Sha256: 7f50d72062a126caabe81d39e5bea649eab32cc0e12a1315a3ac49777122c090

Contents?: true

Size: 1022 Bytes

Versions: 1

Compression:

Stored size: 1022 Bytes

Contents

describe Pheme::MessageHandler do
  subject { ExampleMessageHandler.new(message: message, metadata: { timestamp: timestamp }) }

  before { use_default_configuration! }

  # rubocop:disable RSpec/VerifiedDoubles
  let(:message) { double(status: status) }
  # rubocop:enable RSpec/VerifiedDoubles
  let(:timestamp) { '2018-04-17T21:45:05.915Z' }

  describe "#handle" do
    context 'complete message' do
      let(:status) { 'complete' }

      it "handles the message correctly" do
        expect(Pheme.logger).to receive(:info).with("Done")
        subject.handle
      end
    end

    context 'rejected message' do
      let(:status) { 'rejected' }

      it 'handles the message correctly' do
        expect(Pheme.logger).to receive(:error).with("Oops")
        subject.handle
      end
    end

    context 'base handler' do
      subject { described_class.new(message: nil).handle }

      it 'does not implement handle' do
        expect { subject }.to raise_error(NotImplementedError)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pheme-4.1.1 spec/message_handler_spec.rb