bunny 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,90 +21,90 @@ describe Bunny do
21
21
 
22
22
  it "should allow a default direct exchange to be instantiated by specifying :type" do
23
23
  exch = @b.exchange('amq.direct', :type => :direct)
24
- exch.should be_an_instance_of Bunny::Exchange
24
+ exch.should be_an_instance_of(Bunny::Exchange)
25
25
  exch.name.should == 'amq.direct'
26
26
  exch.type.should == :direct
27
- @b.exchanges.has_key?('amq.direct').should be true
27
+ @b.exchanges.has_key?('amq.direct').should be(true)
28
28
  end
29
29
 
30
30
  it "should allow a default direct exchange to be instantiated without specifying :type" do
31
31
  exch = @b.exchange('amq.direct')
32
- exch.should be_an_instance_of Bunny::Exchange
32
+ exch.should be_an_instance_of(Bunny::Exchange)
33
33
  exch.name.should == 'amq.direct'
34
34
  exch.type.should == :direct
35
- @b.exchanges.has_key?('amq.direct').should be true
35
+ @b.exchanges.has_key?('amq.direct').should be(true)
36
36
  end
37
37
 
38
38
  it "should allow a default fanout exchange to be instantiated without specifying :type" do
39
39
  exch = @b.exchange('amq.fanout')
40
- exch.should be_an_instance_of Bunny::Exchange
40
+ exch.should be_an_instance_of(Bunny::Exchange)
41
41
  exch.name.should == 'amq.fanout'
42
42
  exch.type.should == :fanout
43
- @b.exchanges.has_key?('amq.fanout').should be true
43
+ @b.exchanges.has_key?('amq.fanout').should be(true)
44
44
  end
45
45
 
46
46
  it "should allow a default topic exchange to be instantiated without specifying :type" do
47
47
  exch = @b.exchange('amq.topic')
48
- exch.should be_an_instance_of Bunny::Exchange
48
+ exch.should be_an_instance_of(Bunny::Exchange)
49
49
  exch.name.should == 'amq.topic'
50
50
  exch.type.should == :topic
51
- @b.exchanges.has_key?('amq.topic').should be true
51
+ @b.exchanges.has_key?('amq.topic').should be(true)
52
52
  end
53
53
 
54
54
  it "should allow a default headers (amq.match) exchange to be instantiated without specifying :type" do
55
55
  exch = @b.exchange('amq.match')
56
- exch.should be_an_instance_of Bunny::Exchange
56
+ exch.should be_an_instance_of(Bunny::Exchange)
57
57
  exch.name.should == 'amq.match'
58
58
  exch.type.should == :headers
59
- @b.exchanges.has_key?('amq.match').should be true
59
+ @b.exchanges.has_key?('amq.match').should be(true)
60
60
  end
61
61
 
62
62
  it "should allow a default headers (amq.headers) exchange to be instantiated without specifying :type" do
63
63
  exch = @b.exchange('amq.headers')
64
- exch.should be_an_instance_of Bunny::Exchange
64
+ exch.should be_an_instance_of(Bunny::Exchange)
65
65
  exch.name.should == 'amq.headers'
66
66
  exch.type.should == :headers
67
- @b.exchanges.has_key?('amq.headers').should be true
67
+ @b.exchanges.has_key?('amq.headers').should be(true)
68
68
  end
69
69
 
70
70
  it "should create an exchange as direct by default" do
71
71
  exch = @b.exchange('direct_defaultex')
72
- exch.should be_an_instance_of Bunny::Exchange
72
+ exch.should be_an_instance_of(Bunny::Exchange)
73
73
  exch.name.should == 'direct_defaultex'
74
74
  exch.type.should == :direct
75
- @b.exchanges.has_key?('direct_defaultex').should be true
75
+ @b.exchanges.has_key?('direct_defaultex').should be(true)
76
76
  end
77
77
 
78
78
  it "should be able to be instantiated as a direct exchange" do
79
79
  exch = @b.exchange('direct_exchange', :type => :direct)
80
- exch.should be_an_instance_of Bunny::Exchange
80
+ exch.should be_an_instance_of(Bunny::Exchange)
81
81
  exch.name.should == 'direct_exchange'
82
82
  exch.type.should == :direct
83
- @b.exchanges.has_key?('direct_exchange').should be true
83
+ @b.exchanges.has_key?('direct_exchange').should be(true)
84
84
  end
85
85
 
86
86
  it "should be able to be instantiated as a topic exchange" do
87
87
  exch = @b.exchange('topic_exchange', :type => :topic)
