1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
# encoding: utf-8
require 'spec_helper'
describe AMQP::Queue do
#
# Environment
#
include EventedSpec::AMQPSpec
default_timeout 5
#
# Examples
#
describe "#status" do
it "yields # of messages & consumers to the callback" do
events = []
channel = AMQP::Channel.new
queue1 = channel.queue("", :auto_delete => true)
queue2 = channel.queue("amqpgem.tests.a.named.queue", :auto_delete => true)
EventMachine.add_timer(1.0) do
queue1.status do |m, c|
events << :queue1_declare_ok
end
queue2.status do |m, c|
events << :queue2_declare_ok
end
end
done(2.0) {
events.should include(:queue1_declare_ok)
events.should include(:queue2_declare_ok)
}
end
it "yields # of messages & consumers to the callback in pseudo-synchronous code" do
events = []
channel = AMQP::Channel.new
queue1 = channel.queue("", :auto_delete => true)
queue2 = channel.queue("amqpgem.tests.a.named.queue", :auto_delete => true)
queue1.status do |m, c|
events << :queue1_declare_ok
end
queue2.status do |m, c|
events << :queue2_declare_ok
end
done(2.0) {
queue1.name.should =~ /^amq\..+/
events.should include(:queue1_declare_ok)
events.should include(:queue2_declare_ok)
}
end
end
end
|