Sha256: 902c68779e6011de95b17c327e748beb33874860d12107015bc20c5911195342
Contents?: true
Size: 1.85 KB
Versions: 3
Compression:
Stored size: 1.85 KB
Contents
require 'spec_helper' require 'openssl' require 'hushed' require 'hushed/message' module Hushed describe "QueueRemote" do include Configuration before do AWS.config(:stub_requests => false) @client = Client.new(load_configuration) @sqs_queues = [@client.to_quiet_queue, @client.from_quiet_queue] @default_wait_time = @sqs_queues.map(&:wait_time_seconds).max @sqs_queues.each { |queue| queue.wait_time_seconds = 1 } @document = DocumentDouble.new( :message_id => '1234567', :date => Time.new(2013, 04, 05, 12, 30, 15).utc, :filename => 'neat_beans.xml', :client => @client, :type => 'Thinger' ) @message = Message.new(:client => @client, :document => @document) @queue = Queue.new(@client) end after do @sqs_queues.each do |queue| flush(queue) end @sqs_queues.each { |queue| queue.wait_time_seconds = @default_wait_time } end it "should be able to push a message onto the queue" do expected_md5 = OpenSSL::Digest::MD5.new.hexdigest(@message.to_xml) sent_message = @queue.send(@message) assert_equal 1, @client.to_quiet_queue.approximate_number_of_messages assert_equal expected_md5, sent_message.md5 end it "should be able to fetch a message from the queue" do @client.from_quiet_queue.send_message(@message.to_xml) message = @queue.receive assert_equal @message.to_xml, message.xml.to_xml assert_equal @message.document_type, message.document_type assert_equal @message.document_name, message.document_name end private def flush(queue) pending_messages = queue.approximate_number_of_messages while pending_messages > 0 queue.receive_message do |message| message.delete pending_messages -= 1 end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hushed-0.0.3 | spec/remote/queue_spec.rb |
hushed-0.0.2 | spec/remote/queue_spec.rb |
hushed-0.0.1 | spec/remote/queue_spec.rb |