Sha256: 96d4d24b71bb1cd62966aed0ad75d40fa0e2a5244a238277be89379007ec03b3

Contents?: true

Size: 1012 Bytes

Versions: 19

Compression:

Stored size: 1012 Bytes

Contents

require 'spec_helper'

describe CopycopterClient::PrefixedLogger do
  let(:output_logger) { FakeLogger.new }
  let(:prefix) { "** NOTICE:" }
  let(:thread_info) { "[P:#{Process.pid}] [T:#{Thread.current.object_id}]" }
  subject { CopycopterClient::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

19 entries across 19 versions & 1 rubygems

Version Path
copycopter_client-2.0.1 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-2.0.0 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.1.2 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.1.1 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.1.0 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.4 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.3 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.2 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.1 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.0 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.0.beta11 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.0.beta10 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.0.beta9 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.0.beta8 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.0.beta7 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.0.beta6 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.0.beta5 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.0.beta4 spec/copycopter_client/prefixed_logger_spec.rb
copycopter_client-1.0.0.beta3 spec/copycopter_client/prefixed_logger_spec.rb