spec/unit/models/token_details_spec.rb in ably-1.1.8 vs spec/unit/models/token_details_spec.rb in ably-1.2.0
- old
+ new
@@ -78,9 +78,23 @@
it 'is always false' do
expect(subject.expired?).to eql(false)
end
end
+
+ context 'with :from attribute' do
+ subject { Ably::Models::TokenDetails.new(expires: expire_time) }
+
+ let(:server_offset_time) { 2 * 60 * 60 } # 2 hours
+
+ it 'is false' do
+ expect(subject.expired?(from: (Time.now - server_offset_time))).to eql(false)
+ end
+
+ it 'is true' do
+ expect(subject.expired?(from: Time.now)).to eql(true)
+ end
+ end
end
end
context '==' do
let(:token_attributes) { { token: 'unique' } }