Sha256: 1d2ab27643153594adc55af29cb5b6656ce3d78a96540c82d13396d4ce8cab3f

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'
require_relative '../../lib/logasm/adapters/rabbitmq_adapter'

describe Logasm::Adapters::RabbitmqAdapter do
  let(:publisher) { adapter.publisher }

  before do
    Logasm::Adapters::RabbitmqAdapter::Publisher.any_instance.stub(:initialize).and_return(double)
  end

  describe '#log' do
    context 'when logging a message' do
      let(:adapter) { described_class.new(0, nil, { host: 'localhost',
                                                    user: 'guest',
                                                    pass: 'guest',
                                                    port: '5672' }
                                          ) }

      it 'delegates to publisher' do
        expect(publisher).to receive(:publish)

        adapter.log :info, message: 'test'
      end
    end

    context 'when log level is lower than threshold' do
      let(:adapter) { described_class.new(3, nil, { host: 'localhost',
                                                    user: 'guest',
                                                    pass: 'guest',
                                                    port: '5672' }
                                          ) }

      it 'does not delegate to freddy' do
        expect(publisher).not_to receive(:publish)
        adapter.log :info, message: 'test'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logasm-0.2.0 spec/adapters/rabbitmq_adapter_spec.rb