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

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -