Sha256: 14adf9c3011f0bf5d1aa55a0cd5cb9d64ccfc72fefa7126248e3acbb0578a45d

Contents?: true

Size: 1.1 KB

Versions: 79

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

class MsgrAutoAckConsumer < Msgr::Consumer
  self.auto_ack = true

  def index
  end
end

class MsgrManualAckConsumer < Msgr::Consumer
  self.auto_ack = false

  def index
  end
end

describe Msgr::Dispatcher do
  let(:config) { {} }
  let(:args) { [config] }
  let(:dispatcher) { Msgr::Dispatcher.new(*args) }
  subject { dispatcher }

  describe 'dispatch' do
    it 'should ack messages automatically if auto_ack is enabled' do
      route_db = double('Route', :consumer => 'MsgrAutoAckConsumer', :action => :index)
      msg_db = double('Message', :route => route_db, :acked? => false)
      expect(msg_db).to receive(:ack)
      expect(msg_db).not_to receive(:nack)

      dispatcher.dispatch(msg_db)
    end

    it 'should not ack messages if auto_ack is disabled' do
      route_db = double('Route', :consumer => 'MsgrManualAckConsumer', :action => :index)
      msg_db = double('Message', :route => route_db, :acked? => false)
      expect(msg_db).not_to receive(:ack)
      expect(msg_db).not_to receive(:nack)

      dispatcher.dispatch(msg_db)
    end
  end
end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
msgr-1.2.0 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b306 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b305 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b302 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b301 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b300 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b297 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b296 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b295 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b292 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b291 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b288 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b285 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b263 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b249 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b248 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b244 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b241 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b240 spec/msgr/msgr/dispatcher_spec.rb
msgr-1.1.0.1.b239 spec/msgr/msgr/dispatcher_spec.rb