RSpec::Retry adds a :retry
option for intermittently failing rspec examples. If an example has the :retry
option, rspec will retry the example the specified number of times until the example succeeds.
NoRedInk used to be a Ruby shop, and we open-sourced this in the hope that it will help other people. However, we've been moving away from Ruby for some time now, and only plan to do maintenance on this repo when we have an internal need for it. We don't plan to add any new functionality, and expect that it will fall behind the latest versions of Ruby and Rspec.
That said, if you're reading this and you need this gem to do something new, feel free to fork it and publish your own gem! If you open an issue here to let us know about your fork, we can add a link to it from this repo to help folks find something that's more actively maintained.
Add this line to your application's Gemfile:
gem 'rspec-retry', group: :test # Unlike rspec, this doesn't need to be included in development group
And then execute:
Or install it yourself as:
$ gem install rspec-retry
require in spec_helper.rb
# spec/spec_helper.rb require 'rspec/retry' RSpec.configure do |config| # show retry status in spec process config.verbose_retry = true # show exception that triggers a retry if verbose_retry is set to true config.display_try_failure_messages = true # run retry only on features config.around :each, :js do |ex| ex.run_with_retry retry: 3 end # callback to be run between retries config.retry_callback = proc do |ex| # run some additional clean up task - can be filtered by example metadata if ex.metadata[:js] Capybara.reset! end end end
it 'should randomly succeed', :retry => 3 do expect(rand(2)).to eq(1) end it 'should succeed after a while', :retry => 3, :retry_wait => 10 do expect(command('service myservice status')).to eq('started') end # run spec (following log is shown if verbose_retry options is true) # RSpec::Retry: 2nd try ./spec/lib/random_spec.rb:49 # RSpec::Retry: 3rd try ./spec/lib/random_spec.rb:49Calling
run_with_retry
programmatically
You can call ex.run_with_retry(opts)
on an individual example.
let
s before retryinggit checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4