First of all, I agree that funny external API calls are the right thing to do most of the time. However, not in this case.
I get random Timeout::Error
exceptions in some of my tests, and I would like to be able to ignore them and automatically re-run the example. Failure should be reported only after 10 failed attempts.
All other exceptions and failures should be reported.
I tried to implement this behavior using the global around(:each)
hook in the spec/spec_helper.rb
:
RSpec.configure do |config| config.around(:each) do |example| attempts = 0 passed = false begin attempts +=1 example.run passed = true rescue Timeout::Error => e raise e if attempts >= 10 end until passed end end
However, the rescue part never starts when an exception occurs. Any idea why?
Thanks! Dorian
PS I am using rspec 2.6.0
source share