-
Notifications
You must be signed in to change notification settings - Fork 46
/
queue_declare_spec.rb
59 lines (48 loc) · 1.47 KB
/
queue_declare_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
RSpec.describe "Queue" do
let(:connection) { MarchHare.connect }
let(:channel) { connection.create_channel }
after :each do
channel.close
connection.close
end
it "cannot be created using a symbol as name" do
expect {
channel.queue(:not_valid_name)
}.to raise_error(ArgumentError)
end
context "with a server-generated name" do
it "can be declared as auto-deleted" do
q = channel.queue("", :auto_delete => true)
expect(q).to be_auto_delete
q.delete
end
it "can be declared as auto-deleted and non-durable" do
q = channel.queue("", :auto_delete => true, :durable => false)
expect(q).to be_auto_delete
expect(q).not_to be_durable
q.delete
end
it "can be declared as NON-auto-deleted" do
q = channel.queue("", :auto_delete => false)
expect(q).not_to be_auto_delete
expect(q).not_to be_durable
q.delete
end
it "can be declared as NON-durable" do
q = channel.queue("", :durable => false)
expect(q).not_to be_durable
q.delete
end
it "can be declared with additional attributes like x-message-ttle" do
q = channel.queue("", :durable => false, :arguments => { 'x-message-ttl' => 2000 })
x = channel.exchange("", :type => :direct)
100.times do |i|
x.publish("Message #{i}", :routing_key => q.name)
end
expect(q.get).not_to be_nil
sleep(2.1)
expect(q.get).to be_nil
q.delete
end
end
end