0
<div id="look_here">
  <a href="stackoverflow.com"><img src="xxxxxxxxxx.xxx"></a>
</div>

Capybara(およびRSpec)でこのリンクをどのようにテストしますか?

画像は動的に生成されるので、でテストしたいと思いhrefます。

4

2 に答える 2

1

これは機能するはずです:

page.should have_xpath("//a[@href='stackoverflow.com']")
于 2012-08-16T02:48:44.630 に答える
1
page.should have_selector "a[href='stackoverflow.com']"

http://www.w3.org/TR/CSS2/selector.htmlのセクション5.8.1マッチング属性と属性値を参照してください。

于 2012-08-16T02:59:07.947 に答える