如何让水豚匹配器工作?
我正在寻找 CSS 类。我的 HAML 是:
.friends
= image_tag 'news-face.png'
%p 15
我的测试是:
it "Should show friends count on popular feed" do
visit '/'
page.should have_css('.friends')
end
我收到错误:
Failure/Error: page.should have_css('.friends')
expected css ".friends" to return something
我尝试过 should
、should_not
、& have_selector
并且不知道出了什么问题。
I'm searching for a CSS class. My HAML is:
.friends
= image_tag 'news-face.png'
%p 15
My test is:
it "Should show friends count on popular feed" do
visit '/'
page.should have_css('.friends')
end
I'm getting an error:
Failure/Error: page.should have_css('.friends')
expected css ".friends" to return something
I've tried should
, should_not
, & have_selector
and can't figure out what's wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的页面上似乎没有这样的元素。自己解决这个问题的最佳方法是安装:
然后使用:
使用这个 gem 和命令,您将能够从测试中渲染此页面。
It seems that you don't have such element on your page. The best way to figure it out by yourself is to install:
and then just use:
With this gem and command you will be able to render this page from your test.
也许您会使用
has_css
选择器。Maybe you would use
has_css
selector.