Sha256: 82a7944b041168916df4ba1237ab35f62d7a06e6e95f502918aa5baa2077ff7a

Contents?: true

Size: 1.77 KB

Versions: 5

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

module MessageDriver
  module Adapters
    RSpec.describe Base do
      let(:spec_adapter_class) do
        Class.new(described_class) do
          def initialize; end
        end
      end
      subject(:adapter) { spec_adapter_class.new }

      describe '#new_context' do
        it 'raises an error' do
          expect do
            subject.new_context
          end.to raise_error 'Must be implemented in subclass'
        end
      end

      context 'with a test adapter' do
        subject(:adapter) { TestAdapter.new(nil, {}) }

        describe ContextBase do
          context 'with a test context subclass' do
            subject(:adapter_context) { TestContext.new(adapter) }

            it_behaves_like 'an adapter context'
            it_behaves_like 'transactions are not supported'
            it_behaves_like 'client acks are not supported'
            it_behaves_like 'subscriptions are not supported'
          end

          subject(:adapter_context) { ContextBase.new(adapter) }

          describe '#create_destination' do
            it 'raises an error' do
              expect do
                subject.create_destination('foo')
              end.to raise_error 'Must be implemented in subclass'
            end
          end

          describe '#publish' do
            it 'raises an error' do
              expect do
                subject.publish(:destination, foo: 'bar')
              end.to raise_error 'Must be implemented in subclass'
            end
          end

          describe '#pop_message' do
            it 'raises an error' do
              expect do
                subject.pop_message(:destination)
              end.to raise_error 'Must be implemented in subclass'
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
message-driver-1.0.1 spec/units/message_driver/adapters/base_spec.rb
message-driver-1.0.0 spec/units/message_driver/adapters/base_spec.rb
message-driver-0.7.2 spec/units/message_driver/adapters/base_spec.rb
message-driver-0.7.1 spec/units/message_driver/adapters/base_spec.rb
message-driver-0.7.0 spec/units/message_driver/adapters/base_spec.rb