6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/rspec/flaky/test.rb', line 6
def self.apply!
RSpec.configure do |config|
config.add_setting :flaky_tries, default: 3
config.around(:example) do |example|
next example.run unless example.metadata[:flaky]
tries = RSpec.configuration.flaky_tries
current_example = RSpec.current_example
tries.times do |try_count|
current_example.instance_variable_set(:@exception, nil)
example.run
break unless current_example.exception
end
end
end
end
|