Full stracktrace in ruby 1.9

F

Freak Guard

I'm getting stacktraces like:

expected Foo, got #<NoMethodError: undefined method `bar=' for
nil:NilClass>
spec/models/foobar_spec.rb:79:in `block (6 levels) in <top (required)>'

but it would be way more useful to get the 6 levels. How to enable that
globally?
 
R

Roger Pack

Freak said:
I'm getting stacktraces like:

expected Foo, got #<NoMethodError: undefined method `bar=' for
nil:NilClass>
spec/models/foobar_spec.rb:79:in `block (6 levels) in <top (required)>'

but it would be way more useful to get the 6 levels. How to enable that
globally?

add this somewhere:


at_exit {
puts "==== "
puts $!.backtrace.join("\n")
puts "===="
}

Though there are other options [1]

http://github.com/rogerdpack/ruby_backtracer/blob/master/backtrace_nothing_swallowed.rb
 
R

Robert Klemme

Freak said:
I'm getting stacktraces like:

expected Foo, got #<NoMethodError: undefined method `bar=' for
nil:NilClass>
spec/models/foobar_spec.rb:79:in `block (6 levels) in <top (required)>'

but it would be way more useful to get the 6 levels. How to enable that
globally?

add this somewhere:


at_exit {
puts "==== "
puts $!.backtrace.join("\n")
puts "===="
}

Though there are other options [1]

http://github.com/rogerdpack/ruby_backtracer/blob/master/backtrace_nothing_swallowed.rb

You could simply wrap the whole script or the offending region in begin
rescue.

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top