我有下一个html代码:
<ul class="nav">
<li class="active">
<a href="/users/page">Page</a>
</li>
...
</ul>
我想确保我在类“active”中有li标签。
因此,我尝试过:
response.should have_selector( "li", :class => "active" ,:content => "Page")
而且它不起作用,我得到这样的错误:
Failure/Error: response.should have_selector( "li", :class => "active" ,:content => "Page")
expected following output to contain a <li class='active'>Page</li> tag:
我该如何解决我的问题?
最佳答案
我认为您可以将类添加到CSS选择器。就像是:
response.body.should have_selector( "li.active", :content => 'Page')
关于ruby-on-rails - Rspec 2-标签内的类名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9608891/