Sha256: 6819a73ac8039665a6c142a19d1fa53d06b7bcb93e0d8d1ca3f4d3de0da100db

Contents?: true

Size: 902 Bytes

Versions: 2

Compression:

Stored size: 902 Bytes

Contents

require 'rubygems'
require 'active_support'
require File.join(File.dirname(__FILE__),'../lib/multilogger.rb')

describe MultiLogger do

  before do
    @target = StringIO.new
    @alt_target = StringIO.new
    @log = MultiLogger.new(@target)
    @log.add_log(/p[aA]ttern/, @alt_target)
  end
  
  it "should log messages to the supplied IO object" do
    @log.fatal("This will go to the main log.")
    @target.rewind
    @target.read.should == "This will go to the main log.\n"
    @alt_target.rewind
    @alt_target.read.should == ""
  end

  it "should split messages that match supplied patterns into their respective alternate log files" do
    @log.fatal("This matches the pattern, and will go to the alternate log.")
    @target.rewind
    @target.read.should == ""
    @alt_target.rewind
    @alt_target.read.should == "This matches the pattern, and will go to the alternate log.\n"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
multilogger-0.1.5 spec/multilogger_spec.rb
multilogger-0.1.4 spec/multilogger_spec.rb