きゅうりのステップでは、特定のul
要素に 5 つの子が必要であることがわかっていli
ます。Webrat でこれをどのように主張できますか?
私は次のようなものがあるかもしれないと推測しています:
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)")
別の更新:
Matt が提供したものに少し変更を加えました。
Then /^I should see ([0-9]+) "([^\"]*)"$/ do |count, selector|
response.body.should have_selector(selector, :count => count.to_i)
end
御馳走になります!