Sha256: eeab93b53ea4d7951fcc4b9e958adc7d7cb1540aa0623344e8a3f94b45e4e2ac

Contents?: true

Size: 1.27 KB

Versions: 9

Compression:

Stored size: 1.27 KB

Contents

# encoding: utf-8

require 'spec_helper'
require 'integration/eventmachine/spec_helper'

describe AMQ::Client::EventMachineClient, "Basic.Return" do
  include EventedSpec::SpecHelper
  default_timeout 1.0

  context "when messages are sent to a direct exchange not bound to a queue" do
    let(:messages) { (0..9).map {|i| "Message #{i}" } }

    it "should return all the messages" do
      @returned_messages = []
      em_amqp_connect do |client|
        channel = AMQ::Client::Channel.new(client, 1)
        channel.open do
          queue = AMQ::Client::Queue.new(client, channel).declare(false, false, false, true)
          # need to delete the queue manually because we don't start consumption,
          # hence, no auto-delete
          delayed(0.4) { queue.delete }

          exchange = AMQ::Client::Exchange.new(client, channel, "direct-exchange", :direct).declare.on_return do |method, header, body|
            @returned_messages << method.reply_text
          end

          messages.each do |message|
            exchange.publish(message, AMQ::Protocol::EMPTY_STRING, {}, true, false)
          end
        end

        done(0.6) {
          @returned_messages.size == messages.size
        }
      end

      @returned_messages.should == ["NO_ROUTE"] * messages.size
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
amq-client-1.0.4 spec/integration/eventmachine/basic_return_spec.rb
amq-client-1.0.3 spec/integration/eventmachine/basic_return_spec.rb
amq-client-1.1.0.pre1 spec/integration/eventmachine/basic_return_spec.rb
amq-client-1.0.2 spec/integration/eventmachine/basic_return_spec.rb
amq-client-1.0.1 spec/integration/eventmachine/basic_return_spec.rb
amq-client-1.0.0 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.9.12 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.9.11 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.9.10 spec/integration/eventmachine/basic_return_spec.rb