Sha256: 49ca3483ee9f5e4b5e735532ab8e57f80adca98c6d58e01a1ab5a4a7a8f50091
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
require 'spec_helper' class TestConsumer < Msgr::Consumer def index puts "<<< #{payload}" end end describe Msgr::Dispatcher do let(:dispatcher) { described_class.new max: 1 } let(:consumer) { 'TestConsumer' } let(:route) do double(:route).tap do |t| allow(t).to receive(:consumer).and_return consumer allow(t).to receive(:action).and_return 'index' end end let(:connection) do double(:connection).tap do |c| allow(c).to receive(:ack) end end let(:delivery_info) do double(:delivery_info).tap do |ti| allow(ti).to receive(:delivery_tag).and_return { 3 } end end let(:payload) { {} } let(:metadata) do double(:metadata).tap do |metadata| allow(metadata).to receive(:content_type).and_return { 'text/plain' } end end let(:message) { Msgr::Message.new connection, delivery_info, metadata, payload, route } let(:action) { -> { dispatcher.call message }} before do expect_any_instance_of(::Concurrent::CachedThreadPool).to receive(:post).and_return { |m, &block| block.call m} expect_any_instance_of(TestConsumer).to receive(:index) end it 'should consume message' do dispatcher.call message end context 'with not acknowlged message' do before { dispatcher.call message } subject { message } it { should be_acked } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
msgr-0.11.0.rc1 | spec/integration/msgr/dispatcher_spec.rb |
msgr-0.10.2 | spec/integration/msgr/dispatcher_spec.rb |