Sha256: 7b26a63c1d7b4ec1bfe7a14fa10710b8847ab530910f8c98aa0057d551dfc2ec

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 KB

Contents

require 'test_helper'
require 'simple_aws/sqs'

describe SimpleAWS::SQS do

  before do
    @api = SimpleAWS::SQS.new "key", "secret"
  end

  it "points to the endpoint" do
    @api.uri.must_equal "https://sqs.us-east-1.amazonaws.com"
  end

  it "works with the current version" do
    @api.version.must_equal "2011-10-01"
  end

  describe "API calls" do

    it "builds and signs calls with ActionParam rules" do
      SimpleAWS::Connection.any_instance.expects(:call).with do |request|
        params = request.params
        params.wont_be_nil

        params["Action"].must_equal "ListQueues"
        params["Signature"].wont_be_nil

        true
      end

      obj = SimpleAWS::SQS.new "key", "secret"
      obj.list_queues
    end

    it "listens for the first parameter to be a queue URL and sets the path appropriately" do
      SimpleAWS::Connection.any_instance.expects(:call).with do |request|
        params = request.params
        params.wont_be_nil

        request.host.must_equal "sqs.us-west-1.amazonaws.com"
        request.path.must_equal "/1234567890/queue_name"

        params["MessageBody"].must_equal "This is a message body"

        true
      end

      obj = SimpleAWS::SQS.new "key", "secret"
      obj.send_message "http://sqs.us-west-1.amazonaws.com/1234567890/queue_name",
        "MessageBody" => "This is a message body"
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple_aws-1.2.3 test/simple_aws/sqs.rb
simple_aws-1.2.2 test/simple_aws/sqs.rb
simple_aws-1.2.1 test/simple_aws/sqs.rb
simple_aws-1.2.0 test/simple_aws/sqs.rb
simple_aws-1.1.0 test/simple_aws/sqs.rb