Often, when a test fails, I spend quite sometime trying to figure out the what caused it to fail. It'd be useful if RSpec could kick off a Ruby debugger when the test fails, so that I can inspect the local variables immediately to drill down on the cause.
The work-around I'm using right now looks something like this:
# withing some test
debugger unless some_variable.nil?
expect(some_variable).to be_nil
However, this approach is cumbersome, because I first wait for a test to fail, then add the debugger line, fix the issue and then have to remove the debugger line, whereas I want it work more like gdb
which has the ability to kick in when an exception is hit, without requiring to pepper your code base with debugger
statements.
Edit: I've tried Plymouth. It hasn't worked reliably enough for me. Also the development history seems to indicate that it isn't a very well supported gem, so I'd rather not rely on it.
Update: I tried out pry-rescue
and find it to be neat. However, I use zeus a lot and was wondering if there's a way to make it work with pry-rescue
.