Sha256: ccd912bf95f6109ccebbdb4463c40084c0a5c5c5b66a15878cbc3af49d800195

Contents?: true

Size: 1018 Bytes

Versions: 12

Compression:

Stored size: 1018 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

class Receiver
end

#
class MsgrTestConsumer < Msgr::Consumer
  def index
    Receiver.index
  end

  def error
    Receiver.error
  end
end

describe Msgr do
  let(:queue) { Queue.new }
  let(:client) { Msgr::Client.new size: 1, prefix: SecureRandom.hex(2) }

  before do
    client.routes.configure do
      route 'test.index', to: 'msgr_test#index'
      route 'test.error', to: 'msgr_test#error'
    end

    client.start
  end

  after do
    client.stop delete: true
  end

  it 'should dispatch published methods to consumer' do
    expect(Receiver).to receive(:index) { queue << :end }

    client.publish 'Payload', to: 'test.index'

    Timeout.timeout(4) { queue.pop }
  end

  it 'should redelivery failed messages' do
    expect(Receiver).to receive(:error).ordered.and_raise RuntimeError
    expect(Receiver).to receive(:error).ordered { queue << :end }

    client.publish 'Payload', to: 'test.error'

    Timeout.timeout(4) { queue.pop }
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
msgr-0.15.2.1.b175 spec/msgr/msgr_spec.rb
msgr-0.15.2.1.b169 spec/msgr/msgr_spec.rb
msgr-0.15.2.1.b167 spec/msgr/msgr_spec.rb
msgr-0.15.2.1.b166 spec/msgr/msgr_spec.rb
msgr-0.15.2.1.b165 spec/msgr/msgr_spec.rb
msgr-0.15.2.1.b164 spec/msgr/msgr_spec.rb
msgr-0.15.2.1.b163 spec/msgr/msgr_spec.rb
msgr-0.15.2.1.b162 spec/msgr/msgr_spec.rb
msgr-0.15.2.1.b161 spec/msgr/msgr_spec.rb
msgr-0.15.2.1.b160 spec/msgr/msgr_spec.rb
msgr-0.15.2.1.b159 spec/msgr/msgr_spec.rb
msgr-0.15.2.1.b158 spec/msgr/msgr_spec.rb