spec/unit/models/token_details_spec.rb in ably-1.2.4 vs spec/unit/models/token_details_spec.rb in ably-1.2.6

- old
+ new

@@ -54,10 +54,11 @@ end end context '#expired?' do let(:expire_time) { Time.now + Ably::Models::TokenDetails::TOKEN_EXPIRY_BUFFER } + let(:clock_skew) { 1 } # clock skew of 1 second context 'once grace period buffer has passed' do subject { Ably::Models::TokenDetails.new(expires: expire_time - 1) } it 'is true' do @@ -72,11 +73,11 @@ expect(subject.expired?).to eql(false) end end context 'when expires is not available (i.e. string tokens)' do - subject { Ably::Models::TokenDetails.new() } + subject { Ably::Models::TokenDetails.new } it 'is always false' do expect(subject.expired?).to eql(false) end end @@ -88,11 +89,12 @@ it 'is false' do expect(subject.expired?(from: (Time.now - server_offset_time))).to eql(false) end + # Test is flaky and fails on CI, so adding a bit of extra tolerance (clock_skew) to make it work it 'is true' do - expect(subject.expired?(from: Time.now)).to eql(true) + expect(subject.expired?(from: Time.now + clock_skew)).to eql(true) end end end end