hushed 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +64 -0
- data/Rakefile +9 -0
- data/hushed.gemspec +29 -0
- data/lib/hushed.rb +6 -0
- data/lib/hushed/blackboard.rb +44 -0
- data/lib/hushed/client.rb +92 -0
- data/lib/hushed/documents/document.rb +15 -0
- data/lib/hushed/documents/request/shipment_order.rb +89 -0
- data/lib/hushed/documents/response/shipment_order_result.rb +56 -0
- data/lib/hushed/message.rb +43 -0
- data/lib/hushed/queue.rb +26 -0
- data/lib/hushed/request.rb +11 -0
- data/lib/hushed/response.rb +11 -0
- data/lib/hushed/version.rb +3 -0
- data/spec/fixtures/credentials.yml +12 -0
- data/spec/fixtures/documents/responses/shipment_order_result.xml +23 -0
- data/spec/fixtures/messages/purchase_order_message.xml +11 -0
- data/spec/remote/blackboard_spec.rb +43 -0
- data/spec/remote/queue_spec.rb +63 -0
- data/spec/spec_helper.rb +169 -0
- data/spec/unit/blackboard_spec.rb +102 -0
- data/spec/unit/client_spec.rb +97 -0
- data/spec/unit/documents/document_spec.rb +44 -0
- data/spec/unit/documents/request/shipment_order_spec.rb +90 -0
- data/spec/unit/documents/response/shipment_order_result_spec.rb +26 -0
- data/spec/unit/message_spec.rb +71 -0
- data/spec/unit/queue_spec.rb +48 -0
- metadata +207 -0
| @@ -0,0 +1,97 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'hushed/client'
         | 
| 3 | 
            +
            require 'active_support/core_ext/hash/except'
         | 
| 4 | 
            +
            require 'active_support/core_ext/hash/keys'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module Hushed
         | 
| 7 | 
            +
              describe "Client" do
         | 
| 8 | 
            +
                before do
         | 
| 9 | 
            +
                  AWS.config(:stub_requests => true)
         | 
| 10 | 
            +
                  @options = {
         | 
| 11 | 
            +
                    access_key_id: 'abracadabra',
         | 
| 12 | 
            +
                    secret_access_key: 'alakazam',
         | 
| 13 | 
            +
                    client_id: 'HUSHED',
         | 
| 14 | 
            +
                    business_unit: 'HUSHED',
         | 
| 15 | 
            +
                    warehouse: 'SPACE',
         | 
| 16 | 
            +
                    buckets: {
         | 
| 17 | 
            +
                      to: 'hushed-to-quiet',
         | 
| 18 | 
            +
                      from: 'hushed-from-quiet'
         | 
| 19 | 
            +
                    },
         | 
| 20 | 
            +
                    queues: {
         | 
| 21 | 
            +
                      to: 'http://queue.amazonaws.com/123456789/hushed_to_quiet',
         | 
| 22 | 
            +
                      from: 'http://queue.amazonaws.com/123456789/hushed_from_quiet',
         | 
| 23 | 
            +
                      inventory: 'http://queue.amazonaws.com/123456789/hushed_inventory'
         | 
| 24 | 
            +
                    }
         | 
| 25 | 
            +
                  }
         | 
| 26 | 
            +
                  @client = Client.new(@options)
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                after do
         | 
| 30 | 
            +
                  AWS.config(:stub_requests => false)
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                it "should be able to handle configuration that is passed in with keys as strings" do
         | 
| 34 | 
            +
                  client = Client.new(@options.stringify_keys)
         | 
| 35 | 
            +
                  assert_equal 'HUSHED', client.client_id
         | 
| 36 | 
            +
                  assert_equal 'HUSHED', client.business_unit
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                it "should not be possible to initialize a client without credentials" do
         | 
| 40 | 
            +
                  assert_raises Client::InitializationError do
         | 
| 41 | 
            +
                    Client.new(@options.except(:access_key_id, :secret_access_key))
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                it "should not be possible to initialize a client without a client_id" do
         | 
| 46 | 
            +
                  assert_raises Client::InitializationError do
         | 
| 47 | 
            +
                    Client.new(@options.except(:client_id))
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                it "should not be possible to initialize a client with a business_unit" do
         | 
| 52 | 
            +
                  assert_raises Client::InitializationError do
         | 
