Last active
July 4, 2017 11:18
-
-
Save daipresents/96d2de61dcff3c1067c667d720d6cda6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'pry' | |
require 'rspec/retry' | |
RSpec.configure do |config| | |
# rspec-retry | |
config.verbose_retry = true | |
config.display_try_failure_messages = true | |
config.around :each do |ex| | |
ex.metadata[:retry] = 3 | |
ex.run | |
end | |
end | |
RSpec.describe 'Retry test' do | |
it 'should randomly succeed 1' do | |
num = rand(2) | |
p "test 1: #{num}" | |
expect(num).to eq(1) | |
end | |
it 'should randomly succeed 2' do | |
num = rand(2) | |
p "test 2: #{num}" | |
expect(num).to eq(1) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it 'should randomly succeed', :retry => 3 do | |
expect(rand(2)).to eq(1) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment