spec/consumer_spec.rb in deimos-ruby-1.22.5 vs spec/consumer_spec.rb in deimos-ruby-1.23.0
- old
+ new
@@ -1,8 +1,9 @@
# frozen_string_literal: true
# :nodoc:
+# rubocop:disable Metrics/ModuleLength
module ConsumerTest
describe Deimos::Consumer, 'Message Consumer' do
prepend_before(:each) do
# :nodoc:
consumer_class = Class.new(described_class) do
@@ -24,12 +25,16 @@
end
describe 'consume' do
SCHEMA_CLASS_SETTINGS.each do |setting, use_schema_classes|
context "with Schema Class consumption #{setting}" do
+
before(:each) do
- Deimos.configure { |config| config.schema.use_schema_classes = use_schema_classes }
+ Deimos.configure do |config|
+ config.schema.use_schema_classes = use_schema_classes
+ config.schema.generate_namespace_folders = true
+ end
end
it 'should consume a message' do
test_consume_message(MyConsumer,
{ 'test_id' => 'foo',
@@ -125,10 +130,45 @@
call_original: true)
}.to raise_error('This should not be called unless call_original is set')
end
end
end
+
+ context 'with overriden schema classes' do
+
+ before(:each) do
+ Deimos.configure do |config|
+ config.schema.use_schema_classes = true
+ config.schema.generate_namespace_folders = true
+ end
+ end
+
+ prepend_before(:each) do
+ consumer_class = Class.new(described_class) do
+ schema 'MyUpdatedSchema'
+ namespace 'com.my-namespace'
+ key_config field: 'test_id'
+
+ # :nodoc:
+ def consume(_payload, _metadata)
+ raise 'This should not be called unless call_original is set'
+ end
+ end
+ stub_const('ConsumerTest::MyConsumer', consumer_class)
+ end
+
+ it 'should consume messages' do
+ test_consume_message('my_consume_topic',
+ { 'test_id' => 'foo',
+ 'some_int' => 1 }) do |payload, _metadata|
+ expect(payload['test_id']).to eq('foo')
+ expect(payload['some_int']).to eq(1)
+ expect(payload['super_int']).to eq(9000)
+ end
+ end
+
+ end
end
describe 'decode_key' do
it 'should use the key field in the value if set' do
@@ -216,5 +256,6 @@
end
end
end
end
+# rubocop:enable Metrics/ModuleLength