bunny 1.3.0 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE.md +18 -0
  3. data/.gitignore +7 -1
  4. data/.rspec +1 -3
  5. data/.travis.yml +21 -14
  6. data/CONTRIBUTING.md +132 -0
  7. data/ChangeLog.md +887 -1
  8. data/Gemfile +13 -13
  9. data/LICENSE +1 -1
  10. data/README.md +46 -60
  11. data/Rakefile +54 -0
  12. data/bunny.gemspec +5 -11
  13. data/docker-compose.yml +28 -0
  14. data/docker/Dockerfile +24 -0
  15. data/docker/apt/preferences.d/erlang +3 -0
  16. data/docker/apt/sources.list.d/bintray.rabbitmq.list +2 -0
  17. data/docker/docker-entrypoint.sh +26 -0
  18. data/docker/rabbitmq.conf +29 -0
  19. data/examples/connection/automatic_recovery_with_basic_get.rb +1 -1
  20. data/examples/connection/automatic_recovery_with_client_named_queues.rb +1 -1
  21. data/examples/connection/automatic_recovery_with_multiple_consumers.rb +1 -1
  22. data/examples/connection/automatic_recovery_with_republishing.rb +1 -1
  23. data/examples/connection/automatic_recovery_with_server_named_queues.rb +1 -1
  24. data/examples/connection/channel_level_exception.rb +1 -9
  25. data/examples/connection/disabled_automatic_recovery.rb +1 -1
  26. data/examples/connection/heartbeat.rb +1 -1
  27. data/examples/consumers/high_and_low_priority.rb +1 -1
  28. data/examples/guides/extensions/alternate_exchange.rb +2 -0
  29. data/examples/guides/extensions/basic_nack.rb +1 -1
  30. data/examples/guides/extensions/dead_letter_exchange.rb +1 -1
  31. data/examples/guides/getting_started/hello_world.rb +2 -0
  32. data/examples/guides/getting_started/weathr.rb +2 -0
  33. data/examples/guides/queues/one_off_consumer.rb +2 -0
  34. data/examples/guides/queues/redeliveries.rb +4 -2
  35. data/lib/bunny.rb +8 -4
  36. data/lib/bunny/channel.rb +268 -153
  37. data/lib/bunny/channel_id_allocator.rb +6 -4
  38. data/lib/bunny/concurrent/continuation_queue.rb +34 -13
  39. data/lib/bunny/consumer_work_pool.rb +34 -6
  40. data/lib/bunny/cruby/socket.rb +48 -21
  41. data/lib/bunny/cruby/ssl_socket.rb +65 -4
  42. data/lib/bunny/exceptions.rb +25 -4
  43. data/lib/bunny/exchange.rb +24 -28
  44. data/lib/bunny/get_response.rb +1 -1
  45. data/lib/bunny/heartbeat_sender.rb +3 -2
  46. data/lib/bunny/jruby/socket.rb +23 -6
  47. data/lib/bunny/jruby/ssl_socket.rb +5 -0
  48. data/lib/bunny/queue.rb +31 -22
  49. data/lib/bunny/reader_loop.rb +31 -18
  50. data/lib/bunny/session.rb +448 -159
  51. data/lib/bunny/test_kit.rb +14 -0
  52. data/lib/bunny/timeout.rb +1 -12
  53. data/lib/bunny/transport.rb +205 -98
  54. data/lib/bunny/version.rb +1 -1
  55. data/repl +1 -1
  56. data/spec/config/enabled_plugins +1 -0
  57. data/spec/config/rabbitmq.conf +13 -0
  58. data/spec/higher_level_api/integration/basic_ack_spec.rb +175 -16
  59. data/spec/higher_level_api/integration/basic_cancel_spec.rb +77 -11
  60. data/spec/higher_level_api/integration/basic_consume_spec.rb +60 -55
  61. data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +6 -6
  62. data/spec/higher_level_api/integration/basic_get_spec.rb +31 -7
  63. data/spec/higher_level_api/integration/basic_nack_spec.rb +22 -19
  64. data/spec/higher_level_api/integration/basic_publish_spec.rb +11 -100
  65. data/spec/higher_level_api/integration/basic_qos_spec.rb +32 -4
  66. data/spec/higher_level_api/integration/basic_reject_spec.rb +94 -16
  67. data/spec/higher_level_api/integration/basic_return_spec.rb +4 -4
  68. data/spec/higher_level_api/integration/channel_close_spec.rb +51 -10
  69. data/spec/higher_level_api/integration/channel_open_spec.rb +12 -12
  70. data/spec/higher_level_api/integration/connection_recovery_spec.rb +424 -221
  71. data/spec/higher_level_api/integration/connection_spec.rb +300 -126
  72. data/spec/higher_level_api/integration/connection_stop_spec.rb +31 -19
  73. data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +17 -17
  74. data/spec/higher_level_api/integration/dead_lettering_spec.rb +34 -11
  75. data/spec/higher_level_api/integration/exchange_bind_spec.rb +5 -5
  76. data/spec/higher_level_api/integration/exchange_declare_spec.rb +32 -31
  77. data/spec/higher_level_api/integration/exchange_delete_spec.rb +12 -12
  78. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +5 -5
  79. data/spec/higher_level_api/integration/exclusive_queue_spec.rb +5 -5
  80. data/spec/higher_level_api/integration/heartbeat_spec.rb +26 -8
  81. data/spec/higher_level_api/integration/message_properties_access_spec.rb +49 -49
  82. data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +2 -2
  83. data/spec/higher_level_api/integration/publisher_confirms_spec.rb +156 -42
  84. data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +19 -19
  85. data/spec/higher_level_api/integration/queue_bind_spec.rb +23 -23
  86. data/spec/higher_level_api/integration/queue_declare_spec.rb +129 -34
  87. data/spec/higher_level_api/integration/queue_delete_spec.rb +2 -2
  88. data/spec/higher_level_api/integration/queue_purge_spec.rb +5 -5
  89. data/spec/higher_level_api/integration/queue_unbind_spec.rb +6 -6
  90. data/spec/higher_level_api/integration/read_only_consumer_spec.rb +9 -9
  91. data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +10 -10
  92. data/spec/higher_level_api/integration/tls_connection_spec.rb +224 -89
  93. data/spec/higher_level_api/integration/toxiproxy_spec.rb +76 -0
  94. data/spec/higher_level_api/integration/tx_commit_spec.rb +1 -1
  95. data/spec/higher_level_api/integration/tx_rollback_spec.rb +1 -1
  96. data/spec/higher_level_api/integration/with_channel_spec.rb +2 -2
  97. data/spec/issues/issue100_spec.rb +11 -11
  98. data/spec/issues/issue141_spec.rb +13 -14
  99. data/spec/issues/issue202_spec.rb +1 -1
  100. data/spec/issues/issue224_spec.rb +40 -0
  101. data/spec/issues/issue465_spec.rb +32 -0
  102. data/spec/issues/issue549_spec.rb +30 -0
  103. data/spec/issues/issue78_spec.rb +21 -24
  104. data/spec/issues/issue83_spec.rb +5 -6
  105. data/spec/issues/issue97_spec.rb +44 -45
  106. data/spec/lower_level_api/integration/basic_cancel_spec.rb +15 -16
  107. data/spec/lower_level_api/integration/basic_consume_spec.rb +20 -21
  108. data/spec/spec_helper.rb +8 -26
  109. data/spec/stress/channel_close_stress_spec.rb +64 -0
  110. data/spec/stress/channel_open_stress_spec.rb +15 -9
  111. data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +7 -7
  112. data/spec/stress/concurrent_consumers_stress_spec.rb +18 -16
  113. data/spec/stress/concurrent_publishers_stress_spec.rb +16 -19
  114. data/spec/stress/connection_open_close_spec.rb +9 -9
  115. data/spec/stress/merry_go_round_spec.rb +105 -0
  116. data/spec/tls/client_key.pem +49 -25
  117. data/spec/tls/generate-server-cert.sh +8 -0
  118. data/spec/tls/server-openssl.cnf +10 -0
  119. data/spec/tls/server.csr +16 -0
  120. data/spec/tls/server_key.pem +49 -25
  121. data/spec/toxiproxy_helper.rb +28 -0
  122. data/spec/unit/bunny_spec.rb +5 -5
  123. data/spec/unit/concurrent/atomic_fixnum_spec.rb +6 -6
  124. data/spec/unit/concurrent/condition_spec.rb +8 -8
  125. data/spec/unit/concurrent/linked_continuation_queue_spec.rb +2 -2
  126. data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +16 -16
  127. data/spec/unit/exchange_recovery_spec.rb +39 -0
  128. data/spec/unit/version_delivery_tag_spec.rb +3 -3
  129. metadata +65 -47
  130. data/.ruby-version +0 -1
  131. data/lib/bunny/compatibility.rb +0 -24
  132. data/lib/bunny/system_timer.rb +0 -20
  133. data/spec/compatibility/queue_declare_spec.rb +0 -44
  134. data/spec/compatibility/queue_declare_with_default_channel_spec.rb +0 -33
  135. data/spec/higher_level_api/integration/basic_recover_spec.rb +0 -18
  136. data/spec/higher_level_api/integration/confirm_select_spec.rb +0 -19
  137. data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +0 -50
  138. data/spec/higher_level_api/integration/merry_go_round_spec.rb +0 -85
  139. data/spec/stress/long_running_consumer_spec.rb +0 -83
  140. data/spec/tls/cacert.pem +0 -18
  141. data/spec/tls/client_cert.pem +0 -18
  142. data/spec/tls/server_cert.pem +0 -18
  143. data/spec/unit/system_timer_spec.rb +0 -10