88
- exch.should be_an_instance_of Bunny::Exchange
88
+ exch.should be_an_instance_of(Bunny::Exchange)
89
89
  exch.name.should == 'topic_exchange'
90
90
  exch.type.should == :topic
91
- @b.exchanges.has_key?('topic_exchange').should be true
91
+ @b.exchanges.has_key?('topic_exchange').should be(true)
92
92
  end
93
93
 
94
94
  it "should be able to be instantiated as a fanout exchange" do
95
95
  exch = @b.exchange('fanout_exchange', :type => :fanout)
96
- exch.should be_an_instance_of Bunny::Exchange
96
+ exch.should be_an_instance_of(Bunny::Exchange)
97
97
  exch.name.should == 'fanout_exchange'
98
98
  exch.type.should == :fanout
99
- @b.exchanges.has_key?('fanout_exchange').should be true
99
+ @b.exchanges.has_key?('fanout_exchange').should be(true)
100
100
  end
101
101
 
102
102
  it "should be able to be instantiated as a headers exchange" do
103
103
  exch = @b.exchange('headers_exchange', :type => :headers)
104
- exch.should be_an_instance_of Bunny::Exchange
104
+ exch.should be_an_instance_of(Bunny::Exchange)
105
105
  exch.name.should == 'headers_exchange'
106
106
  exch.type.should == :headers
107
- @b.exchanges.has_key?('headers_exchange').should be true
107
+ @b.exchanges.has_key?('headers_exchange').should be(true)
108
108
  end
109
109
 
110
110
  it "should ignore the :nowait option when instantiated" do
@@ -116,11 +116,19 @@ describe Bunny do
116
116
  exch.publish('This is a published message')
117
117
  end
118
118
 
119
+ it "should be able to return an undeliverable message" do
120
+ exch = @b.exchange('')
121
+ exch.publish('This message should be undeliverable', :immediate => true)
122
+ ret_msg = @b.returned_message
123
+ ret_msg.should be_an_instance_of(Hash)
124
+ ret_msg[:payload].should == 'This message should be undeliverable'
125
+ end
126
+
119
127
  it "should be able to be deleted" do
120
128
  exch = @b.exchange('direct_exchange')
121
129
  res = exch.delete
122
130
  res.should == :delete_ok
123
- @b.exchanges.has_key?('direct_exchange').should be false
131
+ @b.exchanges.has_key?('direct_exchange').should be(false)
124
132
  end
125
133
 
126
134
  it "should ignore the :nowait option when deleted" do
@@ -52,10 +52,10 @@ describe Bunny do
52
52
  it "should be able to pop a message complete with header and delivery details" do
53
53
  q = @b.queue('test1')
54
54
  msg = q.pop(:header => true)
55
- msg.should be_an_instance_of Hash
56
- msg[:header].should be_an_instance_of Bunny::Protocol::Header
55
+ msg.should be_an_instance_of(Hash)
56
+ msg[:header].should be_an_instance_of(Bunny::Protocol::Header)
57
57
  msg[:payload].should == 'This is a test message'
58
- msg[:delivery_details].should be_an_instance_of Hash
58
+ msg[:delivery_details].should be_an_instance_of(Hash)
59
59
  q.message_count.should == 0
60
60
  end
61
61
 
@@ -87,7 +87,7 @@ describe Bunny do
87
87
  q = @b.queue('test1')
88
88
  res = q.delete
89
89
  res.should == :delete_ok
90
- @b.queues.has_key?('test1').should be false
90
+ @b.queues.has_key?('test1').should be(false)
91
91
  end
92
92
 
93
93
  it "should ignore the :nowait option when deleted" do
@@ -19,18 +19,37 @@ describe Bunny do
19
19
  @b.status.should == :connected
20
20
  end
21
21
 
22
+ it "should be able to create and open a new channel" do
23
+ c = @b.create_channel
24
+ c.number.should == 2
25
+ c.should be_an_instance_of(Bunny::Channel09)
26
+ @b.channels.size.should == 3
27
+ c.open.should == :open_ok
28
+ @b.channel.number.should == 2
29
+ end
30
+
31
+ it "should be able to switch between channels" do
32
+ @b.channel.number.should == 1
33
+ @b.switch_channel(0)
34
+ @b.channel.number.should == 0
35
+ end
36
+
37
+ it "should raise an error if trying to switch to a non-existent channel" do
38
+ lambda { @b.switch_channel(5)}.should raise_error(RuntimeError)
39
+ end
40
+
22
41
  it "should be able to create an exchange" do
23
42
  exch = @b.exchange('test_exchange')
