Sha256: c2203c0fd4ed5aeb41bcd6844cbbbd33cc4ede5cf09a25e264bf57fad7ca0baa

Contents?: true

Size: 989 Bytes

Versions: 8

Compression:

Stored size: 989 Bytes

Contents

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

8 entries across 8 versions & 1 rubygems

Version Path
msgr-0.14.1.1.b125 spec/msgr/msgr_spec.rb
msgr-0.14.1.1.b124 spec/msgr/msgr_spec.rb
msgr-0.14.1.1.b112 spec/msgr/msgr_spec.rb
msgr-0.14.1.1.b111 spec/msgr/msgr_spec.rb
msgr-0.14.1.1.b110 spec/msgr/msgr_spec.rb
msgr-0.14.1 spec/msgr/msgr_spec.rb
msgr-0.14.0 spec/msgr/msgr_spec.rb
msgr-0.13.0 spec/msgr/msgr_spec.rb