Sha256: 989d382b750da5329320cdc535e75eda8129f035f01067ae74fa82d182d9d437

Contents?: true

Size: 956 Bytes

Versions: 21

Compression:

Stored size: 956 Bytes

Contents

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

  before { use_default_configuration! }

  let(:message) { RecursiveOpenStruct.new(status: status) }
  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

21 entries across 21 versions & 1 rubygems

Version Path
pheme-4.1.0 spec/message_handler_spec.rb
pheme-4.0.15 spec/message_handler_spec.rb
pheme-4.0.14 spec/message_handler_spec.rb
pheme-4.0.13 spec/message_handler_spec.rb
pheme-4.0.12 spec/message_handler_spec.rb
pheme-4.0.11 spec/message_handler_spec.rb
pheme-4.0.10 spec/message_handler_spec.rb
pheme-4.0.9 spec/message_handler_spec.rb
pheme-4.0.8 spec/message_handler_spec.rb
pheme-4.0.7 spec/message_handler_spec.rb
pheme-4.0.6 spec/message_handler_spec.rb
pheme-4.0.5 spec/message_handler_spec.rb
pheme-4.0.3 spec/message_handler_spec.rb
pheme-4.0.2 spec/message_handler_spec.rb
pheme-4.0.1 spec/message_handler_spec.rb
pheme-4.0.0 spec/message_handler_spec.rb
pheme-3.4.0 spec/message_handler_spec.rb
pheme-3.3.3 spec/message_handler_spec.rb
pheme-3.3.2 spec/message_handler_spec.rb
pheme-3.3.0 spec/message_handler_spec.rb