Sha256: c61189917d6d5a4ad2daa475474ff340572b50a67747be31793f4ab16975c590

Contents?: true

Size: 1.28 KB

Versions: 23

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

RSpec.describe Deimos::Backends::Base do
  include_context 'with publish_backend'
  it 'should call execute' do
    expect(described_class).to receive(:execute).
      with(messages: messages, producer_class: MyProducer)
    described_class.publish(producer_class: MyProducer, messages: messages)
  end

  describe 'payload_log method' do
    it 'should return whole payload (default behavior)' do
      log_message = described_class.send(:log_message, messages)
      expect(log_message[:payloads].count).to eq(3)
      expect(log_message[:payloads].first[:payload]).to eq({ 'foo' => 1 })
      expect(log_message[:payloads].first[:key]).to eq('foo1')
    end

    it 'should return only keys of messages' do
      Deimos.config.payload_log = :keys
      log_message = described_class.send(:log_message, messages)
      expect(log_message[:payload_keys].count).to eq(3)
      expect(log_message[:payload_keys]).to be_a(Array)
      expect(log_message[:payload_keys].first).to eq('foo1')
    end

    it 'should return only messages count' do
      Deimos.config.payload_log = :count
      log_message = described_class.send(:log_message, messages)
      expect(log_message[:payloads_count]).to be_a(Integer)
      expect(log_message[:payloads_count]).to eq(3)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
deimos-ruby-1.24.2 spec/backends/base_spec.rb
deimos-ruby-1.24.1 spec/backends/base_spec.rb
deimos-ruby-1.24.0 spec/backends/base_spec.rb
deimos-ruby-1.23.3 spec/backends/base_spec.rb
deimos-ruby-1.23.2 spec/backends/base_spec.rb
deimos-ruby-1.23.1.pre.beta6 spec/backends/base_spec.rb
deimos-ruby-1.23.1.pre.beta5 spec/backends/base_spec.rb
deimos-ruby-1.23.1.pre.beta4 spec/backends/base_spec.rb
deimos-ruby-1.23.1.pre.beta3 spec/backends/base_spec.rb
deimos-ruby-1.23.1.pre.beta2 spec/backends/base_spec.rb
deimos-ruby-1.23.1.pre.beta1 spec/backends/base_spec.rb
deimos-ruby-1.23.0 spec/backends/base_spec.rb
deimos-ruby-1.22.5 spec/backends/base_spec.rb
deimos-ruby-1.22.4 spec/backends/base_spec.rb
deimos-ruby-1.22.3 spec/backends/base_spec.rb
deimos-ruby-1.22.2 spec/backends/base_spec.rb
deimos-ruby-1.22.1 spec/backends/base_spec.rb
deimos-ruby-1.22 spec/backends/base_spec.rb
deimos-ruby-1.20.1 spec/backends/base_spec.rb
deimos-ruby-1.20.0 spec/backends/base_spec.rb