<commit_before>require "spec_helper"

describe Bunny::Queue, "bound to an exchange" do
  let(:connection) do
    c = Bunny.new(:user => "bunny_gem", :password => "<PASSWORD>", :vhost => "bunny_testbed")
    c.start
    c
  end

  after :each do
    connection.close
  end


  it "can be unbound from an exchange it was bound to" do
    ch = connection.create_channel
    x  = ch.fanout("amq.fanout")
    q  = ch.queue("", :exclusive => true).bind(x)

    x.publish("")
    sleep 0.3
    q.message_count.should == 1

    q.unbind(x)

    x.publish("")
    q.message_count.should == 1
  end
end



describe Bunny::Queue, "NOT bound to an exchange" do
  let(:connection) do
    c = Bunny.new(:user => "bunny_gem", :password => "<PASSWORD>", :vhost => "bunny_testbed")
    c.start
    c
  end

  after :each do
    connection.close
  end


  it "cannot be unbound (raises a channel error)" do
    ch = connection.create_channel
    x  = ch.fanout("amq.fanout")
    q  = ch.queue("", :exclusive => true)

    lambda {
      q.unbind(x)
    }.should raise_error(Bunny::NotFound, /no binding/)
  end
end<commit_msg>Ditto for queue.unbind<commit_after>require "spec_helper"

describe Bunny::Queue, "bound to an exchange" do
  let(:connection) do
    c = Bunny.new(:user => "bunny_gem", :password => "<PASSWORD>", :vhost => "bunny_testbed")
    c.start
    c
  end

  after :each do
    connection.close
  end


  it "can be unbound from an exchange it was bound to" do
    ch = connection.create_channel
    x  = ch.fanout("amq.fanout")
    q  = ch.queue("", :exclusive => true).bind(x)

    x.publish("")
    sleep 0.3
    q.message_count.should == 1

    q.unbind(x)

    x.publish("")
    q.message_count.should == 1
  end
end



describe Bunny::Queue, "NOT bound to an exchange" do
  let(:connection) do
    c = Bunny.new(:user => "bunny_gem", :password => "<PASSWORD>", :vhost => "bunny_testbed")
    c.start
    c
  end

  after :each do
    connection.close
  end


  it "cannot be unbound (raises a channel error)" do
    ch = connection.create_channel
    x  = ch.fanout("amq.fanout")
    q  = ch.queue("", :exclusive => true)

    # No exception as of RabbitMQ 3.2. MK.
    q.unbind(x)
    q.unbind(x)
  end
end
{'fraction_non_alphanumeric': 0.13917758698599186, 'fraction_numerical': 0.004518752824220515, 'mean_word_length': 2.804123711340206, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5559404', 'n_tokens_mistral': 838, 'n_tokens_neox': 787, 'n_words': 220}