Sha256: 4485677c6218a9f40d1e2d2c3bf74784825c563547cd04056669251dd19337de

Contents?: true

Size: 844 Bytes

Versions: 12

Compression:

Stored size: 844 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
		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 :)'
	end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
glue-0.13.0 test/glue/tc_logger.rb
glue-0.14.0 test/glue/tc_logger.rb
glue-0.15.0 test/glue/tc_logger.rb
glue-0.16.0 test/glue/tc_logger.rb
glue-0.17.0 test/glue/tc_logger.rb
glue-0.18.0 test/glue/tc_logger.rb
glue-0.18.1 test/glue/tc_logger.rb
nitro-0.10.0 test/glue/tc_logger.rb
nitro-0.11.0 test/glue/tc_logger.rb
nitro-0.12.0 test/glue/tc_logger.rb
nitro-0.9.5 test/glue/tc_logger.rb
nitro-0.9.3 test/glue/tc_logger.rb