Sha256: 9cba90bf5810453666239e10c8eb22938a614db33a1325dd6789aa18cd03f817

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 KB

Contents

require "spec_helper"

describe "Actions for Messages", :sqs do

  before do
    sqs.queues.create("test")
  end

  let(:sqs) { AWS::SQS.new }
  let(:queue) { sqs.queues.named("test") }

  specify "SendMessage" do
    msg = "this is my message"
    result = queue.send_message(msg)
    result.md5.should eq Digest::MD5.hexdigest(msg)
  end

  specify "ReceiveMessage" do
    body = "test 123"
    queue.send_message(body)
    message = queue.receive_message
    message.body.should eq body
  end

  specify "DeleteMessage" do
    queue.send_message("test")

    message1 = queue.receive_message
    message1.delete

    let_messages_in_flight_expire

    message2 = queue.receive_message
    message2.should be_nil
  end

  specify "DeleteMessageBatch" do
    queue.send_message("test1")
    queue.send_message("test2")

    message1 = queue.receive_message
    message2 = queue.receive_message
    queue.batch_delete(message1, message2)

    let_messages_in_flight_expire

    message3 = queue.receive_message
    message3.should be_nil
  end

  specify "SendMessageBatch" do
    bodies = %w(a b c)
    queue.batch_send(*bodies)

    messages = queue.receive_message(:limit => 10)
    messages.map(&:body).should match_array bodies
  end

  def let_messages_in_flight_expire
    $fake_sqs.expire
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fake_sqs-0.0.11 spec/acceptance/message_actions_spec.rb
fake_sqs-0.0.10 spec/acceptance/message_actions_spec.rb
fake_sqs-0.0.9 spec/acceptance/message_actions_spec.rb
fake_sqs-0.0.8 spec/acceptance/message_actions_spec.rb
fake_sqs-0.0.7 spec/acceptance/message_actions_spec.rb