Sha256: 601e1167ed8155742a5aa802f18d3129f703665232310d52bcd9a107a28c6cf7
Contents?: true
Size: 1.51 KB
Versions: 13
Compression:
Stored size: 1.51 KB
Contents
require 'spec_helper' describe "Firehose amqp resources" do let(:channel) { "/resource-test-#{Time.now.to_i}" } it "should clean up exchanges and queues" do sent, received = 'howdy!', nil before_exchange_count = `rabbitmqctl list_exchanges`.lines.count before_queue_count = `rabbitmqctl list_queues`.lines.count during_exchange_count = nil during_queue_count = nil EM.run do # Kill test if it runs longer than 5s EM.add_timer(5) { EM.stop } subscription = Firehose::Subscription.new subscription.ttl = 1 subscription.subscribe channel do |payload| received = payload subscription.unsubscribe during_exchange_count = `rabbitmqctl list_exchanges`.lines.count during_queue_count = `rabbitmqctl list_queues`.lines.count # I wait 1 second before killing em so that unsubscribe # can talk to AMQP before the whole thing dies. EM.add_timer(1){ EM.stop } end # Let the subscriber subscribe before publishing messages. EM.add_timer(1){ Firehose::Publisher.new.publish(channel, sent) } end after_exchange_count = `rabbitmqctl list_exchanges`.lines.count after_queue_count = `rabbitmqctl list_queues`.lines.count received.should == sent after_exchange_count.should == before_exchange_count after_queue_count.should == before_queue_count during_exchange_count.should == before_exchange_count + 1 during_queue_count.should == before_queue_count + 1 end end
Version data entries
13 entries across 13 versions & 1 rubygems