Skip to content

Commit e14cea9

Browse files
authored
Use rspec-retry to retry this test up to 3 times. (#977)
Looks like even a 2 second time delta is not always sufficient, thus instead of always accepting a huge delta insist on a small delta but run the test several times until it succeeds.
1 parent ee59f10 commit e14cea9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ group :development, :testing do
2525
end
2626
end
2727

28+
group :testing do
29+
gem 'rspec-retry'
30+
end
31+
2832
group :development do
2933
gem 'ruby-prof', :platforms => :mri
3034
gem 'pry-rescue'

spec/mongo/client_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,8 +1604,8 @@
16041604
expect(session).to be_a(Mongo::Session)
16051605
end
16061606

1607-
it 'sets the last use field to the current time' do
1608-
expect(session.instance_variable_get(:@server_session).last_use).to be_within(2).of(Time.now)
1607+
it 'sets the last use field to the current time', retry: 4 do
1608+
expect(session.instance_variable_get(:@server_session).last_use).to be_within(1).of(Time.now)
16091609
end
16101610

16111611
context 'when options are provided' do

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
require 'support/authorization'
8080
require 'support/primary_socket'
8181
require 'support/constraints'
82+
require 'rspec/retry'
8283

8384
RSpec.configure do |config|
8485
config.include(Authorization)

0 commit comments

Comments
 (0)