Skip to content

Commit

Permalink
sleep interval supports floats; exponential backoff test is faster
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelglass committed May 15, 2018
1 parent f2c3a83 commit a42546e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rspec/retry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def run
example.example_group_instance.instance_exec(example, &RSpec.configuration.retry_callback)
end

sleep sleep_interval if sleep_interval.to_i > 0
sleep sleep_interval if sleep_interval.to_f > 0
end
end

Expand Down
8 changes: 6 additions & 2 deletions spec/lib/rspec/retry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,17 @@ class SharedError < StandardError; end
end
end

context "with exponential backoff enabled", :retry => 3, :retry_wait => 5, :exponential_backoff => true do
context "with exponential backoff enabled", :retry => 3, :retry_wait => 0.001, :exponential_backoff => true do
context do
before(:all) { set_expectations([false, false, true]) }
before(:all) do
set_expectations([false, false, true])
@start_time = Time.now
end

it 'should run example until :retry times', :retry => 3 do
expect(true).to be(shift_expectation)
expect(count).to eq(3)
expect(Time.now - @start_time).to be >= (0.001)
end
end
end
Expand Down

0 comments on commit a42546e

Please sign in to comment.