Sha256: 3d67e3457de747778736b0adc7ab8db7a9eabd77d69857d2ad09d9c446936626
Contents?: true
Size: 1.21 KB
Versions: 3
Compression:
Stored size: 1.21 KB
Contents
# -*- encoding: utf-8 -*- require 'minitest/autorun' require 'stringio' require 'webgen/logger' class TestLogger < MiniTest::Unit::TestCase def test_logging @logio = StringIO.new logger = Webgen::Logger.new(@logio) logger.formatter = Proc.new do |severity, timestamp, progname, msg| "#{severity} #{msg}\n" end logger.verbose = false logger.debug { ["debug", "verbose"]} assert_log(/^DEBUG debug$/) logger.info {["info", "verbose"]} assert_log(/^INFO info$/) logger.warn {["warn", "verbose"]} assert_log(/^WARN warn$/) logger.error {["error", "verbose"]} assert_log(/^ERROR error$/) logger.vinfo {["verbose", "verbose"]} assert_log(/^$/) logger.verbose = true logger.debug { ["debug", "verbose"]} assert_log(/^DEBUG debug\nverbose$/) logger.info {["info", "verbose"]} assert_log(/^INFO info\nverbose$/) logger.warn {["warn", "verbose"]} assert_log(/^WARN warn\nverbose$/) logger.error {["error", "verbose"]} assert_log(/^ERROR error\nverbose$/) logger.vinfo {["verbose", "verbose"]} assert_log(/^INFO verbose\nverbose$/) end def assert_log(reg) assert_match(reg, @logio.string) @logio.string = '' end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
webgen-1.0.0.beta3 | test/webgen/test_logger.rb |
webgen-1.0.0.beta2 | test/webgen/test_logger.rb |
webgen-1.0.0.beta1 | test/webgen/test_logger.rb |