On Wed, May 20, 2009 at 11:38 AM, Jim Burgess
<rails-mailing-l...@andreas-s.net> 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.

You need to use the css selector to specify spans with a particular class:

assert_select("span.required_field", :count => 13)

-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to