| 53 | 
            +
                    Client.new(@options.except(:business_unit))
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                it "should not be possible to initialize a client with missing bucket information" do
         | 
| 58 | 
            +
                  assert_raises Client::InitializationError do
         | 
| 59 | 
            +
                    Client.new(@options.except(:buckets))
         | 
| 60 | 
            +
                  end
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                it "should not be possible to initialize a client with partial bucket information" do
         | 
| 64 | 
            +
                  assert_raises Client::InitializationError do
         | 
| 65 | 
            +
                    buckets = {to: 'neato'}
         | 
| 66 | 
            +
                    Client.new(@options.merge(buckets: buckets))
         | 
| 67 | 
            +
                  end
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                it "should not be possible to initialize a client with missing queue information" do
         | 
| 71 | 
            +
                  assert_raises Client::InitializationError do
         | 
| 72 | 
            +
                    Client.new(@options.except(:queues))
         | 
| 73 | 
            +
                  end
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                it "should not be possible to initialize a client with partial queue information" do
         | 
| 77 | 
            +
                  assert_raises Client::InitializationError do
         | 
| 78 | 
            +
                    queues = {inventory: 'neato'}
         | 
| 79 | 
            +
                    Client.new(@options.merge(queues: queues))
         | 
| 80 | 
            +
                  end
         | 
| 81 | 
            +
                end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                it "should raise an error if the bucket names are invalid" do
         | 
| 84 | 
            +
                  AWS::S3::Bucket.any_instance.expects(:exists?).returns(false)
         | 
| 85 | 
            +
                  assert_raises Client::InvalidBucketError do
         | 
| 86 | 
            +
                    @client.to_quiet_bucket
         | 
| 87 | 
            +
                  end
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                it "should raise an error if the queue names are invalid" do
         | 
| 91 | 
            +
                  AWS::SQS::Queue.any_instance.expects(:exists?).returns(false)
         | 
| 92 | 
            +
                  assert_raises Client::InvalidQueueError do
         | 
| 93 | 
            +
                    @client.to_quiet_queue
         | 
| 94 | 
            +
                  end
         | 
| 95 | 
            +
                end
         | 
| 96 | 
            +
              end
         | 
| 97 | 
            +
            end
         | 
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            module Hushed
         | 
| 2 | 
            +
              module Documents
         | 
| 3 | 
            +
                module DocumentInterfaceTestcases
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  def test_it_should_be_able_to_generate_a_filename
         | 
| 6 | 
            +
                    assert bn = @object.business_unit
         | 
| 7 | 
            +
                    assert type = @object.type
         | 
| 8 | 
            +
                    assert number = @object.document_number
         | 
| 9 | 
            +
                    assert date = @object.date.strftime("%Y%m%d_%H%M%S")
         | 
| 10 | 
            +
                    expected_filename = "#{bn}_#{type}_#{number}_#{date}.xml"
         | 
| 11 | 
            +
                    assert_equal expected_filename, @object.filename
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def test_it_should_respond_to_warehouse
         | 
| 15 | 
            +
                    assert @object.respond_to?(:warehouse), "#{@object.class} does not respond to #warehouse"
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  def test_it_should_be_initializable_with_a_hash
         | 
| 19 | 
            +
                    begin
         | 
| 20 | 
            +
                      @object.class.new(:thinger => 123)
         | 
| 21 | 
            +
                    rescue TypeError
         | 
| 22 | 
            +
                      flunk "It should be possible to initialize #{@object.class} with an args hash"
         | 
| 23 | 
            +
                    rescue StandardError
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              describe "DocumentDouble" do
         | 
| 31 | 
            +
                include Documents::DocumentInterfaceTestcases
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                before do
         | 
| 34 | 
            +
                  @object = DocumentDouble.new(
         | 
| 35 | 
            +
                    :message_id => '1234567',
         | 
| 36 | 
            +
                    :date => Time.new(2013, 04, 05, 12, 30, 15).utc,
         | 
| 37 | 
            +
                    :client => @client,
         | 
| 38 | 
            +
                    :type => 'Thinger',
         | 
| 39 | 
            +
                    :business_unit => 'HUSHED',
         | 
| 40 | 
            +
                    :document_number => '123456'
         | 
| 41 | 
            +
                  )
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
            end
         | 
