For a cucumber step, I know that a particular ul
element should have 5 children li
. How can I assert this with Webrat?
I'm guessing there could be something like:
Then ".selector" should have n ".another-selector"
or maybe
Then I should see n ".selector" within ".another.selector"
Is there anything like this floating around, or should I make a custom step?
Thanks!
Update:
I've resorted to the following, which seems to work fine:
# Check there are the correct number of items
assert_have_selector("#activity ol li:nth-child(5)")
assert_have_no_selector("#activity ol li:nth-child(6)")
Another update:
I've made a little change to what Matt has supplied:
Then /^I should see ([0-9]+) "([^\"]*)"$/ do |count, selector|
response.body.should have_selector(selector, :count => count.to_i)
end
Works a treat!