NoRedInk/rspec-retry

Idea: refactor so that it can be used programatically

rstacruz opened this issue · 2 comments

It'd be nice to do this:

# Call `retry` around each example in this context
around(:each) { |example| retry example, 3 }

This will be useful to attach custom retry behavior to some tags:

# Attempt to retry any failing Selenium tests due to some net errors
RSpec.configure do |config|
  config.around :each, :selenium do |example|
    retry example, 3, exceptions: [Net::ConnectError]
  end
end
# elsewhere:
describe "your feature", :selenium do
  it "should work" do
    # run this 3x
  end
end

At the moment, to do what the above is supposed to do, you'll need to do describe "your scenario", exceptions_to_retry: [Net::ConnectError], retry: 3, selenium: true do, which will be very cumbersome to type on every spec that needs it.

@rstacruz I tried your suggestion, but it turns out that retry is a Ruby keyword and can't be overridden with a method. I was able to do some refactoring and implement a method on Example. Check out #45 and let me know what you think.

released in 0.4.5, thanks @dwbutler