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
You won't get access to local variables (easily) without debugger
being in scope of the block, however RSpec
provides you with around hooks which let's you do this:
config.around(:each) do |example|
result = example.run
debugger if result.is_a?(Exception)
puts "Debugging enabled"
end
You then have access to @ivars
and subject
/ let(:var)
contents at this point.