如何缩短 RSpec 2 中测试失败的回溯?
当我的规格遇到错误时,我收到如下消息:
Vendor should reject duplicate names
Failure/Error: user_with_duplicate_email.should_not be_valid
expected valid? to return false, got true
# /home/kevin/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/rspec-expectations-2.3.0/lib/rspec/expectations/fail_with.rb:29:in `fail_with'
# /home/kevin/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/rspec-expectations-2.3.0/lib/rspec/expectations/handler.rb:44:in `handle_matcher'
# /home/kevin/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/rspec-expectations-2.3.0/lib/rspec/expectations/extensions/kernel.rb:50:in `should_not'
.
.
about 15 more lines
.
.
# /home/kevin/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/drb/drb.rb:1592:in `block (2 levels) in main_loop'
# /home/kevin/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/drb/drb.rb:1588:in `loop'
# /home/kevin/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/drb/drb.rb:1588:in `block in main_loop'
我正在运行 Ruby 1.0.2、rails (3.0.3) 和 rspec (2.3.0)。 M .rspec 配置文件仅指定了两个选项:
--drb --颜色
如何关闭扩展跟踪?
When my specs hit an error, I get a message like this:
Vendor should reject duplicate names
Failure/Error: user_with_duplicate_email.should_not be_valid
expected valid? to return false, got true
# /home/kevin/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/rspec-expectations-2.3.0/lib/rspec/expectations/fail_with.rb:29:in `fail_with'
# /home/kevin/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/rspec-expectations-2.3.0/lib/rspec/expectations/handler.rb:44:in `handle_matcher'
# /home/kevin/.rvm/gems/ruby-1.9.2-p136@rails3tutorial/gems/rspec-expectations-2.3.0/lib/rspec/expectations/extensions/kernel.rb:50:in `should_not'
.
.
about 15 more lines
.
.
# /home/kevin/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/drb/drb.rb:1592:in `block (2 levels) in main_loop'
# /home/kevin/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/drb/drb.rb:1588:in `loop'
# /home/kevin/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/drb/drb.rb:1588:in `block in main_loop'
I'm running Ruby 1.0.2, rails (3.0.3), and rspec (2.3.0). M .rspec configuration file has only two options specified:
--drb
--colour
How do I turn off the extended trace?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
spec_helper.rb
中,您可以使用以下代码片段过滤回溯:In
spec_helper.rb
you can filter backtrace using the following code snippet:我将其更新为与 Rspec 3.2.3 一起使用。在
spec_helper.rb
中输入:这是纯金。谢谢卢阿卡苏斯!
I updated it to work with with Rspec 3.2.3. In
spec_helper.rb
put:This is pure gold. Thank you luacassus!