0

using: Ruby 2.4.0p0 Rails 5.2.3 while running my test cases: having and error:

My testcase is like:

require 'test_helper'

class SubscriptionsControllerTest < ActionDispatch::IntegrationTest

  test "Can reach to index " do
    get subscriptions_url
    assert_response :success
  end

end

Error:

SubscriptionsControllerTest#test_Can_reach_to_index_:
ActionView::Template::Error: Can't resolve image into URL: undefined method `[]' for nil:NilClass
    app/views/subscriptions/index.html.erb:43:in `_app_views_subscriptions_index_html_erb__900758959545617488_70234463713200'
    test/controllers/subscriptions_controller_test.rb:6:in `block in <class:SubscriptionsControllerTest>'

But the image load correctly when open the ui manually. could you suggest what is wrong. in the view has image_tag as on line no 43.

 <%= image_tag 'tukacad_1.png', alt: '', class: "img-responsive" %>
vidur punj
  • 5,019
  • 4
  • 46
  • 65

1 Answers1

0

inside application.rb or test.rb write the following line

config.serve_static_assets = true

also run

rails assets:precompile
vidur punj
  • 5,019
  • 4
  • 46
  • 65