Sha256: 0bf9e798c713d9f45dee5d5ef17ac63b1f0958fa33847213c678485966bc08ad

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

# $Id: setup.rb 53 2007-11-28 00:21:33Z tim_pease $

require 'test/unit'

# This line is needed for Ruby 1.9 -- hashes throw a "KeyError" in 1.9
# whereas they throw an "IndexError" in 1.8
#
KeyError = IndexError if not defined? KeyError

begin
  require 'logging'
rescue LoadError
  path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
  raise if $:.include? path
  $: << path
  retry
end

begin
  require 'turn'
rescue LoadError
  require 'rubygems'
  begin; require 'turn'; rescue LoadError; end
end


module TestLogging
module LoggingTestCase

  def setup
    super

    ::Logging.module_eval do
      ::Logging::LEVELS.clear
      ::Logging::LNAMES.clear
      remove_const :MAX_LEVEL_LENGTH if const_defined? :MAX_LEVEL_LENGTH
      remove_const :OBJ_FORMAT if const_defined? :OBJ_FORMAT
    end

    ::Logging::Repository.class_eval do
      if defined?(@singleton__instance__)
        @singleton__instance__ = nil
      else
        @__instance__ = nil
        class << self
          nonce = class << Singleton; self; end
          define_method(:instance, nonce::FirstInstanceCall)
        end
      end
    end
    
    ::Logging::Appender.instance_variable_get(:@appenders).clear
  end

end  # module LoggingTestCase
end  # module TestLogging

# EOF

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logging-0.5.2 test/setup.rb
logging-0.5.3 test/setup.rb