Not specifically, but you can configure an around hook to do what you want:

Rspec.configure do |config|
  config.around(:example) do |example|
    begin
      example.run
    rescue Net::ReadTimeout
      # … your code
      raise
    end
  end
end


Jon Rowe
---------------------------
[email protected]
jonrowe.co.uk


On Thursday, 23 July 2015 at 11:06, Dylan Reichstadt wrote:

> Hey All,
>  
> I am looking to add better instrumentation around exceptions thrown in rspec. 
> For example, I want to track how many times I get a Net::ReadTimeout error 
> from Capybara/Rspec.
>  
> In a limited scope, I have been:
> Rescuing this exception
> Incrementing a global variable
> Re-raising that exception again (after incrementing)
>  
> However, this exception can happen across all examples. I don't want to wrap 
> every scenario in a Begin & Rescue block - that sounds extremely messy.
>  
> Does rspec have something to help with this, or does anyone have any ideas I 
> can achieve better tracking of exceptions? I have been googling around RSpec 
> and Catching All Exceptions, but can't find anything.  
>  
> --  
> You received this message because you are subscribed to the Google Groups 
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> (mailto:[email protected]).
> To post to this group, send email to [email protected] 
> (mailto:[email protected]).
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rspec/88d51b4d-2bb3-4391-bffd-476663474a07%40googlegroups.com
>  
> (https://groups.google.com/d/msgid/rspec/88d51b4d-2bb3-4391-bffd-476663474a07%40googlegroups.com?utm_medium=email&utm_source=footer).
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/B0B309A143F64C02BC9E29EC27A39E65%40jonrowe.co.uk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to