| @@ -0,0 +1,90 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'hushed/documents/request/shipment_order'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Hushed
         | 
| 5 | 
            +
              module Documents
         | 
| 6 | 
            +
                module Request
         | 
| 7 | 
            +
                  describe "ShipmentOrder" do
         | 
| 8 | 
            +
                    include Hushed::Documents::DocumentInterfaceTestcases
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                    before do
         | 
| 11 | 
            +
                      @order = OrderDouble.example
         | 
| 12 | 
            +
                      @client = ClientDouble.new(:client_id => 'HUSHED', :business_unit => 'HUSHED', :warehouse => 'SPACE')
         | 
| 13 | 
            +
                      @object = @shipment_order = ShipmentOrder.new(:order => @order, :client => @client)
         | 
| 14 | 
            +
                    end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                    it "should be possible to initialize a ShipmentOrder" do
         | 
| 17 | 
            +
                      shipment_order = ShipmentOrder.new(:order => @order, :client => @client)
         | 
| 18 | 
            +
                      assert_equal @order, shipment_order.order
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                    it "should raise an error if an order wasn't passed in" do
         | 
| 22 | 
            +
                      assert_raises ShipmentOrder::MissingOrderError do
         | 
| 23 | 
            +
                        ShipmentOrder.new
         | 
| 24 | 
            +
                      end
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    it "should be able to generate an XML document" do
         | 
| 28 | 
            +
                      message = ShipmentOrder.new(:order => @order, :client => @client)
         | 
| 29 | 
            +
                      document = Nokogiri::XML::Document.parse(message.to_xml)
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                      expected_namespaces = {'xmlns' => ShipmentOrder::NAMESPACE}
         | 
| 32 | 
            +
                      assert_equal expected_namespaces, document.collect_namespaces()
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                      assert_equal 1, document.css('ShipOrderDocument').length
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                      assert_equal @client.client_id, document.css('ClientID').first.text
         | 
| 37 | 
            +
                      assert_equal @client.business_unit, document.css('BusinessUnit').first.text
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                      assert_header(document.css('OrderHeader').first)
         | 
| 40 | 
            +
                      assert_equal @order.note, document.css('Comments').first.text
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                      assert_shipping(document.css('ShipMode').first)
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                      assert_address(@order.email, @order.shipping_address, document.css('ShipTo').first)
         | 
| 45 | 
            +
                      assert_address(@order.email, @order.billing_address, document.css('BillTo').first)
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                      assert_equal @order.total_price.to_s, document.css('DeclaredValue').first.text
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                      order_details = document.css('OrderDetails')
         | 
| 50 | 
            +
                      assert_equal 1, order_details.length
         | 
| 51 | 
            +
                      assert_line_item(@order.line_items.first, order_details.first)
         | 
| 52 | 
            +
                    end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                    private
         | 
| 55 | 
            +
                    def assert_header(header)
         | 
| 56 | 
            +
                      assert_equal "#{@order.id}", header['OrderNumber']
         | 
| 57 | 
            +
                      assert_equal @order.created_at.utc.to_s, header['OrderDate']
         | 
| 58 | 
            +
                      assert_equal @order.created_at.utc.to_s, header['ShipDate']
         | 
| 59 | 
            +
                      assert_equal @order.type, header['OrderType']
         | 
| 60 | 
            +
                    end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                    def assert_shipping(shipping)
         | 
| 63 | 
            +
                      assert_equal 'FEDEX', shipping['Carrier']
         | 
| 64 | 
            +
                      assert_equal 'GROUND', shipping['ServiceLevel']
         | 
| 65 | 
            +
                    end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                    def assert_line_item(expected_line_item, line_item)
         | 
| 68 | 
            +
                      assert_equal expected_line_item.id.to_s, line_item['ItemNumber']
         | 
| 69 | 
            +
                      assert_equal "1", line_item['Line']
         | 
| 70 | 
            +
                      assert_equal expected_line_item.quantity.to_s, line_item['QuantityOrdered']
         | 
| 71 | 
            +
                      assert_equal expected_line_item.quantity.to_s, line_item['QuantityToShip']
         | 
| 72 | 
            +
                      assert_equal expected_line_item.unit_of_measure, line_item['UOM']
         | 
| 73 | 
            +
                      assert_equal expected_line_item.price, line_item['Price']
         | 
