0

きゅうりのステップでは、特定の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

御馳走になります!

4

1 に答える 1

1

これは私がそれを行う方法です:

Then /^"([^\"]*)" should have ([0-9]+) "([^\"]*)"$/ do |selector1, count, selector2|
  within(selector1) do |content|
       content.should have_selector(selector2, :count => count.to_i)
  end
end

それはトリックを行うべきですか?

マッタ

于 2010-07-08T22:53:42.457 に答える