24
- exch.should be_an_instance_of Bunny::Exchange09
43
+ exch.should be_an_instance_of(Bunny::Exchange09)
25
44
  exch.name.should == 'test_exchange'
26
- @b.exchanges.has_key?('test_exchange').should be true
45
+ @b.exchanges.has_key?('test_exchange').should be(true)
27
46
  end
28
47
 
29
48
  it "should be able to create a queue" do
30
49
  q = @b.queue('test1')
31
- q.should be_an_instance_of Bunny::Queue09
50
+ q.should be_an_instance_of(Bunny::Queue09)
32
51
  q.name.should == 'test1'
33
- @b.queues.has_key?('test1').should be true
52
+ @b.queues.has_key?('test1').should be(true)
34
53
  end
35
54
 
36
55
  it "should be able to set QoS" do
@@ -21,90 +21,90 @@ describe Bunny do
21
21
 
22
22
  it "should allow a default direct exchange to be instantiated by specifying :type" do
23
23
  exch = @b.exchange('amq.direct', :type => :direct)
24
- exch.should be_an_instance_of Bunny::Exchange09
24
+ exch.should be_an_instance_of(Bunny::Exchange09)
25
25
  exch.name.should == 'amq.direct'
26
26
  exch.type.should == :direct
27
- @b.exchanges.has_key?('amq.direct').should be true
27
+ @b.exchanges.has_key?('amq.direct').should be(true)
28
28
  end
29
29
 
30
30
  it "should allow a default direct exchange to be instantiated without specifying :type" do
31
31
  exch = @b.exchange('amq.direct')
32
- exch.should be_an_instance_of Bunny::Exchange09
32
+ exch.should be_an_instance_of(Bunny::Exchange09)
33
33
  exch.name.should == 'amq.direct'
34
34
  exch.type.should == :direct
35
- @b.exchanges.has_key?('amq.direct').should be true
35
+ @b.exchanges.has_key?('amq.direct').should be(true)
36
36
  end
37
37
 
38
38
  it "should allow a default fanout exchange to be instantiated without specifying :type" do
39
39
  exch = @b.exchange('amq.fanout')
40
- exch.should be_an_instance_of Bunny::Exchange09
40
+ exch.should be_an_instance_of(Bunny::Exchange09)
41
41
  exch.name.should == 'amq.fanout'
42
42
  exch.type.should == :fanout
43
- @b.exchanges.has_key?('amq.fanout').should be true
43
+ @b.exchanges.has_key?('amq.fanout').should be(true)
44
44
  end
45
45
 
46
46
  it "should allow a default topic exchange to be instantiated without specifying :type" do
47
47
  exch = @b.exchange('amq.topic')
48
- exch.should be_an_instance_of Bunny::Exchange09
48
+ exch.should be_an_instance_of(Bunny::Exchange09)
49
49
  exch.name.should == 'amq.topic'
50
50
  exch.type.should == :topic
51
- @b.exchanges.has_key?('amq.topic').should be true
51
+ @b.exchanges.has_key?('amq.topic').should be(true)
52
52
  end
53
53
 
54
54
  it "should allow a default headers (amq.match) exchange to be instantiated without specifying :type" do
55
55
  exch = @b.exchange('amq.match')
56
- exch.should be_an_instance_of Bunny::Exchange09
56
+ exch.should be_an_instance_of(Bunny::Exchange09)
57
57
  exch.name.should == 'amq.match'
58
58
  exch.type.should == :headers
59
- @b.exchanges.has_key?('amq.match').should be true
59
+ @b.exchanges.has_key?('amq.match').should be(true)
60
60
  end
61
61
 
62
62
  it "should allow a default headers (amq.headers) exchange to be instantiated without specifying :type" do
63
63
  exch = @b.exchange('amq.headers')
64
- exch.should be_an_instance_of Bunny::Exchange09
64
+ exch.should be_an_instance_of(Bunny::Exchange09)
65
65
  exch.name.should == 'amq.headers'
66
66
  exch.type.should == :headers
67
- @b.exchanges.has_key?('amq.headers').should be true
67
+ @b.exchanges.has_key?('amq.headers').should be(true)
68
68
  end
69
69
 
70
70
  it "should create an exchange as direct by default" do
71
71
  exch = @b.exchange('direct_defaultex')
72
- exch.should be_an_instance_of Bunny::Exchange09
72
+ exch.should be_an_instance_of(Bunny::Exchange09)
73
73
  exch.name.should == 'direct_defaultex'
74
74
  exch.type.should == :direct