| 74 | 
            +
                    end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                    def assert_address(email, address, node)
         | 
| 77 | 
            +
                      assert_equal address.company, node['Company']
         | 
| 78 | 
            +
                      assert_equal address.name, node['Contact']
         | 
| 79 | 
            +
                      assert_equal address.address1, node['Address1']
         | 
| 80 | 
            +
                      assert_equal address.address2, node['Address2']
         | 
| 81 | 
            +
                      assert_equal address.city, node['City']
         | 
| 82 | 
            +
                      assert_equal address.province_code, node['State']
         | 
| 83 | 
            +
                      assert_equal address.zip, node['PostalCode']
         | 
| 84 | 
            +
                      assert_equal address.country_code, node['Country']
         | 
| 85 | 
            +
                      assert_equal email, node['Email']
         | 
| 86 | 
            +
                    end
         | 
| 87 | 
            +
                  end
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
              end
         | 
| 90 | 
            +
            end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'hushed/documents/response/shipment_order_result'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Hushed
         | 
| 5 | 
            +
              module Documents
         | 
| 6 | 
            +
                module Response
         | 
| 7 | 
            +
                  describe "ShipmentOrderResult" do
         | 
| 8 | 
            +
                    include Fixtures
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                    it "should be able to successfully parse a response document" do
         | 
| 11 | 
            +
                      document = load_response('shipment_order_result')
         | 
| 12 | 
            +
                      order_result = ShipmentOrderResult.new(io: document)
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                      assert_equal 'HUSHED', order_result.client_id
         | 
| 15 | 
            +
                      assert_equal 'HUSHED', order_result.business_unit
         | 
| 16 | 
            +
                      assert_equal 1, order_result.carton_count
         | 
| 17 | 
            +
                      assert_equal Time.new(2009, 9, 1, 0, 0, 0).utc, order_result.date_shipped
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                      assert_equal "40000000000", order_result.tracking_number
         | 
| 20 | 
            +
                      assert_equal "FIRST", order_result.service_level
         | 
| 21 | 
            +
                      assert_equal "USPS", order_result.carrier
         | 
| 22 | 
            +
                    end
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,71 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'hushed/message'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Hushed
         | 
| 5 | 
            +
              describe "Message" do
         | 
| 6 | 
            +
                include Fixtures
         | 
| 7 | 
            +
                before do
         | 
| 8 | 
            +
                  prepare_models
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                it "should be possible to initialize a Message" do
         | 
| 12 | 
            +
                  message = Message.new(:document => @document, :client => @client)
         | 
| 13 | 
            +
                  assert_equal @document, message.document
         | 
| 14 | 
            +
                  assert_equal @client, message.client
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                it "should raise an error if the document is missing when trying to generate XML" do
         | 
| 18 | 
            +
                  message = Message.new(:client => @client)
         | 
| 19 | 
            +
                  assert_raises Message::MissingDocumentError do
         | 
| 20 | 
            +
                    message.to_xml
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                it "should raise an error if the client is missing when trying to generate XML" do
         | 
| 25 | 
            +
                  message = Message.new(:document => @document)
         | 
| 26 | 
            +
                  assert_raises Message::MissingClientError do
         | 
| 27 | 
            +
                    message.to_xml
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                it "should be possible to create a Message with XML and query it for information" do
         | 
| 32 | 
            +
                  message = Message.new(:xml => load_message('purchase_order_message'))
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  assert_equal 'PurchaseOrder', message.document_type
         | 
| 35 | 
            +
                  assert_equal 'HUSHED_PurchaseOrder_1234_20100927_132505124.xml', message.document_name
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                it "should be able to generate an XML document" do
         | 
| 39 | 
            +
                  message = Message.new(:document => @document, :client => @client)
         | 
| 40 | 
            +
                  document = Nokogiri::XML::Document.parse(message.to_xml)
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  expected_namespaces = {'xmlns' => Message::NAMESPACE}
         | 
| 43 | 
            +
                  assert_equal expected_namespaces, document.collect_namespaces()
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  assert node = document.css('EventMessage').first
         | 
| 46 | 
            +
                  assert_equal @document.type, node['DocumentType']
         | 
| 47 | 
            +
                  assert_equal @document.filename, node['DocumentName']
         | 
