Sha256: 508fc6c75dbceb9bb437c0c66f4b25e711dadd9c2bfce61d69f033ecb706dca3
Contents?: true
Size: 1.55 KB
Versions: 10
Compression:
Stored size: 1.55 KB
Contents
# Welcome to Karafka-Testing 2.0! Karafka-Testing 2.0 some breaking changes in the way consumer builder and message publishing is done. ## Upgrade Please upgrade your application to `Karafka 2.0` first. - Replace `#karafka_consumer_for` in your specs with `#karafka.consumer_for` - Replace `#publish_for_karafka` in your specs with `#karafka.publish` And that's all! Below you can find same example written for Karafka `2.0` and `1.4`. ### Karafka 2.0 ```ruby RSpec.describe CountersConsumer do subject(:consumer) { karafka.consumer_for(:counters) } let(:nr1_value) { rand } let(:nr2_value) { rand } let(:sum) { nr1_value + nr2_value } before do karafka.publish({ 'number' => nr1_value }.to_json) karafka.publish({ 'number' => nr2_value }.to_json, partition: 2) allow(Karafka.logger).to receive(:info) end it 'expects to log a proper message' do expect(Karafka.logger).to receive(:info).with("Sum of 2 elements equals to: #{sum}") consumer.consume end end ``` ### Karafka 1.4 ```ruby RSpec.describe InlineBatchConsumer do subject(:consumer) { karafka_consumer_for(:counters) } let(:nr1_value) { rand } let(:nr2_value) { rand } let(:sum) { nr1_value + nr2_value } before do publish_for_karafka({ 'number' => nr1_value }.to_json) publish_for_karafka({ 'number' => nr2_value }.to_json, partition: 2) allow(Karafka.logger).to receive(:info) end it 'expects to log a proper message' do expect(Karafka.logger).to receive(:info).with("Sum of 2 elements equals to: #{sum}") consumer.consume end end ```
Version data entries
10 entries across 10 versions & 1 rubygems