Sha256: bb87a05923bb63ad67a5726cb697d2ab114c5e74d63f1c2fdc27f35589f622ab

Contents?: true

Size: 1.28 KB

Versions: 14

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

RSpec.describe(Deimos::Message) do
  it 'should detect tombstones' do
    expect(described_class.new(nil, nil, key: 'key1')).
      to be_tombstone
    expect(described_class.new({ v: 'val1' }, nil, key: 'key1')).
      not_to be_tombstone
    expect(described_class.new({ v: '' }, nil, key: 'key1')).
      not_to be_tombstone
    expect(described_class.new({ v: 'val1' }, nil, key: nil)).
      not_to be_tombstone
  end

  it 'can support complex keys/values' do
    expect { described_class.new({ a: 1, b: 2 }, nil, key: { c: 3, d: 4 }) }.
      not_to raise_exception
  end

  describe 'headers' do
    it 'returns nil when not set' do
      expect(described_class.new({ v: 'val1' }, nil, key: 'key1')).
        to have_attributes(headers: nil)
    end

    it 'can set and get headers' do
      expect(described_class.new({ v: 'val1' }, nil, key: 'key1', headers: { a: 1 })).
        to have_attributes(headers: { a: 1 })
    end

    it 'includes headers when converting to Hash' do
      expect(described_class.new({ v: 'val1' }, nil, key: 'key1', headers: { a: 1 }).to_h).
        to include(headers: { a: 1 })

      expect(described_class.new({ v: 'val1' }, nil, key: 'key1', headers: { a: 1 }).encoded_hash).
        to include(headers: { a: 1 })
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
deimos-ruby-1.24.2 spec/message_spec.rb
deimos-ruby-1.24.1 spec/message_spec.rb
deimos-ruby-1.24.0 spec/message_spec.rb
deimos-ruby-1.23.3 spec/message_spec.rb
deimos-ruby-1.23.2 spec/message_spec.rb
deimos-ruby-1.23.1.pre.beta6 spec/message_spec.rb
deimos-ruby-1.23.1.pre.beta5 spec/message_spec.rb
deimos-ruby-1.23.1.pre.beta4 spec/message_spec.rb
deimos-ruby-1.23.1.pre.beta3 spec/message_spec.rb
deimos-ruby-1.23.1.pre.beta2 spec/message_spec.rb
deimos-ruby-1.23.1.pre.beta1 spec/message_spec.rb
deimos-ruby-1.23.0 spec/message_spec.rb
deimos-ruby-1.22.5 spec/message_spec.rb
deimos-ruby-1.22.4 spec/message_spec.rb