Sha256: ca9602931622509e8416cf60fcf655d7870ff4bc076b54835c308da8c9f6693b

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require "spec_helper"

describe Alephant::Publisher::Queue do
  let(:options)     { Alephant::Publisher::Queue::Options.new }
  let(:fake_client) { Aws::SQS::Client.new(stub_responses: true) }

  before(:each) do
    allow_any_instance_of(Alephant::Publisher::Queue::Publisher).to receive(:sqs_client).and_return(fake_client)
    fake_client.stub_responses(:get_queue_url, { queue_url: 'http://sqs.aws.myqueue/id' })
  end

  describe ".create" do
    it "sets parser, sequencer, queue and writer" do
      options.add_queue(
        :sqs_queue_name => "bar",
        :aws_account_id => "foo"
      )
      instance = Alephant::Publisher::Queue.create(options)
      expect(instance.queue)
        .to be_a Alephant::Publisher::Queue::SQSHelper::Queue
    end

    context "with account" do
      it "creates a queue with an account number in the option hash" do
        options = Alephant::Publisher::Queue::Options.new
        options.add_queue(
          :sqs_queue_name => "bar",
          :aws_account_id => "foo"
        )

        publisher = Alephant::Publisher::Queue.create(options)

        expect(publisher.queue.queue).to be_a(Aws::SQS::Queue)
      end
    end

    context "without account" do
      it "creates a queue with an empty option hash" do
        options = Alephant::Publisher::Queue::Options.new
        options.add_queue(:sqs_queue_name => "bar")

        publisher = Alephant::Publisher::Queue.create(options)

        expect(publisher.queue.queue).to be_a(Aws::SQS::Queue)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alephant-publisher-queue-2.6.0 spec/alephant/publisher/queue_spec.rb