Sha256: 0adac362d04db72639a347356825077b97be89e27c706ff5c3091bdba4c2323d

Contents?: true

Size: 1.41 KB

Versions: 15

Compression:

Stored size: 1.41 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(:queue_double)  { double('AWS::SQS::QueueCollection', :[] => queue, :url_for => nil) }
  let(:client_double) { double('AWS::SQS', :queues => queue_double) }

  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

15 entries across 15 versions & 1 rubygems

Version Path
alephant-publisher-queue-2.0.0 spec/publisher_spec.rb
alephant-publisher-queue-1.4.1 spec/publisher_spec.rb
alephant-publisher-queue-1.4.0 spec/publisher_spec.rb
alephant-publisher-queue-1.3.6 spec/publisher_spec.rb
alephant-publisher-queue-1.3.5 spec/publisher_spec.rb
alephant-publisher-queue-1.3.4 spec/publisher_spec.rb
alephant-publisher-queue-1.3.3 spec/publisher_spec.rb
alephant-publisher-queue-1.3.2 spec/publisher_spec.rb
alephant-publisher-queue-1.2.2 spec/publisher_spec.rb
alephant-publisher-queue-1.2.1 spec/publisher_spec.rb
alephant-publisher-queue-1.2.0 spec/publisher_spec.rb
alephant-publisher-queue-1.1.0 spec/publisher_spec.rb
alephant-publisher-queue-1.0.0 spec/publisher_spec.rb
alephant-publisher-queue-0.1.0 spec/publisher_spec.rb
alephant-publisher-queue-0.0.1 spec/publisher_spec.rb