| 48 | 
            +
                  assert_equal @document.warehouse, node['Warehouse']
         | 
| 49 | 
            +
                  assert_equal @document.date.utc.to_s, node['MessageDate']
         | 
| 50 | 
            +
                  assert_equal @document.message_id, node['MessageId']
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  assert_equal @client.client_id, node['ClientId']
         | 
| 53 | 
            +
                  assert_equal @client.business_unit, node['BusinessUnit']
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                def prepare_models
         | 
| 57 | 
            +
                  @document = DocumentDouble.new(
         | 
| 58 | 
            +
                    type: "PurchaseOrder",
         | 
| 59 | 
            +
                    filename: "abracadabra.xml",
         | 
| 60 | 
            +
                    message_id: "alakazam",
         | 
| 61 | 
            +
                    warehouse: "Onett1",
         | 
| 62 | 
            +
                    date: Time.new(2013, 4, 1, 12, 30, 0)
         | 
| 63 | 
            +
                  )
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  @client = ClientDouble.new(
         | 
| 66 | 
            +
                    client_id: 'HUSHED',
         | 
| 67 | 
            +
                    business_unit: 'HUSHED'
         | 
| 68 | 
            +
                  )
         | 
| 69 | 
            +
                end
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
            end
         | 
| @@ -0,0 +1,48 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'hushed/queue'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Hushed
         | 
| 5 | 
            +
              describe "Queue" do
         | 
| 6 | 
            +
                include Fixtures
         | 
| 7 | 
            +
                before do
         | 
| 8 | 
            +
                  @sqs_queue = mock()
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  @client = mock()
         | 
| 11 | 
            +
                  @client.stubs(:to_quiet_queue).returns(@sqs_queue)
         | 
| 12 | 
            +
                  @client.stubs(:from_quiet_queue).returns(@sqs_queue)
         | 
| 13 | 
            +
                  @client.stubs(:quiet_inventory_queue).returns(@sqs_queue)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  @message = mock()
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  @queue = Queue.new(@client)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                it "should be able to write a message to a queue" do
         | 
| 21 | 
            +
                  @message.stubs(:to_xml).returns('hello world')
         | 
| 22 | 
            +
                  @sqs_queue.expects(:send_message).with('hello world')
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  @queue.send(@message)
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                it "should return a message when receiving from a queue" do
         | 
| 28 | 
            +
                  @message.stubs(:body).returns(load_message('purchase_order_message'))
         | 
| 29 | 
            +
                  @sqs_queue.expects(:receive_message).yields(@message)
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  received_message = @queue.receive
         | 
| 32 | 
            +
                  assert_equal 'PurchaseOrder', received_message.document_type
         | 
| 33 | 
            +
                  assert_equal 'HUSHED_PurchaseOrder_1234_20100927_132505124.xml', received_message.document_name
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                it "should return a message when receiving even if the queue did not return anything" do
         | 
| 37 | 
            +
                  @sqs_queue.expects(:receive_message)
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  received_message = @queue.receive
         | 
| 40 | 
            +
                  assert_equal false, received_message.nil?
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                it "should be possible to get an approximate number of pending messages" do
         | 
| 44 | 
            +
                  @sqs_queue.expects(:approximate_number_of_messages).returns(10)
         | 
| 45 | 
            +
                  assert_equal 10, @queue.approximate_pending_messages
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,207 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: hushed
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              prerelease: 
         | 
| 5 | 
            +
              version: 0.0.1
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Chris Saunders
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2013-06-03 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              prerelease: false
         | 
| 16 | 
            +
              name: aws-sdk
         | 
| 17 | 
            +
              type: :runtime
         | 
| 18 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 19 | 
            +
                requirements:
         | 
| 20 | 
            +
                - - ~>
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: 1.10.0
         | 
| 23 | 
            +
                none: false
         | 
| 24 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                requirements:
         | 
| 26 | 
            +
                - - ~>
         | 
| 27 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 28 | 
            +
                    version: 1.10.0
         | 
| 29 | 
            +
                none: false
         | 
| 30 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 31 | 
            +
              prerelease: false
         | 
| 32 | 
            +
              name: nokogiri
         | 
| 33 | 
            +
              type: :runtime
         | 
| 34 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 35 | 
            +
                requirements:
         | 
| 36 | 
            +
                - - ! '>='
         | 
