-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathqueue_bind_spec.rb
89 lines (64 loc) · 1.98 KB
/
queue_bind_spec.rb
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
78
79
80
81
82
83
84
85
86
87
88
89
RSpec.describe "A queue" do
#
# Environment
#
let(:connection) { MarchHare.connect }
after :each do
connection.close
end
#
# Examples
#
it "can be bound to amq.fanout" do
ch = connection.create_channel
x = ch.exchange("amq.fanout", :type => :fanout, :durable => true, :auto_delete => false)
q = ch.queue("", :exclusive => true)
x.publish("")
expect(q.get).to eq(nil)
q.bind(x)
x.publish("", :routing_key => q.name)
expect(q.get).not_to eq(nil)
end
it "can be bound to a newly declared exchange [an HB::Exchange instance]" do
ch = connection.create_channel
x = ch.exchange("march.hare.fanout", :type => :fanout, :durable => false, :auto_delete => true)
q = ch.queue("", :exclusive => true)
x.publish("")
expect(q.get).to eq(nil)
q.bind(x)
x.publish("", :routing_key => q.name)
expect(q.get).not_to eq(nil)
q.unbind(x)
end
it "can be bound to a newly declared exchange [a string]" do
ch = connection.create_channel
x = ch.exchange("march.hare.fanout", :type => :fanout, :durable => false, :auto_delete => true)
q = ch.queue("", :exclusive => true)
x.publish("")
expect(q.get).to eq(nil)
q.bind("march.hare.fanout")
x.publish("", :routing_key => q.name)
expect(q.get).not_to eq(nil)
q.unbind("march.hare.fanout")
end
it "is automatically bound to the default exchange" do
ch = connection.create_channel
x = ch.default_exchange
q = ch.queue("", :exclusive => true)
x.publish("", :routing_key => q.name)
expect(q.get).not_to eq(nil)
end
context "when the exchange does not exist" do
it "raises an exception" do
ch = connection.create_channel
q = ch.queue("", :exclusive => true)
raised = nil
begin
q.bind("asyd8a9d98sa73t78hd9as^&&(&@#(*^")
rescue MarchHare::NotFound => e
raised = e
end
expect(raised.channel_close.reply_text).to be =~ /no exchange/
end
end
end