[rspec-users] Exception handling

Marcos Chicote totochicote at gmail.com
Wed Jun 30 10:05:20 EDT 2010

I don't think so, but I don't really know how to check it programatically.
I don't mean exceptions in *before/after *methos, but inside *it()* method

I would like to write something like this:
after(:each) do
if exception_occured_on_it_method?

Is that possible?

On Wed, Jun 30, 2010 at 10:58 AM, David Chelimsky <dchelimsky at gmail.com>wrote:

> On Jun 30, 2010, at 8:45 AM, Marcos Chicote wrote:
> Hello,
> I'm new in Rspec and I would like to ask a question.
> Suppose I have a test that fails raising an exception. I do not want the
> test to raise an exception and I'm not expecting one, but something fails
> and an exception occurs.
> Is there some way to handle that exception and do something in that case?
> I was thinking of some way of checking that a test failed in *after(:each)
> * method and handle the error there (I want to clear some variables and
> re-start others).
> Is that possible?
> Exceptions in before/after(:all) will bubble up as exceptions, but
> exceptions in before/after(:each) or in the examples are handled and treated
> as failures. Are you experiencing something different?
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100630/1bd1be69/attachment.html>

More information about the rspec-users mailing list