| 37 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 38 | 
            +
                    version: '0'
         | 
| 39 | 
            +
                none: false
         | 
| 40 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                requirements:
         | 
| 42 | 
            +
                - - ! '>='
         | 
| 43 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 44 | 
            +
                    version: '0'
         | 
| 45 | 
            +
                none: false
         | 
| 46 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 47 | 
            +
              prerelease: false
         | 
| 48 | 
            +
              name: activesupport
         | 
| 49 | 
            +
              type: :runtime
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ! '>='
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
                none: false
         | 
| 56 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                requirements:
         | 
| 58 | 
            +
                - - ! '>='
         | 
| 59 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            +
                    version: '0'
         | 
| 61 | 
            +
                none: false
         | 
| 62 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              name: bundler
         | 
| 65 | 
            +
              type: :development
         | 
| 66 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 67 | 
            +
                requirements:
         | 
| 68 | 
            +
                - - ~>
         | 
| 69 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 70 | 
            +
                    version: '1.3'
         | 
| 71 | 
            +
                none: false
         | 
| 72 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                requirements:
         | 
| 74 | 
            +
                - - ~>
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 76 | 
            +
                    version: '1.3'
         | 
| 77 | 
            +
                none: false
         | 
| 78 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 79 | 
            +
              prerelease: false
         | 
| 80 | 
            +
              name: rake
         | 
| 81 | 
            +
              type: :development
         | 
| 82 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 83 | 
            +
                requirements:
         | 
| 84 | 
            +
                - - ! '>='
         | 
| 85 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 86 | 
            +
                    version: '0'
         | 
| 87 | 
            +
                none: false
         | 
| 88 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 89 | 
            +
                requirements:
         | 
| 90 | 
            +
                - - ! '>='
         | 
| 91 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 92 | 
            +
                    version: '0'
         | 
| 93 | 
            +
                none: false
         | 
| 94 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 95 | 
            +
              prerelease: false
         | 
| 96 | 
            +
              name: minitest
         | 
| 97 | 
            +
              type: :development
         | 
| 98 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 99 | 
            +
                requirements:
         | 
| 100 | 
            +
                - - ! '>='
         | 
| 101 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 102 | 
            +
                    version: 5.0.0
         | 
| 103 | 
            +
                none: false
         | 
| 104 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 105 | 
            +
                requirements:
         | 
| 106 | 
            +
                - - ! '>='
         | 
| 107 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 108 | 
            +
                    version: 5.0.0
         | 
| 109 | 
            +
                none: false
         | 
| 110 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 111 | 
            +
              prerelease: false
         | 
| 112 | 
            +
              name: mocha
         | 
| 113 | 
            +
              type: :development
         | 
| 114 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 115 | 
            +
                requirements:
         | 
| 116 | 
            +
                - - ! '>='
         | 
| 117 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 118 | 
            +
                    version: '0'
         | 
| 119 | 
            +
                none: false
         | 
| 120 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - ! '>='
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '0'
         | 
| 125 | 
            +
                none: false
         | 
| 126 | 
            +
            description: API Client for Quiet Logistics Services
         | 
| 127 | 
            +
            email:
         | 
| 128 | 
            +
            - chris.saunders@shopify.com
         | 
| 129 | 
            +
            executables: []
         | 
| 130 | 
            +
            extensions: []
         | 
| 131 | 
            +
            extra_rdoc_files: []
         | 
| 132 | 
            +
            files:
         | 
| 133 | 
            +
            - .gitignore
         | 
| 134 | 
            +
            - Gemfile
         | 
| 135 | 
            +
            - LICENSE.txt
         | 
| 136 | 
            +
            - README.md
         | 
| 137 | 
            +
            - Rakefile
         | 
| 138 | 
            +
            - hushed.gemspec
         | 
| 139 | 
            +
            - lib/hushed.rb
         | 
| 140 | 
            +
            - lib/hushed/blackboard.rb
         | 
| 141 | 
            +
            - lib/hushed/client.rb
         | 
| 142 | 
            +
            - lib/hushed/documents/document.rb
         | 
| 143 | 
            +
            - lib/hushed/documents/request/shipment_order.rb
         | 
| 144 | 
            +
            - lib/hushed/documents/response/shipment_order_result.rb
         | 
