Full stracktrace in ruby 1.9

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?

···

--
Posted via http://www.ruby-forum.com/.

Freak Guard wrote:

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

···

--
Posted via http://www.ruby-forum.com/\.

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

  robert

···

On 25.09.2009 16:40, Roger Pack wrote:

Freak Guard wrote:

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

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/