Skip to content

Instantly share code, notes, and snippets.

@daipresents
Last active July 4, 2017 11:18
Show Gist options
  • Save daipresents/96d2de61dcff3c1067c667d720d6cda6 to your computer and use it in GitHub Desktop.
Save daipresents/96d2de61dcff3c1067c667d720d6cda6 to your computer and use it in GitHub Desktop.
# 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
it 'should randomly succeed', :retry => 3 do
expect(rand(2)).to eq(1)
end
# 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