Jim Burgess wrote:
> Hi,
>
> Testing the view of an application with functional tests, how would one
> go about checking that there are a certain number of <span> elements
> present on a page, which all belong to a certain class.
>
> I tried:
>
> assert_select "form" do
> assert_select "span", :class=> "required_field", :count => 13
> end
>
> But this just found all of the span elements on the page and returned
> false.
At a guess...
assert_xhtml do
form :xpath! => 'count(.//span[ @class = "required_field" ]) = 13'
end
If that doesn't work, look up the XPath syntax for count(). If that _still_
doesn't work, throw away assert_xhtml, and drop down raw XPath thru Nokogiri to
do it.
(gem install rkelly nokogiri assert2, and require 'assert2/xhtml', to get
assert_xhtml, IIRC..)
--
Phlip
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---