def run
example = current_example
loop do
if attempts > 0
RSpec.configuration.formatters.each { |f| f.retry(example) if f.respond_to? :retry }
if verbose_retry?
message = "RSpec::Retry: #{ordinalize(attempts + 1)} try #{example.location}"
message = "\n" + message if attempts == 1
RSpec.configuration.reporter.message(message)
end
end
example.metadata[:retry_attempts] = self.attempts
example.clear_exception
ex.run
self.attempts += 1
break if example.exception.nil?
break if attempts >= retry_count
if exceptions_to_hard_fail.any?
break if exception_exists_in?(exceptions_to_hard_fail, example.exception)
end
if exceptions_to_retry.any?
break unless exception_exists_in?(exceptions_to_retry, example.exception)
end
if verbose_retry? && display_try_failure_messages?
if attempts != retry_count
exception_strings =
if ::RSpec::Core::MultipleExceptionError::InterfaceTag === example.exception
example.exception.all_exceptions.map(&:to_s)
else
[example.exception.to_s]
end
try_message = "\n#{ordinalize(attempts)} Try error in #{example.location}:\n#{exception_strings.join "\n"}\n"
RSpec.configuration.reporter.message(try_message)
end
end
example.example_group_instance.clear_lets if clear_lets
if RSpec.configuration.retry_callback
example.example_group_instance.instance_exec(example, &RSpec.configuration.retry_callback)
end
sleep sleep_interval if sleep_interval.to_f > 0
end
end