lib/pwwka/test_handler.rb in pwwka-0.2.0 vs lib/pwwka/test_handler.rb in pwwka-0.3.0

- old
+ new

@@ -8,17 +8,13 @@ # 2. Arrange for `test_teardown` to be called during teardown of your tests # 3. Use the method `pop_message` to examine the message on the queue class TestHandler attr_reader :channel_connector - attr_reader :channel - attr_reader :topic_exchange def initialize @channel_connector = ChannelConnector.new - @channel = channel_connector.channel - @topic_exchange = channel_connector.topic_exchange end # call this method to create the queue used for testing # queue needs to be declared before the exchange is published to def test_setup @@ -26,12 +22,12 @@ true end def test_queue @test_queue ||= begin - test_queue = channel.queue("test-queue", durable: true) - test_queue.bind(topic_exchange, routing_key: "#.#") + test_queue = channel_connector.channel.queue("test-queue", durable: true) + test_queue.bind(channel_connector.topic_exchange, routing_key: "#.#") test_queue end end # Get the message on the queue as TestHandler::Message. @@ -60,14 +56,19 @@ pop_message.delivery_info end def purge_test_queue test_queue.purge + channel_connector.delayed_queue.purge if channel_connector.configuration.allow_delayed? end def test_teardown test_queue.delete - topic_exchange.delete + channel_connector.topic_exchange.delete + # delayed messages + channel_connector.delayed_queue.delete + channel_connector.delayed_exchange.delete + channel_connector.connection_close end # Simple class to hold a popped message. #