Sha256: 338c03c6cc17af96239d5f53786bc369ee5d5d38290f8e47c88ec8f1edf47c8e

Contents?: true

Size: 997 Bytes

Versions: 28

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

require 'avro_turf/messaging'

describe Deimos::AvroDataEncoder do

  let(:encoder) do
    encoder = described_class.new(schema: 'MySchema',
                                  namespace: 'com.my-namespace')
    allow(encoder).to(receive(:encode)) { |payload| payload }
    encoder
  end

  specify 'generate_key_schema' do
    expect_any_instance_of(AvroTurf::SchemaStore).
      to receive(:add_schema).with(
        'type' => 'record',
        'name' => 'MySchema_key',
        'namespace' => 'com.my-namespace',
        'doc' => 'Key for com.my-namespace.MySchema',
        'fields' => [
          {
            'name' => 'test_id',
            'type' => 'string'
          }
        ]
      )
    encoder.send(:_generate_key_schema, 'test_id')
  end

  it 'should encode a key' do
    # reset stub from TestHelpers
    allow(described_class).to receive(:new).and_call_original
    expect(encoder.encode_key('test_id', '123')).to eq('test_id' => '123')
  end

end

Version data entries

28 entries across 28 versions & 2 rubygems

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