简体   繁体   English

如何获取rspec以显示在失败的测试中找到的内容

[英]how to get rspec to show what it found on failed tests

I wrote an rspec test it { should have_title("Title | Subtitle") } 我写了一个rspec测试it { should have_title("Title | Subtitle") }

When I go to said page from localhost I see the correct title displayed, however, when I run my rspec test, I get: 当我从本地主机转到所述页面时,我看到显示的正确标题,但是,当我运行rspec测试时,我得到:

Failure/Error: it { should have_title("Title | Subtitle") }
       expected #has_title?("Title | Subtitle") to return true, got false

How can I ask rspec to print out the title it found instead? 如何要求rspec打印出找到的标题?

Thanks 谢谢

has_title? is a capybara matcher. 是水豚配对者。 rspec is not involved there, that matcher just returns true or false. rspec在那里不涉及,匹配器仅返回true或false。

if you want to get the title, you need to do something like expect(page.title).to eql('blah') 如果您想获得标题,则需要执行类似于expect(page.title).to eql('blah')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM