如何在 Rails 测试用例中显示更长的跟踪 [英] How to show longer traces in Rails TestCases

查看:35
本文介绍了如何在 Rails 测试用例中显示更长的跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有要设置的配置变量,或者是否有其他方法可以让 Rails ActiveSupport::TestCase 显示多个跟踪行?否则真的很难调试.

Is there a config variable to set, or some other way to get Rails ActiveSupport::TestCase to show more than one trace line? It is really hard to debug otherwise.

示例:

ERROR test_something (0.73s) 
      SystemStackError: stack level too deep
      /Users/mario/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database_statements.rb:153

推荐答案

查看是否没有文件 config/initializers/backtrace_silencers.rb

它说:

# You can also remove all the silencers if you're trying to debug
# a problem that might stem from framework code.
Rails.backtrace_cleaner.remove_silencers!

如果第一个还不够,您也可以调用 remove_filters!,但过滤器只会使路径更短,而消音器确实会从回溯中删除一些行.

You can also call remove_filters! if the first was not enough, but filters only make the paths shorter, while silencers do remove some lines from the backtrace.

您可能会发现 railties/lib/rails/backtrace_cleaner.rbactivesupport/lib/active_support/backtrace_cleaner.rb 中的源代码很有用.

You may find the source code in railties/lib/rails/backtrace_cleaner.rb and activesupport/lib/active_support/backtrace_cleaner.rb useful.

这篇关于如何在 Rails 测试用例中显示更长的跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