Sha256: 741f39f5c7ba33d101539f89aac52ab9587464cf5a053047bbf9656586fd5406

Contents?: true

Size: 1.86 KB

Versions: 13

Compression:

Stored size: 1.86 KB

Contents

require "spec_helper"

describe Bunny::Exchange, "#delete" do
  let(:connection) do
    c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
    c.start
    c
  end

  after :each do
    connection.close if connection.open?
  end


  context "with a name of an existing exchange" do
    it "deletes that exchange" do
      ch = connection.create_channel
      x  = ch.fanout("bunny.tests.exchanges.fanout#{rand}")

      x.delete
      expect {
        x.delete
      }.to raise_error(Bunny::NotFound)
      
      ch.exchanges.size.should == 0
    end
  end


  context "with a name of a non-existent exchange" do
    it "raises an exception" do
      ch = connection.create_channel

      expect {
        ch.exchange_delete("sdkhflsdjflskdjflsd#{rand}")
      }.to raise_error(Bunny::NotFound)
    end
  end
  
  context "with a name of 'amq.direct'" do
    it "does not delete the exchange" do
      ch = connection.create_channel
      x  = ch.direct('amq.direct')
      
      x.delete.should == nil
    end
  end
  
  context "with a name of 'amq.fanout'" do
    it "does not delete the exchange" do
      ch = connection.create_channel
      x  = ch.fanout('amq.fanout')
      
      x.delete.should == nil
    end
  end
  
  context "with a name of 'amq.topic'" do
    it "does not delete the exchange" do
      ch = connection.create_channel
      x  = ch.topic('amq.topic')
      
      x.delete.should == nil
    end
  end
  
  context "with a name of 'amq.headers'" do
    it "does not delete the exchange" do
      ch = connection.create_channel
      x  = ch.headers('amq.headers')
      
      x.delete.should == nil
    end
  end
  
  context "with a name of 'amq.match'" do
    it "does not delete the exchange" do
      ch = connection.create_channel
      x  = ch.headers('amq.match')
      
      x.delete.should == nil
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
bunny-1.0.0.rc2 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-0.10.8 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-1.0.0.rc1 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-0.10.7 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-0.10.6 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-1.0.0.pre6 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-0.10.5 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-1.0.0.pre5 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-0.10.4 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-0.10.3 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-1.0.0.pre4 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-0.10.2 spec/higher_level_api/integration/exchange_delete_spec.rb
bunny-0.10.1 spec/higher_level_api/integration/exchange_delete_spec.rb