diff --git a/lib/ably/models/protocol_message.rb b/lib/ably/models/protocol_message.rb index 07572bb88..1534a135e 100644 --- a/lib/ably/models/protocol_message.rb +++ b/lib/ably/models/protocol_message.rb @@ -216,6 +216,11 @@ def has_transient_flag? flags & 16 == 16 # 2^4 end + # @api private + def has_attach_resume_flag? + flags & 32 == 32 # 2^5 + end + # @api private def has_attach_presence_flag? flags & 65536 == 65536 # 2^16 diff --git a/spec/unit/models/protocol_message_spec.rb b/spec/unit/models/protocol_message_spec.rb index cdbee41de..53c7a20a6 100644 --- a/spec/unit/models/protocol_message_spec.rb +++ b/spec/unit/models/protocol_message_spec.rb @@ -176,6 +176,28 @@ def new_protocol_message(options) 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) }