@@ -0,0 +1,76 @@
1
+ require "spec_helper"
2
+ require_relative "../../toxiproxy_helper"
3
+
4
+ if ::Toxiproxy.running?
5
+ describe Bunny::Channel, "#basic_publish" do
6
+ include RabbitMQ::Toxiproxy
7
+
8
+ after :each do
9
+ @connection.close if @connection.open?
10
+ end
11
+
12
+ context "when the the connection detects missed heartbeats with automatic recovery" do
13
+ before(:each) do
14
+ setup_toxiproxy
15
+ @connection = Bunny.new(user: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
16
+ host: "localhost:11111", heartbeat_timeout: 1, automatically_recover: true)
17
+ @connection.start
18
+ end
19
+
20
+ let(:queue_name) { "bunny.basic.publish.queue#{rand}" }
21
+
22
+ it "raises a ConnectionClosedError" do
23
+ ch = @connection.create_channel
24
+ begin
25
+ rabbitmq_toxiproxy.down do
26
+ sleep 2
27
+ expect { ch.default_exchange.publish("", :routing_key => queue_name) }.to raise_error(Bunny::ConnectionClosedError)
28
+ end
29
+ ensure
30
+ cleanup_toxiproxy
31
+ end
32
+ end
33
+ end
34
+
35
+ context "when the the connection detects missed heartbeats without automatic recovery" do
36
+ before(:each) do
37
+ setup_toxiproxy
38
+ @connection = Bunny.new(user: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
39
+ host: "localhost:11111", heartbeat_timeout: 1, automatically_recover: false, threaded: false)
40
+ @connection.start
41
+ end
42
+
43
+ it "does not raise an exception on session thread" do
44
+ rabbitmq_toxiproxy.down do
45
+ sleep 5
46
+ end
47
+ end
48
+ end
49
+
50
+ context "recovery attempt limit that's exceeded" do
51
+ before(:each) do
52
+ setup_toxiproxy
53
+ @connection = Bunny.new(user: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
54
+ host: "localhost:11111", heartbeat_timeout: 1, automatically_recover: true, network_recovery_interval: 1,
55
+ recovery_attempts: 2, reset_recovery_attempts_after_reconnection: true,
56
+ disconnect_timeout: 1)
57
+ @connection.start
58
+ end
59
+
60
+ it "permanently closes connection" do
61
+ expect(@connection.open?).to be(true)
62
+
63
+ rabbitmq_toxiproxy.down do
64
+ sleep 5
65
+ end
66
+ # give the connection one last chance to recover
67
+ sleep 3
68
+
69
+ expect(@connection.open?).to be(false)
70
+ expect(@connection.closed?).to be(true)
71
+ end
72
+ end # context
73
+ end # describe
74
+ else
75
+ puts "Toxiproxy isn't running, some examples will be skipped"
76
+ end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe Bunny::Channel, "#tx_commit" do
4
4
  let(:connection) do
