我让RoR 4.1.4和RVM一起运行。 RSpec版本是2.14.8。此外,Capybara是v2.1.0。每次我运行rspec
时,我都会得到不必要的输出:
# /home/msnyder/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.4/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
# /home/msnyder/.rvm/gems/ruby-2.1.2/gems/actionpack-4.1.4/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
# /home/msnyder/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/rack/logger.rb:38:in `call_app'
# /home/msnyder/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/rack/logger.rb:20:in `block in call'
# /home/msnyder/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/tagged_logging.rb:68:in `block in tagged'
# /home/msnyder/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/tagged_logging.rb:26:in `tagged'
</snip>
有没有办法抑制这个输出,所以我只看到有趣的东西?
编辑:我已将RSpec更新为3.2.1,将Capybara更新为2.4.4。即使我没有在我正在运行的命令中设置--backtrace
也不在.rspec
文件中,完整的回溯仍然存在。
答案 0 :(得分:0)
我把它放在我的rails_helper中:
RSpec.configure do |config|
# Cleaner backtrace for failure messages
config.backtrace_exclusion_patterns = [
/\/lib\d*\/ruby\//,
/bin\//,
/gems/,
/spec\/spec_helper\.rb/,
/lib\/rspec\/(core|expectations|matchers|mocks)/
]
end
您还可以在此处阅读文档:https://www.relishapp.com/rspec/rspec-core/docs/configuration/excluding-lines-from-the-backtrace