Sha256: fc6ae27b2deee730ba6fe77f282b8b8e31f8e27733365880d0cc023af2ed6cbf

Contents?: true

Size: 1.95 KB

Versions: 2

Compression:

Stored size: 1.95 KB

Contents

#
# File::       test_SiteFuelLogging.rb
# Author::     wkm
# Copyright::  2009
# License::    GPL
#
# Unit tests for the sitefuel logging class
#

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

require 'test/unit'
require 'logger'

require 'sitefuel/SiteFuelLogger'

include SiteFuel

class TestSiteFuelLogging < Test::Unit::TestCase
  def test_fatal
    log = SiteFuelLogger.instance
    log.level = Logger::UNKNOWN

    fatal = log.fatal_count
    assert_equal fatal, log.fatal_count
    log.fatal('fatal error')
    assert_equal fatal+1, log.fatal_count
    log.fatal('apparently not so fatal, since here\'s another fatal error')
    assert_equal fatal+2, log.fatal_count
  end

  def test_errors
    log = SiteFuelLogger.instance
    log.level = Logger::UNKNOWN

    error = log.error_count
    assert_equal error, log.error_count
    log.error('just an error')
    assert_equal error+1, log.error_count
    log.error('another error')
    assert_equal error+2, log.error_count
  end

  def test_warnings
    log = SiteFuelLogger.instance
    log.level = Logger::UNKNOWN

    warn = log.warn_count
    assert_equal warn, log.warn_count
    log.warn('just a warning')
    assert_equal warn+1, log.warn_count
    log.warn('another warning :)')
    assert_equal warn+2, log.warn_count
  end

  def test_info_messages
    log = SiteFuelLogger.instance
    log.level = Logger::UNKNOWN

    info = log.info_count
    assert_equal info, log.info_count
    log.info('oh hello, just letting you know...')
    assert_equal info+1, log.info_count
    log.info('... the sky is still blue.')
    assert_equal info+2, log.info_count
  end

  def test_debug_messages
    log = SiteFuelLogger.instance
    log.level = Logger::UNKNOWN

    debug = log.debug_count
    assert_equal debug, log.debug_count
    log.debug('about to run an assert!')
    assert_equal debug+1, log.debug_count
    log.debug('wadda ya know. about to run another assert.')
    assert_equal debug+2, log.debug_count
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitefuel-0.0.0b test/test_SiteFuelLogging.rb
sitefuel-0.0.0a test/test_SiteFuelLogging.rb