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 67 68 69 70 71 72 73 74 75 76 77
|
# encoding: utf-8
require "spec_helper"
describe "A 'Hello, world'-like example with a non-empty message" do
#
# Environment
#
include EventedSpec::AMQPSpec
default_options AMQP_OPTS
default_timeout 5
amqp_before do
@channel = AMQP::Channel.new
@channel.on_error do |ch, close|
raise "Channel-level error!: #{close.inspect}"
end
@queue = @channel.queue("", :auto_delete => true)
@exchange = @channel.direct("amqpgem.tests.integration.direct.exchange", :auto_delete => true)
@queue.bind(@exchange, :routing_key => "messages.all")
end
it "is delivered" do
consumer1 = AMQP::Consumer.new(@channel, @queue).consume
consumer1.on_delivery do |metadata, payload|
done
end
EventMachine.add_timer(0.5) do
@exchange.publish("Hello!", :routing_key => "messages.all")
end
end
end
describe "A 'Hello, world'-like example with a blank message" do
#
# Environment
#
include EventedSpec::AMQPSpec
default_options AMQP_OPTS
default_timeout 5
amqp_before do
@channel = AMQP::Channel.new
@channel.on_error do |ch, close|
raise "Channel-level error!: #{close.inspect}"
end
@queue = @channel.queue("", :auto_delete => true)
@exchange = @channel.direct("amqpgem.tests.integration.direct.exchange", :auto_delete => true)
@queue.bind(@exchange, :routing_key => "messages.all")
end
it "is delivered" do
consumer1 = AMQP::Consumer.new(@channel, @queue).consume
consumer1.on_delivery do |metadata, payload|
done
end
EventMachine.add_timer(0.5) do
@exchange.publish("", :routing_key => "messages.all")
end
end
end
|