Detecting status of a spec in after block

Hi
inside an after :each block, whats the best way to find out if the
current spec has run? Right now the only solution I have is
self.example.instance_variable_get(:@exception).nil?. Is there a
better solution?

Also, is there an on_error hook I can use instead of an after :each
block?

thanks
Vishnu

On Jan 20, 2011, at 8:17 AM, vishnu wrote:

Hi
inside an after :each block, whats the best way to find out if the
current spec has run?

If you’re in an after block, the current spec has run. No need to query
anything.

Right now the only solution I have is
self.example.instance_variable_get(:@exception).nil?. Is there a
better solution?

There is not. There is example.metadata[:execution_result], but it
doesn’t get the exception until after the afters (in case one has an
exception).

What is it you’re trying to do?

Also, is there an on_error hook I can use instead of an after :each block?

That’s an interesting idea, but again, what are you trying to
accomplish?

Cheers,
David

On Thu, Jan 20, 2011 at 8:49 PM, David C. [email protected]
wrote:

On Jan 20, 2011, at 8:17 AM, vishnu wrote:

Hi
inside an after :each block, whats the best way to find out if the
current spec has run?

If you’re in an after block, the current spec has run. No need to query
anything.

oops, what I meant was succeeded or failed, not run.

That’s an interesting idea, but again, what are you trying to accomplish?
I’m running functional tests (ui driven tests) and whenever a spec has
failed, I’d like to grab a screenshot and save it.