This seems like it should be real easy to do but I have not found any documentation: I have an image tag in a page: <%= image_tag "arrow_green.gif", :alt => "image did not load" %> And a functional test I would like to write: assert_tag :tag => "img", :attributes => { :src => "arrow_green.gif" } Of course, rails return the asset id at the end, so the test fails: expected tag, but no tag found matching {:tag=>"img", :attributes=>{:src=>"arrow_green.giv"}} in... So is there a way to write a test for this? I know I can use an :alt property and test that, but I really would rather test the :src. Any way to get the asset id within the test so I could write: assert_tag :tag => "img", :attributes => { :src => "arrow_green.gif" + asset_id } -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jun 28, 2010, at 1:37 PM, DK wrote:> This seems like it should be real easy to do but I have not found any documentation: > > I have an image tag in a page: > > <%= image_tag "arrow_green.gif", :alt => "image did not load" %> > > And a functional test I would like to write: > > assert_tag :tag => "img", :attributes => { :src => "arrow_green.gif" } > > Of course, rails return the asset id at the end, so the test fails: > > expected tag, but no tag found matching {:tag=>"img", :attributes=>{:src=>"arrow_green.giv"}} in... > > > So is there a way to write a test for this? I know I can use an :alt property and test that, but I really would rather test the :src. Any way to get the asset id within the test so I could write: > > assert_tag :tag => "img", :attributes => { :src => "arrow_green.gif" + asset_id }Mess around with... ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
DK wrote:> This seems like it should be real easy to do but I have not found any > documentation: > > I have an image tag in a page: > > <%= image_tag "arrow_green.gif", :alt => "image did not load" %> > >Slightly off your question, but...that''s a terrible abuse of the alt attribute. It should have text that can take the place of the image in non-graphical browsers. "Image die not load" is inappropriate alt content and is dealt with by the browser in any case. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.