75
- @b.exchanges.has_key?('direct_defaultex').should be true
75
+ @b.exchanges.has_key?('direct_defaultex').should be(true)
76
76
  end
77
77
 
78
78
  it "should be able to be instantiated as a direct exchange" do
79
79
  exch = @b.exchange('direct_exchange', :type => :direct)
80
- exch.should be_an_instance_of Bunny::Exchange09
80
+ exch.should be_an_instance_of(Bunny::Exchange09)
81
81
  exch.name.should == 'direct_exchange'
82
82
  exch.type.should == :direct
83
- @b.exchanges.has_key?('direct_exchange').should be true
83
+ @b.exchanges.has_key?('direct_exchange').should be(true)
84
84
  end
85
85
 
86
86
  it "should be able to be instantiated as a topic exchange" do
87
87
  exch = @b.exchange('topic_exchange', :type => :topic)
88
- exch.should be_an_instance_of Bunny::Exchange09
88
+ exch.should be_an_instance_of(Bunny::Exchange09)
89
89
  exch.name.should == 'topic_exchange'
90
90
  exch.type.should == :topic
91
- @b.exchanges.has_key?('topic_exchange').should be true
91
+ @b.exchanges.has_key?('topic_exchange').should be(true)
92
92
  end
93
93
 
94
94
  it "should be able to be instantiated as a fanout exchange" do
95
95
  exch = @b.exchange('fanout_exchange', :type => :fanout)
96
- exch.should be_an_instance_of Bunny::Exchange09
96
+ exch.should be_an_instance_of(Bunny::Exchange09)
97
97
  exch.name.should == 'fanout_exchange'
98
98
  exch.type.should == :fanout
99
- @b.exchanges.has_key?('fanout_exchange').should be true
99
+ @b.exchanges.has_key?('fanout_exchange').should be(true)
100
100
  end
101
101
 
102
102
  it "should be able to be instantiated as a headers exchange" do
103
103
  exch = @b.exchange('headers_exchange', :type => :headers)
104
- exch.should be_an_instance_of Bunny::Exchange09
104
+ exch.should be_an_instance_of(Bunny::Exchange09)
105
105
  exch.name.should == 'headers_exchange'
106
106
  exch.type.should == :headers
107
- @b.exchanges.has_key?('headers_exchange').should be true
107
+ @b.exchanges.has_key?('headers_exchange').should be(true)
108
108
  end
109
109
 
110
110
  it "should ignore the :nowait option when instantiated" do
@@ -116,11 +116,19 @@ describe Bunny do
116
116
  exch.publish('This is a published message')
117
117
  end
118
118
 
119
+ it "should be able to return an undeliverable message" do
120
+ exch = @b.exchange('')
121
+ exch.publish('This message should be undeliverable', :immediate => true)
122
+ ret_msg = @b.returned_message
123
+ ret_msg.should be_an_instance_of(Hash)
124
+ ret_msg[:payload].should == 'This message should be undeliverable'
125
+ end
126
+
119
127
  it "should be able to be deleted" do
120
128
  exch = @b.exchange('direct_exchange')
121
129
  res = exch.delete
122
130
  res.should == :delete_ok
123
- @b.exchanges.has_key?('direct_exchange').should be false
131
+ @b.exchanges.has_key?('direct_exchange').should be(false)
124
132
  end
125
133
 
126
134
  it "should ignore the :nowait option when deleted" do
@@ -52,10 +52,10 @@ describe Bunny do
52
52
  it "should be able to pop a message complete with header and delivery details" do
53
53
  q = @b.queue('test1')
54
54
  msg = q.pop(:header => true)
55
- msg.should be_an_instance_of Hash
56
- msg[:header].should be_an_instance_of Bunny::Protocol09::Header
55
+ msg.should be_an_instance_of(Hash)
56
+ msg[:header].should be_an_instance_of(Bunny::Protocol09::Header)
57
57
  msg[:payload].should == 'This is a test message'
58
- msg[:delivery_details].should be_an_instance_of Hash
58
+ msg[:delivery_details].should be_an_instance_of(Hash)
59
59
  q.message_count.should == 0
60
60
  end
61
61
 
@@ -87,7 +87,7 @@ describe Bunny do
87
87
  q = @b.queue('test1')
88
88
  res = q.delete
89
89
  res.should == :delete_ok
90
- @b.queues.has_key?('test1').should be false
90
+ @b.queues.has_key?('test1').should be(false)
91
91
  end
92
92
 
93
93
  it "should ignore the :nowait option when deleted" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Duncan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-08 00:00:00 +01:00
12
+ date: 2009-08-17 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15