spec/consumer_spec.rb in deimos-ruby-1.12.4 vs spec/consumer_spec.rb in deimos-ruby-1.12.5

- old
+ new

@@ -30,12 +30,12 @@ Deimos.configure { |config| config.schema.use_schema_classes = use_schema_classes } end it 'should consume a message' do test_consume_message(MyConsumer, - 'test_id' => 'foo', - 'some_int' => 123) do |payload, _metadata| + {'test_id' => 'foo', + 'some_int' => 123}) do |payload, _metadata| expect(payload['test_id']).to eq('foo') expect(payload['some_int']).to eq(123) end end @@ -62,19 +62,19 @@ end end it 'should consume a message on a topic' do test_consume_message('my_consume_topic', - 'test_id' => 'foo', - 'some_int' => 123) do |payload, _metadata| + {'test_id' => 'foo', + 'some_int' => 123}) do |payload, _metadata| expect(payload['test_id']).to eq('foo') expect(payload['some_int']).to eq(123) end end it 'should fail on invalid message' do - test_consume_invalid_message(MyConsumer, 'invalid' => 'key') + test_consume_invalid_message(MyConsumer, {'invalid' => 'key'}) end it 'should fail if reraise is false but fatal_error is true' do Deimos.configure { |config| config.consumers.reraise_errors = false } test_consume_invalid_message(MyConsumer, 'fatal') @@ -83,48 +83,48 @@ it 'should fail if fatal_error is true globally' do Deimos.configure do |config| config.consumers.fatal_error = proc { true } config.consumers.reraise_errors = false end - test_consume_invalid_message(MyConsumer, 'invalid' => 'key') + test_consume_invalid_message(MyConsumer, {'invalid' => 'key'}) end it 'should fail on message with extra fields' do test_consume_invalid_message(MyConsumer, - 'test_id' => 'foo', + {'test_id' => 'foo', 'some_int' => 123, - 'extra_field' => 'field name') + 'extra_field' => 'field name'}) end it 'should not fail when before_consume fails without reraising errors' do Deimos.configure { |config| config.consumers.reraise_errors = false } expect { test_consume_message( MyConsumer, { 'test_id' => 'foo', 'some_int' => 123 }, - { skip_expectation: true } + skip_expectation: true ) { raise 'OH NOES' } }.not_to raise_error end it 'should not fail when consume fails without reraising errors' do Deimos.configure { |config| config.consumers.reraise_errors = false } expect { test_consume_message( MyConsumer, { 'invalid' => 'key' }, - { skip_expectation: true } + skip_expectation: true ) }.not_to raise_error end it 'should call original' do expect { test_consume_message(MyConsumer, { 'test_id' => 'foo', 'some_int' => 123 }, - { call_original: true }) + call_original: true) }.to raise_error('This should not be called unless call_original is set') end end end end @@ -187,31 +187,31 @@ end it 'should consume a message' do expect(Deimos.config.metrics).to receive(:histogram).twice test_consume_message('my_consume_topic', - 'test_id' => 'foo', + {'test_id' => 'foo', 'some_int' => 123, 'updated_at' => Time.now.to_i, - 'timestamp' => 2.minutes.ago.to_s) do |payload, _metadata| + 'timestamp' => 2.minutes.ago.to_s}) do |payload, _metadata| expect(payload['test_id']).to eq('foo') end end it 'should fail nicely when timestamp wrong format' do expect(Deimos.config.metrics).to receive(:histogram).twice test_consume_message('my_consume_topic', - 'test_id' => 'foo', + {'test_id' => 'foo', 'some_int' => 123, 'updated_at' => Time.now.to_i, - 'timestamp' => 'dffdf') do |payload, _metadata| + 'timestamp' => 'dffdf'}) do |payload, _metadata| expect(payload['test_id']).to eq('foo') end test_consume_message('my_consume_topic', - 'test_id' => 'foo', + {'test_id' => 'foo', 'some_int' => 123, 'updated_at' => Time.now.to_i, - 'timestamp' => '') do |payload, _metadata| + 'timestamp' => ''}) do |payload, _metadata| expect(payload['test_id']).to eq('foo') end end end