NoRedInk/rspec-retry

`exceptions_to_retry` does not retry child exceptions

dwbutler opened this issue · 2 comments

Hi, I'm running into an issue with retrying exceptions. I've added the following configuration to Rspec:

config.exceptions_to_retry = [Selenium::WebDriver::Error::WebDriverError]

The intention was to catch a whole bunch of Selenium errors that all descend from WebDriverError. (A biggy is Selenium::WebDriver::Error::StaleElementReferenceError). My expectation was that child exceptions would be caught and retried, similar to how Ruby's rescue works.

Unfortunately, it appears that only specific error classes are retried, as indicated by this line:

https://github.com/NoRedInk/rspec-retry/blob/master/lib/rspec/retry.rb#L57

I propose replacing it with something like:

break unless exceptions_to_retry.any? do |exception_klass|
  example.exception.class < exception_klass
end

Checks out. You wanna create a PR?

Sure thing, here you go: #41