spec/unit/models/protocol_message_spec.rb in ably-1.1.7 vs spec/unit/models/protocol_message_spec.rb in ably-1.1.8
- old
+ new
@@ -8,13 +8,13 @@
def new_protocol_message(options)
subject.new({ action: 1 }.merge(options))
end
- # TR4n, TR4b, TR4c, TR4d, TR4e
+ # TR4n, TR4b, TR4c, TR4d
it_behaves_like 'a model',
- with_simple_attributes: %w(id channel channel_serial connection_id connection_key),
+ with_simple_attributes: %w(id channel channel_serial connection_id),
base_model_options: { action: 1 } do
let(:model_args) { [] }
end
@@ -174,10 +174,32 @@
it '#has_presence_flag? is false' do
expect(protocol_message.has_presence_flag?).to be_falsey
end
end
+ context 'when attach resumed flag' do
+ context 'flags is 34' do
+ let(:protocol_message) { new_protocol_message(flags: 34) }
+
+ it '#has_attach_resume_flag? is true' do
+ expect(protocol_message.has_attach_resume_flag?).to be_truthy
+ end
+
+ it '#has_attach_presence_flag? is false' do
+ expect(protocol_message.has_attach_presence_flag?).to be_falsey
+ end
+ end
+
+ context 'flags is 0' do
+ let(:protocol_message) { new_protocol_message(flags: 0) }
+
+ it 'should raise an exception if flags is a float number' do
+ expect(protocol_message.has_attach_resume_flag?).to be_falsy
+ end
+ end
+ end
+
context 'when channel resumed and presence flags present' do
let(:protocol_message) { new_protocol_message(flags: 5) }
it '#has_channel_resumed_flag? is true' do
expect(protocol_message.has_channel_resumed_flag?).to be_truthy
@@ -412,27 +434,9 @@
let(:protocol_message) { new_protocol_message({}) }
it 'contains an empty AuthDetails object' do
expect(auth).to be_a(Ably::Models::AuthDetails)
expect(auth.access_token).to eql(nil)
- end
- end
- end
-
- context '#connection_key (#TR4e)' do
- context 'existing only in #connection_details.connection_key' do
- let(:protocol_message) { new_protocol_message(connectionDetails: { connectionKey: 'key' }) }
-
- it 'is returned' do
- expect(protocol_message.connection_key).to eql('key')
- end
- end
-
- context 'existing in both #connection_key and #connection_details.connection_key' do
- let(:protocol_message) { new_protocol_message(connectionKey: 'deprecated', connectionDetails: { connectionKey: 'key' }) }
-
- it 'returns #connection_details.connection_key as #connection_key will be deprecated > 0.8' do
- expect(protocol_message.connection_key).to eql('key')
end
end
end
end