Sha256: a91b90d69d624cf359a53ad68ae27058b04961c3a8c16b8423f6e7c7f2666867

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

describe Ougai::Logging do
  subject do
    m = described_class
    Class.new { include m }.new
  end

  describe '#weak_merge!' do
    it 'merges with unique elements in array' do
      result = nil
      subject.instance_eval do
        result = weak_merge!({ foo: [1, 2], bar: 'base', baz: ['A'] },
                             { foo: [2, 3], bar: 'inferior', baz: ['B'] })
      end
      expect(result[:foo]).to eq([2, 3, 1])
      expect(result[:bar]).to eq('base')
      expect(result[:baz]).to eq(['B', 'A'])
    end
  end

  describe '#child' do
    let!(:fields) { double('fields') }
    let!(:child_logger) { double('child logger') }

    context 'block is not given' do
      it 'returns child logger' do
        expect(Ougai::ChildLogger).to receive(:new).with(subject, fields).and_return(child_logger)
        expect(subject.child(fields)).to eq(child_logger)
      end
    end

    context 'block is given' do
      it 'passes child logger' do
        expect(Ougai::ChildLogger).to receive(:new).with(subject, fields).and_return(child_logger)
        subject.child(fields) do |cl|
          expect(cl).to eq(child_logger)
        end
      end
    end
  end

  describe '#chain' do
    it 'is not implemented' do
      expect{ subject.chain(:arg1, :arg2, :arg3, :arg4) }.to raise_error(NotImplementedError)
    end
  end

  describe '#append' do
    it 'is not implemented' do
      expect{ subject.send(:append, :arg1, :arg2) }.to raise_error(NotImplementedError)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ougai-1.7.1 spec/logging_spec.rb
ougai-1.7.1-java spec/logging_spec.rb
ougai-1.7.0 spec/logging_spec.rb
ougai-1.6.6 spec/logging_spec.rb
ougai-1.6.5 spec/logging_spec.rb
ougai-1.6.4 spec/logging_spec.rb