OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/spec/support/rspec_retry.rb

41 lines
1.1 KiB

require 'rspec/retry'
require 'retriable'
##
# Enable specs to mark metadata retry: <count> to retry that given example
# immediately after it fails.
#
# This DOES NOT retry all specs by default.
RSpec.configure do |config|
##
# Print verbose information on when an example is being retried
# and print the exception that causes a retry
config.verbose_retry = true
config.display_try_failure_messages = true
##
# By default, retry specs twice
# TODO rather set this on features themselves.
config.default_retry_count = 2
end
##
# Allow specific code blocks to retry on specific errors
Retriable.configure do |c|
# Three tries in that block
c.tries = 3
end
##
# Helper to pass options to retriable while logging
# failures
def retry_block(args: {}, &block)
log_errors = Proc.new do |exception, try, elapsed_time, next_interval|
$stderr.puts <<-EOS.strip_heredoc
#{exception.class}: '#{exception.message}'
#{try} tries in #{elapsed_time} seconds and #{next_interval} seconds until the next try.
EOS
end
Retriable.retriable(args.merge(on_retry: log_errors), &block)
end