I am trying to run an RSpec test, and I want to detect if the test failed in the after
method. I have something like this right now:
after(:each
EDIT: this answer is only valid for RSpec 2. for RSpec 3 see geekazoid's answer.
The after each block runs in the context of class which exposes example
and you can detect failures by checking the exception
method on example
thusly:
after(:each) do
if example.exception != nil
# Failure only code goes here
end
end