Sha256: 778692aeacc1e4d934e6c584004270eabc4201a1890576c696c96ff2c3689db5

Contents?: true

Size: 1.59 KB

Versions: 2

Compression:

Stored size: 1.59 KB

Contents

require 'songkick_queue/consumer'

module SongkickQueue
  RSpec.describe Consumer do
    describe ".from_queue" do
      it "should fail if .consume_from_queue has not been called" do
        class ExampleConsumer
          include SongkickQueue::Consumer
        end

        expect { ExampleConsumer.queue_name }.to raise_error(NotImplementedError)
      end

      it "should return the queue name set by .consume_from_queue" do
        class ExampleConsumer
          include SongkickQueue::Consumer

          consume_from_queue 'app.examples'
        end

        expect(ExampleConsumer.queue_name).to eq 'app.examples'
      end

      it "should add the configured namespace to the queue name" do
        class ExampleConsumer
          include SongkickQueue::Consumer

          consume_from_queue 'app.examples'
        end

        allow(ExampleConsumer).to receive(:config) { double(queue_namespace: 'test-env') }

        expect(ExampleConsumer.queue_name).to eq 'test-env.app.examples'
      end
    end

    describe "#initialize" do
      it "should pass a logger" do
        class ExampleConsumer
          include SongkickQueue::Consumer
        end

        consumer = ExampleConsumer.new(:delivery_info, :logger)

        expect(consumer.logger).to eq :logger
      end
    end

    describe "#process" do
      it "should fail if not overridden" do
        class ExampleConsumer
          include SongkickQueue::Consumer
        end

        consumer = ExampleConsumer.new(:delivery_info, :logger)

        expect { consumer.process(:message) }.to raise_error(NotImplementedError)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
songkick_queue-0.3.0 spec/songkick_queue/consumer_spec.rb
songkick_queue-0.2.0 spec/songkick_queue/consumer_spec.rb