Sha256: e584714c37890f92a646b8c00daa525b6986d079ee2c8088a9151b86ed00d626

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

require "spec_helper"

describe Alephant::Publisher::Queue do
  let(:options)       { Alephant::Publisher::Queue::Options.new }
  let(:queue)         { double("AWS::SQS::Queue", :url => nil) }
  let(:client_double) { double("AWS::SQS", :queues => queue_double) }
  let(:queue_double) do
    double("AWS::SQS::QueueCollection", :[] => queue, :url_for => nil)
  end

  before(:each) do
    expect(AWS::SQS).to receive(:new).and_return(client_double)
  end

  describe ".create" do
    it "sets parser, sequencer, queue and writer" do
      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"
        )

        expect(queue_double).to receive(:url_for).with(
          "bar",
          :queue_owner_aws_account_id => "foo"
        )

        Alephant::Publisher::Queue.create(options)
      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")

        expect(queue_double).to receive(:url_for).with("bar", {})

        Alephant::Publisher::Queue.create(options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alephant-publisher-queue-2.2.0 spec/publisher_spec.rb