spec/integration/exchange_declaration_spec.rb in amqp-0.7.1 vs spec/integration/exchange_declaration_spec.rb in amqp-0.7.2

- old
+ new

@@ -6,11 +6,11 @@ # # Environment # - include AMQP::Spec + include EventedSpec::AMQPSpec default_timeout 10 amqp_before do @channel = AMQP::Channel.new @@ -24,26 +24,31 @@ describe "#direct" do context "when exchange name is specified" do it 'declares a new direct exchange with that name' do @channel.direct('name').name.should == 'name' + @channel.direct('name').delete + done end it "declares direct exchange as transient (non-durable)" do exchange = @channel.direct('name') exchange.should_not be_durable exchange.should be_transient + exchange.delete + done end it "declares direct exchange as non-auto-deleted" do exchange = @channel.direct('name') exchange.should_not be_auto_deleted + exchange.delete done end end @@ -57,13 +62,13 @@ context "when exchange name was specified as a blank string" do it 'returns direct exchange with server-generated name' do pending <<-EOF - This has to be fixed in RabbitMQ first - https://bugzilla.rabbitmq.com/show_bug.cgi?id=23509 - EOF + This has to be fixed in RabbitMQ first + https://bugzilla.rabbitmq.com/show_bug.cgi?id=23509 + EOF @channel.direct("") do |exchange| exchange.name.should_not be_empty done end end @@ -78,10 +83,13 @@ original_exchange = @channel.direct(name) exchange = @channel.direct(name, :passive => true) exchange.should == original_exchange + original_exchange.delete + exchange.delete + done end # it end context "and exchange with given name DOES NOT exist" do @@ -102,10 +110,12 @@ it "returns a new durable direct exchange" do exchange = @channel.direct("a_new_durable_direct_exchange", :durable => true) exchange.should be_durable exchange.should_not be_transient + exchange.delete + done end # it end # context @@ -113,53 +123,60 @@ it "returns a new NON-durable direct exchange" do exchange = @channel.direct("a_new_non_durable_direct_exchange", :durable => false) exchange.should_not be_durable exchange.should be_transient + exchange.delete + done end # it end # context context "when exchange is declared as auto-deleted" do it "returns a new auto-deleted direct exchange" do exchange = @channel.direct("a new auto-deleted direct exchange", :auto_delete => true) exchange.should be_auto_deleted + exchange.delete done end # it end # context context "when exchange is declared as auto-deleted" do it "returns a new auto-deleted direct exchange" do exchange = @channel.direct("a new non-auto-deleted direct exchange", :auto_delete => false) exchange.should_not be_auto_deleted + exchange.delete done end # it end # context context "when exchange is declared without explicit :nowait parameter" do it "is declared with :nowait by default" do exchange = @channel.direct("a new non-auto-deleted direct exchange", :auto_delete => false) exchange.should_not be_auto_deleted + exchange.delete done end # it end # context context "when exchange is re-declared with parameters different from original declaration" do it "raises an exception" do - @channel.direct("previously.declared.durable.direct.exchange", :durable => true) + exchange = @channel.direct("previously.declared.durable.direct.exchange", :durable => true) expect { @channel.direct("previously.declared.durable.direct.exchange", :durable => false) }.to raise_error(AMQP::IncompatibleOptionsError) + exchange.delete + done end # it end # context end # describe @@ -172,10 +189,11 @@ it "declares a new fanout exchange with that name" do exchange = @channel.fanout(name) exchange.name.should == name + exchange.delete done end end # context @@ -197,10 +215,13 @@ original_exchange = @channel.fanout(name) exchange = @channel.fanout(name, :passive => true) exchange.should == original_exchange + original_exchange.delete + exchange.delete + done end # it end context "and exchange with given name DOES NOT exist" do @@ -291,10 +312,12 @@ it "declares a new topic exchange with that name" do exchange = @channel.topic(name) exchange.name.should == name + exchange.delete + done end end # context context "when exchange name is omitted" do @@ -314,10 +337,12 @@ original_exchange = @channel.topic(name) exchange = @channel.topic(name, :passive => true) exchange.should == original_exchange + original_exchange.delete + exchange.delete done end # it end @@ -339,10 +364,12 @@ it "returns a new durable topic exchange" do exchange = @channel.topic("a_new_durable_topic_exchange", :durable => true) exchange.should be_durable exchange.should_not be_transient + exchange.delete + done end # it end # context @@ -350,10 +377,12 @@ it "returns a new NON-durable topic exchange" do exchange = @channel.topic("a_new_non_durable_topic_exchange", :durable => false) exchange.should_not be_durable exchange.should be_transient + exchange.delete + done end # it end # context @@ -370,20 +399,22 @@ context "when exchange is declared as auto-deleted" do it "returns a new auto-deleted topic exchange" do exchange = @channel.topic("a new non-auto-deleted topic exchange", :auto_delete => false) exchange.should_not be_auto_deleted + exchange.delete done end # it end # context context "when exchange is declared without explicit :nowait parameter" do it "is declared with :nowait by default" do exchange = @channel.topic("a new non-auto-deleted topic exchange", :auto_delete => false) exchange.should_not be_auto_deleted + exchange.delete done end # it end # context @@ -393,17 +424,19 @@ end it "raises an exception" do channel = AMQP::Channel.new - channel.topic("previously.declared.durable.topic.exchange", :durable => true) + exchange = channel.topic("previously.declared.durable.topic.exchange", :durable => true) channel.should be_open expect { channel.topic("previously.declared.durable.topic.exchange", :durable => false) }.to raise_error(AMQP::IncompatibleOptionsError) + exchange.delete + done end # it end # context end # describe @@ -416,10 +449,11 @@ it "declares a new headers exchange with that name" do exchange = @channel.headers(name) exchange.name.should == name + exchange.delete done end end # context @@ -444,10 +478,12 @@ original_exchange = @channel.headers(name) exchange = @channel.headers(name, :passive => true) exchange.should == original_exchange + original_exchange.delete + exchange.delete done end # it end @@ -469,10 +505,12 @@ it "returns a new durable headers exchange" do exchange = @channel.headers("a_new_durable_headers_exchange", :durable => true) exchange.should be_durable exchange.should_not be_transient + exchange.delete + done end # it end # context @@ -480,40 +518,47 @@ it "returns a new NON-durable headers exchange" do exchange = @channel.headers("a_new_non_durable_headers_exchange", :durable => false) exchange.should_not be_durable exchange.should be_transient + exchange.delete + done end # it end # context context "when exchange is declared as auto-deleted" do it "returns a new auto-deleted headers exchange" do exchange = @channel.headers("a new auto-deleted headers exchange", :auto_delete => true) exchange.should be_auto_deleted + done end # it end # context context "when exchange is declared as auto-deleted" do it "returns a new auto-deleted headers exchange" do exchange = @channel.headers("a new non-auto-deleted headers exchange", :auto_delete => false) exchange.should_not be_auto_deleted + exchange.delete + done end # it end # context context "when exchange is declared without explicit :nowait parameter" do it "is declared with :nowait by default" do exchange = @channel.headers("a new non-auto-deleted headers exchange", :auto_delete => false) exchange.should_not be_auto_deleted + exchange.delete + done end # it end # context @@ -521,14 +566,16 @@ amqp_after do done end it "raises an exception" do - @channel.headers("previously.declared.durable.topic.exchange", :durable => true) + exchange = @channel.headers("previously.declared.durable.topic.exchange", :durable => true) expect { @channel.headers("previously.declared.durable.topic.exchange", :durable => false) }.to raise_error(AMQP::IncompatibleOptionsError) + + exchange.delete done end # it end # context end # describe