Exi*_*iRe 6 rspec ruby-on-rails rspec2 ruby-on-rails-3.1
我有下一个HTML代码:
<ul class="nav">
<li class="active">
<a href="/users/page">Page</a>
</li>
...
</ul>
Run Code Online (Sandbox Code Playgroud)
我想确保我的li标签有"active"类并且在该文本中.
所以,我尝试过:
response.should have_selector( "li", :class => "active" ,:content => "Page")
Run Code Online (Sandbox Code Playgroud)
它不起作用,我得到这样的错误:
Failure/Error: response.should have_selector( "li", :class => "active" ,:content => "Page")
expected following output to contain a <li class='active'>Page</li> tag:
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决我的问题?
小智 9
我认为你可以将类添加到css选择器.就像是:
response.body.should have_selector( "li.active", :content => 'Page')
Run Code Online (Sandbox Code Playgroud)
我解决了它:
response.body.should have_selector( "li.active") do
have_selector('a', :content => 'Pages')
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1469 次 |
| 最近记录: |