| 145 | 
            +
            - lib/hushed/message.rb
         | 
| 146 | 
            +
            - lib/hushed/queue.rb
         | 
| 147 | 
            +
            - lib/hushed/request.rb
         | 
| 148 | 
            +
            - lib/hushed/response.rb
         | 
| 149 | 
            +
            - lib/hushed/version.rb
         | 
| 150 | 
            +
            - spec/fixtures/credentials.yml
         | 
| 151 | 
            +
            - spec/fixtures/documents/responses/shipment_order_result.xml
         | 
| 152 | 
            +
            - spec/fixtures/messages/purchase_order_message.xml
         | 
| 153 | 
            +
            - spec/remote/blackboard_spec.rb
         | 
| 154 | 
            +
            - spec/remote/queue_spec.rb
         | 
| 155 | 
            +
            - spec/spec_helper.rb
         | 
| 156 | 
            +
            - spec/unit/blackboard_spec.rb
         | 
| 157 | 
            +
            - spec/unit/client_spec.rb
         | 
| 158 | 
            +
            - spec/unit/documents/document_spec.rb
         | 
| 159 | 
            +
            - spec/unit/documents/request/shipment_order_spec.rb
         | 
| 160 | 
            +
            - spec/unit/documents/response/shipment_order_result_spec.rb
         | 
| 161 | 
            +
            - spec/unit/message_spec.rb
         | 
| 162 | 
            +
            - spec/unit/queue_spec.rb
         | 
| 163 | 
            +
            homepage: ''
         | 
| 164 | 
            +
            licenses:
         | 
| 165 | 
            +
            - MIT
         | 
| 166 | 
            +
            post_install_message: 
         | 
| 167 | 
            +
            rdoc_options: []
         | 
| 168 | 
            +
            require_paths:
         | 
| 169 | 
            +
            - lib
         | 
| 170 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 171 | 
            +
              requirements:
         | 
| 172 | 
            +
              - - ! '>='
         | 
| 173 | 
            +
                - !ruby/object:Gem::Version
         | 
| 174 | 
            +
                  segments:
         | 
| 175 | 
            +
                  - 0
         | 
| 176 | 
            +
                  hash: 757848764150941350
         | 
| 177 | 
            +
                  version: '0'
         | 
| 178 | 
            +
              none: false
         | 
| 179 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 180 | 
            +
              requirements:
         | 
| 181 | 
            +
              - - ! '>='
         | 
| 182 | 
            +
                - !ruby/object:Gem::Version
         | 
| 183 | 
            +
                  segments:
         | 
| 184 | 
            +
                  - 0
         | 
| 185 | 
            +
                  hash: 757848764150941350
         | 
| 186 | 
            +
                  version: '0'
         | 
| 187 | 
            +
              none: false
         | 
| 188 | 
            +
            requirements: []
         | 
| 189 | 
            +
            rubyforge_project: 
         | 
| 190 | 
            +
            rubygems_version: 1.8.23
         | 
| 191 | 
            +
            signing_key: 
         | 
| 192 | 
            +
            specification_version: 3
         | 
| 193 | 
            +
            summary: Integrates with QL Blackboard and work Queue
         | 
| 194 | 
            +
            test_files:
         | 
| 195 | 
            +
            - spec/fixtures/credentials.yml
         | 
| 196 | 
            +
            - spec/fixtures/documents/responses/shipment_order_result.xml
         | 
| 197 | 
            +
            - spec/fixtures/messages/purchase_order_message.xml
         | 
| 198 | 
            +
            - spec/remote/blackboard_spec.rb
         | 
| 199 | 
            +
            - spec/remote/queue_spec.rb
         | 
| 200 | 
            +
            - spec/spec_helper.rb
         | 
| 201 | 
            +
            - spec/unit/blackboard_spec.rb
         | 
| 202 | 
            +
            - spec/unit/client_spec.rb
         | 
| 203 | 
            +
            - spec/unit/documents/document_spec.rb
         | 
| 204 | 
            +
            - spec/unit/documents/request/shipment_order_spec.rb
         | 
| 205 | 
            +
            - spec/unit/documents/response/shipment_order_result_spec.rb
         | 
| 206 | 
            +
            - spec/unit/message_spec.rb
         | 
| 207 | 
            +
            - spec/unit/queue_spec.rb
         |