Sha256: 1956204d125d42b7d64fc66eeeb00ccd6b67f3da38ebd9d1bf490cc835ec3726
Contents?: true
Size: 1.57 KB
Versions: 6
Compression:
Stored size: 1.57 KB
Contents
require 'spec_helper' require 'hushed/queue' module Hushed describe "Queue" do include Fixtures before do @sqs_queue = mock() @client = mock() @client.stubs(:to_quiet_queue).returns(@sqs_queue) @client.stubs(:from_quiet_queue).returns(@sqs_queue) @client.stubs(:quiet_inventory_queue).returns(@sqs_queue) @message = mock() @queue = Queue.new(@client) end it "should be able to write a message to a queue" do @message.stubs(:to_xml).returns('hello world') @sqs_queue.expects(:send_message).with('hello world') @queue.send(@message) end it "should return a message which holds a reference to the message_object when receiving from a queue" do @message.stubs(:body).returns(load_message('purchase_order_message')) @sqs_queue.expects(:receive_message).yields(@message) received_message = @queue.receive assert_equal 'PurchaseOrder', received_message.document_type assert_equal 'HUSHED_PurchaseOrder_1234_20100927_132505124.xml', received_message.document_name assert_equal @message, received_message.message_object end it "should return a message when receiving even if the queue did not return anything" do @sqs_queue.expects(:receive_message) received_message = @queue.receive assert_equal false, received_message.nil? end it "should be possible to get an approximate number of pending messages" do @sqs_queue.expects(:approximate_number_of_messages).returns(10) assert_equal 10, @queue.approximate_pending_messages end end end
Version data entries
6 entries across 6 versions & 1 rubygems