当我运行任何失败的RSpec测试时,我会得到许多我不太了解的消息。
例如,假设我跑:
expect(true).to be_false
然后我的控制台变得混乱了以#
Failures:
1) Some test
Failure/Error: expect(true).to be_false
expected true to respond to `false?`
# ./spec/controllers/wing_relationships_controller_spec.rb:43:in `block (3 levels) in <top (required)>'
# /Users/mac/.rvm/gems/ruby-2.1.2@global/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `load'
# /Users/mac/.rvm/gems/ruby-2.1.2@global/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `block in load'
# /Users/mac/.rvm/gems/ruby-2.1.2@global/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
# /Users/mac/.rvm/gems/ruby-2.1.2@global/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `load'
# /Users/mac/.rvm/gems/ruby-2.1.2@global/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `load'
# /Users/mac/.rvm/gems/ruby-2.1.2@global/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `block in load'
# /Users/mac/.rvm/gems/ruby-2.1.2@global/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
# /Users/mac/.rvm/gems/ruby-2.1.2@global/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:241:in `load'
# -e:1:in `<main>'
错误信息总是有所不同,有时它们非常长。
当我进行多次测试时,很难读取结果。我想摆脱那些。有什么建议?我已经关闭了RSpec中的--warning
答案 0 :(得分:0)
最好找出错误的来源并修复泄漏的规范,而忽略错误。
如果您因某些原因对此不感兴趣,那么您可以随时使用: 如果你真的想要使用一个简单的技巧:
rspec 2>/dev/null
答案 1 :(得分:0)
从https://github.com/rspec/rspec-rails/issues/1237
得到了这个答案要从输出中删除gem,它是一行配置:
RSpec.configure do |config|
config.backtrace_exclusion_patterns << %r{/gems/}
end
或者,如果您只想过滤掉您的回溯中的特定宝石:
RSpec.configure do |config|
config.filter_gems_from_backtrace "rack", "rack-test", "capybara"
end