Sha256: ebc95561c867be0e391747058142f471f07b2469f1b347a8d83ccfc86f227427

Contents?: true

Size: 981 Bytes

Versions: 7

Compression:

Stored size: 981 Bytes

Contents

$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'vendor')

require 'stringio'

require 'test/unit'
require 'glue/logger'

class TC_Logger < Test::Unit::TestCase # :nodoc: all

  def setup
    @io = StringIO.new('')
    Logger.set(Logger.new(@io))
  end

  def test_logger
=begin
    Logger.info 'hello'
    assert_equal(" INFO: hello\n", @io.string)

    # bug: Binding.of_caller thinks Logger is the caller.
    a = 14
    b = 13
    Logger.trace 'a * b'
    assert_equal(" INFO: hello\nDEBUG: a * b = 182\n", @io.string)
    
    @io.string = ''
    Logger.debug 'hello'
    assert_equal("DEBUG: hello\n", @io.string)

    # test logging level.
    Logger.get.level = Logger::INFO
    Logger.debug 'world'
    assert_equal("DEBUG: hello\n", @io.string)

    # bug:
    Logger.error 'Have forgotten that :)'
    
    # 
    Logger.set('hello.log')
    assert_instance_of(Logger, Logger.get)
=end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
glue-0.24.0 test/glue/tc_logger.rb
glue-0.25.0 test/glue/tc_logger.rb
glue-0.26.0 test/glue/tc_logger.rb
glue-0.27.0 test/glue/tc_logger.rb
glue-0.28.0 test/glue/tc_logger.rb
glue-0.29.0 test/glue/tc_logger.rb
glue-0.30.0 test/glue/tc_logger.rb