Sha256: 10d0530e1f86041c4be9ed6e291895e015b97c398ae727b82f0471717fb320ec

Contents?: true

Size: 1.39 KB

Versions: 9

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'
require 'hushed'
require 'hushed/blackboard'

module Hushed
  describe "BlackboardRemote" do
    include Configuration
    include Fixtures

    before do
      AWS.config(stub_requests: false)
      @client = Client.new(load_configuration)
      @blackboard = Blackboard.new(@client)
      @document = DocumentDouble.new(
        message_id: '1234567',
        date: Time.new(2013, 04, 05, 12, 30, 15).utc,
        filename: 'neat_beans.xml',
        client: @client,
        type: 'ShipmentOrderResult'
      )
    end

    after do
      buckets = [@client.to_quiet_bucket, @client.from_quiet_bucket]
      buckets.each { |bucket| bucket.objects.delete_all }
    end

    it "should be able to write a document to an S3 bucket" do
      message = @blackboard.post(@document)
      file = message.document_name
      bucket = @client.to_quiet_bucket
      assert bucket.objects[file].exists?, "It appears that #{file} was not written to S3"
    end

    it "should be able to fetch a document from an S3 bucket when given a message" do
      expected_contents = load_response('shipment_order_result').read()
      @client.from_quiet_bucket.objects[@document.filename].write(expected_contents)
      message = MessageDouble.new(document_name: @document.filename, document_type: @document.type)
      document = @blackboard.fetch(message)
      assert_equal expected_contents, document.io
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hushed-0.0.9 spec/remote/blackboard_spec.rb
hushed-0.0.8 spec/remote/blackboard_spec.rb
hushed-0.0.7 spec/remote/blackboard_spec.rb
hushed-0.0.6 spec/remote/blackboard_spec.rb
hushed-0.0.5 spec/remote/blackboard_spec.rb
hushed-0.0.4 spec/remote/blackboard_spec.rb
hushed-0.0.3 spec/remote/blackboard_spec.rb
hushed-0.0.2 spec/remote/blackboard_spec.rb
hushed-0.0.1 spec/remote/blackboard_spec.rb