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
Post a Comment