Sha256: f9a531a059bd8e6c1353e65256c434783da7a38659b74daa46776becba95fa53

Contents?: true

Size: 1022 Bytes

Versions: 3

Compression:

Stored size: 1022 Bytes

Contents

require File.expand_path('../spec_helper', File.dirname(__FILE__))
require 'gorillib/logger/log'


describe 'Logger' do
  # so we can practice loading and unloading
  def logger_code_file
    GORILLIB_ROOT_DIR('lib/gorillib/logger/log.rb')
  end

  describe '#dump' do
    it 'inspects each arg and sends tab-separated to Log.debug' do
      Log.should_receive(:debug).with(%r{\{:hi=>"there"\}\t3\t\"bye\".*#{__FILE__}:.*in })
      Log.dump({ :hi => "there" }, 3, "bye")
    end
  end

  it 'does not create a log if one exists' do
    dummy = 'dummy'
    Object.instance_eval{ remove_const(:Log) rescue nil ; ::Log = dummy }
    load(logger_code_file)
    ::Log.should equal(dummy)
    Object.instance_eval{ remove_const(:Log) rescue nil }
  end

  it 'creates a new log to STDERR' do
    @old_stderr = $stderr
    $stderr = StringIO.new
    Object.instance_eval{ remove_const(:Log) rescue nil }
    load(logger_code_file)
    Log.info 'hi mom'
    $stderr.string.should =~ /hi mom/
    $stderr = @old_stderr
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gorillib-0.1.11 spec/logger/log_spec.rb
gorillib-0.1.9 spec/logger/log_spec.rb
gorillib-0.1.8 spec/logger/log_spec.rb