开发者

Turn on full backtrace in Ruby on Rails TestCase

Only one line of backtrace is displayed when I run:

rake test

Output:

...

ERROR should get search for keywords (1.93s) 
  NoMethodError: undefined method `features' for #<Transcript:0x00000006243780>
  /usr/lib/ruby/gems/1.9.1/gems/activemodel-3.1.0/lib/active_model/attribute_methods.rb:385:in `method_missing'

...

I need more lines of backtrack information. I have tried

  • rake test --trace

  • Rails.backtrace_cleaner.remove_silencers! in config/initializers/backtrace_silencers.rb

  • setting global $DEBUG=true

and it开发者_开发技巧 didn't work.

How can I turn it on?


BACKTRACE=blegga rake test

BACKTRACE=blegga rails test # rails 5+

Append --trace if you need rake related log.


Nowdays you can run:

rails test --backtrace


Finally figured this out. The issue is with the 'turn' gem included in Rails 3.1, or actually with turn v0.8.2, which is required by the default Gemfile:

group :test do
  # Pretty printed test output
  gem 'turn', '0.8.2', require: false
end

Turn v0.8.2 doesn't include the full backtrace, so you have to upgrade to get it. I did that by changing the above in my Gemfile to this:

group :test do
  # Pretty printed test output
  gem 'turn', require: false
  gem 'minitest'
end

(I had to add minitest because otherwise turn throws a RuntimeError saying "MiniTest v1.6.0 is out of date.")

Then I ran bundle update turn and got the latest verion (0.9.2 as of this writing). That gives full backtraces.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