Sha256: 20cd98855244f40226f2075df273654e4c90fc84d9d27b0368ffe9782bf1f20a

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

require "spec_helper"

describe Bunny::Queue, "#subscribe" do
  let(:connection) do
    c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
    c.start
    c
  end

  after :all do
    connection.close if connection.open?
  end

  context "with automatic acknowledgement mode" do
    let(:queue_name) { "bunny.basic_consume#{rand}" }

    it "registers the consumer" do
      delivered_keys = []
      delivered_data = []

      t = Thread.new do
        ch = connection.create_channel
        q = ch.queue(queue_name, :auto_delete => true, :durable => false)
        q.subscribe(:exclusive => false, :ack => false) do |delivery_info, properties, payload|
          delivered_keys << delivery_info.routing_key
          delivered_data << payload
        end
      end
      t.abort_on_exception = true
      sleep 0.5

      ch = connection.create_channel
      x  = ch.default_exchange
      x.publish("hello", :routing_key => queue_name)

      sleep 0.7
      delivered_keys.should include(queue_name)
      delivered_data.should include("hello")

      ch.queue(queue_name, :auto_delete => true, :durable => false).message_count.should == 0

      ch.close
    end
  end

  context "with manual acknowledgement mode" do
    let(:queue_name) { "bunny.basic_consume#{rand}" }

    it "register a consumer with manual acknowledgements mode"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bunny-0.9.0.pre6 spec/higher_level_api/integration/basic_consume_spec.rb
bunny-0.9.0.pre5 spec/higher_level_api/integration/basic_consume_spec.rb
bunny-0.9.0.pre4 spec/higher_level_api/integration/basic_consume_spec.rb
bunny-0.9.0.pre3 spec/higher_level_api/integration/basic_consume_spec.rb
bunny-0.9.0.pre2 spec/higher_level_api/integration/basic_consume_spec.rb