[rspec-users] Are there any ways to detect spec faults during a run?

David Chelimsky dchelimsky at gmail.com
Sun Mar 13 09:58:21 EDT 2011


On Mar 9, 2011, at 6:00 AM, Magnus Erickson wrote:

> Hi,
> Is there a way to detect if an example has failed? Something like a: "example_failed?" method.
> In my case I need to dump some information, i.e trace and error log, to be used when analyzing what
> went wrong in the example. I'm thinking about putting it in a after(:each) {}.

after(:each) won't work because failures aren't actually reported out until all of the after hooks are processed.

Your best bet is a custom formatter. See:

http://relishapp.com/rspec/rspec-core/v/2-5/dir/formatters/custom-formatters
http://relishapp.com/rspec/rspec-core/v/2-5/dir/command-line/format-option

HTH,
David




More information about the rspec-users mailing list