# 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