5
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
5
+ c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
6
6
  c.start
7
7
  c
8
8
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe Bunny::Channel, "#tx_rollback" do
4
4
  let(:connection) do
5
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
5
+ c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
6
6
  c.start
7
7
  c
8
8
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe Bunny::Channel, "#with_channel" do
4
4
  let(:connection) do
5
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
5
+ c = Bunny.new(username: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed")
6
6
  c.start
7
7
  c
8
8
  end
@@ -20,6 +20,6 @@ describe Bunny::Channel, "#with_channel" do
20
20
  end
21
21
  rescue Exception
22
22
  end
23
- ch.should be_closed
23
+ expect(ch).to be_closed
24
24
  end
25
25
  end
@@ -2,17 +2,17 @@ require "spec_helper"
2
2
 
3
3
  unless ENV["CI"]
4
4
  describe Bunny::Channel, "#basic_publish" do
5
- let(:connection) do
6
- c = Bunny.new(:user => "bunny_gem",
7
- :password => "bunny_password",
8
- :vhost => "bunny_testbed",
9
- :socket_timeout => 0)
10
- c.start
11
- c
5
+ before :all do
6
+ @connection = Bunny.new(username: "bunny_gem",
7
+ password: "bunny_password",
8
+ vhost: "bunny_testbed",
9
+ write_timeout: 0,
10
+ read_timeout: 0)
11
+ @connection.start
12
12
  end
13
13
 
14
14
  after :all do
15
- connection.close if connection.open?
15
+ @connection.close if @connection.open?
16
16
  end
17
17
 
18
18
 
@@ -21,15 +21,15 @@ unless ENV["CI"]
21
21
  let(:m) { 10 }
22
22
 
23
23
  it "successfully publishers them all" do
24
- ch = connection.create_channel
24
+ ch = @connection.create_channel
25
25
 
26
- q = ch.queue("", :exclusive => true)
26
+ q = ch.queue("", exclusive: true)
27
27
  x = ch.default_exchange
28
28
 
29
29
  body = "x" * 1024
30
30
  m.times do |i|
31
31
  n.times do
32
- x.publish(body, :routing_key => q.name)
32
+ x.publish(body, routing_key: q.name)
33
33
  end
34
34
  puts "Published #{i * n} 1K messages..."
35
35
  end
@@ -1,43 +1,42 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "Registering 2nd exclusive consumer on queue" do
4
- let(:connection) do
5
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
6
- c.start
7
- c
4
+ before :all do
5
+ @connection = Bunny.new(:user => "bunny_gem", password: "bunny_password", :vhost => "bunny_testbed")
6
+ @connection.start
8
7
  end
9
8
 
10
9
  after :each do
11
- connection.close if connection.open?
10
+ @connection.close if @connection.open?
12
11
  end
13
12
 
14
13
 
15
14
  it "raises a meaningful exception" do
16
15
  xs = []
17
16
 
18
- ch1 = connection.create_channel
19
- ch2 = connection.create_channel
17
+ ch1 = @connection.create_channel
18
+ ch2 = @connection.create_channel
20
19
  q1 = ch1.queue("", :auto_delete => true)
21
20
  q2 = ch2.queue(q1.name, :auto_delete => true, :passive => true)
22
21
 
23
- c1 = q1.subscribe(:exclusive => true) do |_, _, payload|
22
+ c1 = q1.subscribe(exclusive: true) do |_, _, payload|
24
23
  xs << payload
25
24
  end
26
25
  sleep 0.1
27
26
 
28
- lambda do
29
- q2.subscribe(:exclusive => true) do |_, _, _|
27
+ expect do
28
+ q2.subscribe(exclusive: true) do |_, _, _|
30
29
  end
31
- end.should raise_error(Bunny::AccessRefused)
30
+ end.to raise_error(Bunny::AccessRefused)
32
31
 
33
- ch1.should be_open
34
- ch2.should be_closed
32
+ expect(ch1).to be_open
33
+ expect(ch2).to be_closed
35
34
 
36
35
  q1.publish("abc")
37
36
  sleep 0.1
38
37
 
39
38
  # verify that the first consumer is fine
40
- xs.should == ["abc"]
39
+ expect(xs).to eq ["abc"]
41
40
 
42
41
  q1.delete
43
42
  end
@@ -4,7 +4,7 @@ describe Bunny::Session do
4
4
  context "with unreachable host" do
5
5
  it "raises Bunny::TCPConnectionFailed" do
6
6
  begin
7
- conn = Bunny.new(:hostname => "192.192.192.192")
7
+ conn = Bunny.new(:hostname => "127.0.0.254", :port => 1433)
8
8
  conn.start
9
9
 
10
10
  fail "expected 192.192.192.192 to be unreachable"
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "spec_helper"
3
+
4
+ unless ENV["CI"]
5
+ describe "Message framing implementation" do
6
+ let(:connection) do
7
+ c = Bunny.new(:user => "bunny_gem",
8
+ password: "bunny_password",
9
+ :vhost => "bunny_testbed",
10
+ :port => ENV.fetch("RABBITMQ_PORT", 5672))
11
+ c.start
12
+ c
13
+ end
14
+
15
+ after :each do
16
+ connection.close if connection.open?
17
+ end
18
+
19
+
20
+ context "with payload 272179 bytes in size" do
21
+ it "successfully frames the message" do
22
+ ch = connection.create_channel
23
+
24
+ q = ch.queue("", exclusive: true)
25
+ x = ch.default_exchange
26
+
27
+ as = ("a" * 272179)
28
+ x.publish(as, routing_key: q.name, persistent: true)
29
+
30
+ sleep(1)
31
+ expect(q.message_count).to eq 1
32
+
33
+ _, _, payload = q.pop
34
+ expect(payload.bytesize).to eq as.bytesize
35
+
36
+ ch.close
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,32 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Bunny::Session do
5
+ let(:connection) do
6
+ c = Bunny.new(
7
+ user: 'bunny_gem', password: 'bunny_password',
8
+ vhost: 'bunny_testbed',
9
+ port: ENV.fetch('RABBITMQ_PORT', 5672)
10
+ )
11
+ c.start
12
+ c
13
+ end
14
+
15
+ context 'after the connection has been manually closed' do
16
+ before :each do
17
+ connection.close
18
+ end
19
+
20
+ after :each do
21
+ connection.close if connection.open?
22
+ end
23
+
24
+ describe '#create_channel' do
25
+ it 'should raise an exception' do
26
+ expect {
27
+ connection.create_channel
28
+ }.to raise_error(Bunny::ConnectionAlreadyClosed)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bunny::Session do
4
+ context 'when retry attempts have been exhausted' do
5
+ let(:io) { StringIO.new } # keep test output clear
6
+
7
+ def create_session
8
+ described_class.new(
9
+ host: 'fake.host',
10
+ recovery_attempts: 0,
11
+ connection_timeout: 0,
12
+ network_recovery_interval: 0,
13
+ logfile: io,
14
+ )
15
+ end
16
+
17
+ it 'closes the session' do
18
+ session = create_session
19
+ session.handle_network_failure(StandardError.new)
20
+ expect(session.closed?).to be true
21
+ end
22
+
23
+ it 'stops the reader loop' do
24
+ session = create_session
25
+ reader_loop = session.reader_loop
26
+ session.handle_network_failure(StandardError.new)
27
+ expect(reader_loop.stopping?).to be true
28
+ end
29
+ end
30
+ end
@@ -2,20 +2,17 @@ require "spec_helper"
2
2
 
3
3
  unless ENV["CI"]
4
4
  describe Bunny::Queue, "#subscribe" do
5
- let(:connection1) do
6
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
7
- c.start
8
- c
9
- end
10
- let(:connection2) do
11
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
12
- c.start
13
- c
5
+ before :all do
6
+ @connection1 = Bunny.new(:user => "bunny_gem", password: "bunny_password", :vhost => "bunny_testbed")
7
+ @connection1.start
8
+ @connection2 = Bunny.new(:user => "bunny_gem", password: "bunny_password", :vhost => "bunny_testbed")
9
+ @connection2.start
14
10
  end
15
11
 
16
12
  after :all do
17
- connection1.close if connection1.open?
18
- connection2.close if connection2.open?
13
+ [@connection1, @connection2].select { |c| !!c }.each do |c|
14
+ c.close if c.open?
15
+ end
19
16
  end
20
17
 
21
18
 
@@ -23,20 +20,20 @@ unless ENV["CI"]
23
20
  it "consumes messages" do
24
21
  delivered_data = []
25
22
 
26
- ch1 = connection1.create_channel
27
- ch2 = connection1.create_channel
23
+ ch1 = @connection1.create_channel
24
+ ch2 = @connection1.create_channel
28
25
 
29
- q = ch1.queue("", :exclusive => true)
30
- q.subscribe(:ack => false, :block => false) do |delivery_info, properties, payload|
26
+ q = ch1.queue("", exclusive: true)
27
+ q.subscribe(manual_ack: false) do |delivery_info, properties, payload|
31
28
  delivered_data << payload
32
29
  end
33
30
  sleep 0.5
34
31
 
35
32
  x = ch2.default_exchange
36
- x.publish("abc", :routing_key => q.name)
33
+ x.publish("abc", routing_key: q.name)
37
34
  sleep 0.7
38
35
 
39
- delivered_data.should == ["abc"]
36
+ expect(delivered_data).to eq ["abc"]
40
37
 
41
38
  ch1.close
42
39
  ch2.close
@@ -49,23 +46,23 @@ unless ENV["CI"]
49
46
  it "consumes messages" do
50
47
  delivered_data = []
51
48
 
52
- ch1 = connection1.create_channel
53
- ch2 = connection1.create_channel
49
+ ch1 = @connection1.create_channel
50
+ ch2 = @connection1.create_channel
54
51
 
55
- q = ch1.queue(queue_name, :exclusive => true)
52
+ q = ch1.queue(queue_name, exclusive: true)
56
53
  x = ch2.default_exchange
57
54
  3.times do |i|
58
- x.publish("data#{i}", :routing_key => queue_name)
55
+ x.publish("data#{i}", routing_key: queue_name)
59
56
  end
60
57
  sleep 0.7
61
- q.message_count.should == 3
58
+ expect(q.message_count).to eq 3
62
59
 
63
- q.subscribe(:ack => false, :block => false) do |delivery_info, properties, payload|
60
+ q.subscribe(manual_ack: false) do |delivery_info, properties, payload|
64
61
  delivered_data << payload
65
62
  end
66
63
  sleep 0.7
67
64
 
68
- delivered_data.should == ["data0", "data1", "data2"]
65
+ expect(delivered_data).to eq ["data0", "data1", "data2"]
69
66
 
70
67
  ch1.close
71
68
  ch2.close
@@ -1,19 +1,18 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Bunny::Channel, "#open" do
4
- let(:connection) do
5
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
6
- c.start
7
- c
4
+ before :all do
5
+ @connection = Bunny.new(:user => "bunny_gem", password: "bunny_password", :vhost => "bunny_testbed")
6
+ @connection.start
8
7
  end
9
8
 
10
9
  after :all do
11
- connection.close if connection.open?
10
+ @connection.close if @connection.open?
12
11
  end
13
12
 
14
13
 
15
14
  it "properly resets channel exception state" do
16
- ch = connection.create_channel
15
+ ch = @connection.create_channel
17
16
 
18
17
  begin
19
18
  ch.queue("bunny.tests.does.not.exist", :passive => true)