Sha256: 7ed3d6b7bd684fec2969101d1837df394216adf18fff6ab7ad43fd1a5833cf39

Contents?: true

Size: 1 KB

Versions: 11

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

describe CopyTunerClient::PrefixedLogger do
  let(:output_logger) { FakeLogger.new }
  let(:prefix) { "** NOTICE:" }
  let(:thread_info) { "[P:#{Process.pid}] [T:#{Thread.current.object_id}]" }
  subject { CopyTunerClient::PrefixedLogger.new(prefix, output_logger) }

  it "provides the prefix" do
    expect(subject.prefix).to eq(prefix)
  end

  it "provides the logger" do
    expect(subject.original_logger).to eq(output_logger)
  end

  [:debug, :info, :warn, :error, :fatal].each do |level|
    it "prefixes #{level} log messages" do
      message = 'hello'
      subject.send(level, message)

      expect(output_logger).to have_entry(level, "#{prefix} #{thread_info} #{message}")
    end
  end

  it "calls flush for a logger that responds to flush" do
    output_logger.stubs(:flush)

    subject.flush

    expect(output_logger).to have_received(:flush)
  end

  it "doesn't call flush for a logger that doesn't respond to flush" do
    expect { subject.flush }.not_to raise_error
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
copy_tuner_client-0.4.9 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.4.8 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.4.7 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.4.6 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.4.5 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.4.4 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.4.3 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.4.2 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.4.1 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.4.0 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.3.5 spec/copy_tuner_client/prefixed_logger_spec.rb