Skip to content

Commit

Permalink
Basic coverage for basic.cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Klishin committed Nov 24, 2012
1 parent 40e08b7 commit b0566e2
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions spec/lower_level_api/integration/basic_cancel_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

describe Bunny::Channel, "#basic_consume" do
describe Bunny::Channel, "#basic_cancel" do
let(:connection) do
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
c.start
Expand All @@ -25,7 +25,30 @@
end

context "when the given consumer tag is valid" do
it "cancels the consumer"
let(:queue_name) { "bunny.basic.cancel.queue#{rand}" }

it "cancels the consumer" do
delivered_data = []

t = Thread.new do
ch = connection.create_channel
q = ch.queue(queue_name, :auto_delete => true, :durable => false)
consume_ok = ch.basic_consume(q, "", true, false) do |metadata, payload|
delivered_data << payload
end

consume_ok.consumer_tag.should_not be_nil
cancel_ok = ch.basic_cancel(consume_ok.consumer_tag)
cancel_ok.consumer_tag.should == consume_ok.consumer_tag

ch.close
end
t.abort_on_exception = true
sleep 0.5

sleep 0.7
delivered_data.should be_empty
end
end

context "when the given consumer tag is invalid (was never registered)" do
Expand Down

0 comments on commit b0566e2

Please sign in to comment.