Sha256: 7b86f794c1b4cced1bcdf01ba9aae98048783a71680a48f3d0e22b304455a325

Contents?: true

Size: 1010 Bytes

Versions: 43

Compression:

Stored size: 1010 Bytes

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
    subject.prefix.should == prefix
  end

  it "provides the logger" do
    subject.original_logger.should == output_logger
  end

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

      output_logger.should 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

    output_logger.should have_received(:flush)
  end

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

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
copy_tuner_client-0.0.15 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.1.1.beta9 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.1.1.beta8 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.1.1.beta7 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.1.1.beta6 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.1.1.beta5 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.0.14 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.1.1.beta4 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.1.1.beta3 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.1.1.beta2 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.1.1.beta spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.1.0.beta spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.0.12 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.0.11 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.0.9 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.0.8 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.0.7 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.0.6 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.0.5 spec/copy_tuner_client/prefixed_logger_spec.rb
copy_tuner_client-0.0.4 spec/copy_tuner_client/prefixed_logger_spec.rb