unit testing - Rails test: test image_tag on view -



unit testing - Rails test: test image_tag on view -

i'm writing view tests , want test image:

<%= image_tag "icon.png", class: "img-responsive" %>

so made test, not working:

it 'app logo' render assert_select 'img.img-responsive[src=?]', asset_path('icon.png') end

it works if utilize following, think not right way of doing it:

it 'app logo' render assert_select 'img.img-responsive[src=?]', '/assets/icon.png' end

what problem? right why test rspec?

try using capybara:

page.should have_selector(:xpath, xpath_of_the_image_element)

ruby-on-rails unit-testing view rspec

Comments

Popular posts from this blog

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -