对于黄瓜步骤,我知道
ul
元素应该有5个子元素
li
我猜可能会有这样的情况:
Then ".selector" should have n ".another-selector"
或者也许
Then I should see n ".selector" within ".another.selector"
谢谢!
更新:
我采取了以下措施,似乎效果不错:
# 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)")
另一个更新:
我对马特提供的东西做了一点改动:
Then /^I should see ([0-9]+) "([^\"]*)"$/ do |count, selector|
response.body.should have_selector(selector, :count => count.to_i)
end
工作是一种享受!