Sha256: 62b64b93e2a83f86e24b6a0d717ebfae0d892ce85afe8337250169587bce109e

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

each_db_config(Deimos::Backends::Db) do
  include_context 'with publish_backend'

  it 'should save to the database' do
    described_class.publish(producer_class: MyProducer, messages: messages)
    records = Deimos::KafkaMessage.all
    expect(records.size).to eq(3)
    expect(records[0].attributes.to_h).to include(
      'message' => '{"foo"=>1}',
      'topic' => 'my-topic',
      'key' => 'foo1'
    )
    expect(records[1].attributes.to_h).to include(
      'message' => '{"foo"=>2}',
      'topic' => 'my-topic',
      'key' => 'foo2'
    )
    expect(records[2].attributes.to_h).to include(
      'message' => '{"foo"=>3}',
      'topic' => 'my-topic',
      'key' => 'foo3'
    )
  end
  it 'should add to non-keyed messages' do
    described_class.publish(producer_class: MyNoKeyProducer,
                            messages: messages)
    expect(Deimos::KafkaMessage.count).to eq(3)
    described_class.publish(producer_class: MyNoKeyProducer,
                            messages: [messages.first])
    expect(Deimos::KafkaMessage.count).to eq(4)

  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
deimos-ruby-1.0.0.pre.beta22 spec/backends/db_spec.rb
deimos-kafka-1.0.0.pre.beta21 spec/backends/db_spec.rb
deimos-kafka-1.0.0.pre.beta20 spec/backends/db_spec.rb
deimos-kafka-1.0.0.pre.beta19 spec/backends/db_spec.rb
deimos-kafka-1.0.0.pre.beta18 spec/backends/db_spec.rb
deimos-kafka-1.0.0.pre.beta17 spec/backends/db_spec.rb
deimos-kafka-1.0.0.pre.beta16 spec/backends/db_spec.rb
deimos-kafka-1.0.0.pre.beta15 spec/backends/db_spec.rb