Sha256: 0af937fbe82907002c895f411e421c51a3cb569b439a6d85d8bdb38ac4afbd7e

Contents?: true

Size: 1.24 KB

Versions: 21

Compression:

Stored size: 1.24 KB

Contents

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|
            @returned_messages << method.reply_text
          end

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

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

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

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
amq-client-0.7.0.alpha21 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha20 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha19 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha18 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha17 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha16 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha15 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha14 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha13 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha12 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha11 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha10 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha9 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha8 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha7 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha6 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha5 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha4 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha3 spec/integration/eventmachine/basic_return_spec.rb
amq-client-0.7.0.alpha2 spec/integration/eventmachine/basic_return_spec.rb