Skip to content

Instantly share code, notes, and snippets.

@isuke
Created July 2, 2018 06:29
Show Gist options
  • Select an option

  • Save isuke/0372eabb250664d066d7732d1dfa5890 to your computer and use it in GitHub Desktop.

Select an option

Save isuke/0372eabb250664d066d7732d1dfa5890 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
require 'rspec/retry'
RSpec.configure do |config|
if ENV['RAKSUL_AD_RSPEC_RETRY']&.match?(/true/i)
# 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, type: :system do |ex|
retry_num = ex.metadata[:retry] || ENV['RAKSUL_AD_RSPEC_RETRY_NUM']&.to_i || 2
ex.run_with_retry retry: retry_num
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
Capybara.reset! if ex.metadata[:system]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment