File: setup.rb

package info (click to toggle)
ruby-logging 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 688 kB
  • sloc: ruby: 6,272; sh: 9; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 765 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Equivalent to a header guard in C/C++
# Used to prevent the class/module from being loaded more than once
unless defined? LOGGING_TEST_SETUP
LOGGING_TEST_SETUP = true

require "rubygems"
require "test/unit"
require "tmpdir"

LOGGING_TEST_TMPDIR = Dir.mktmpdir("logging")
Test::Unit.at_exit do
  FileUtils.remove_entry(LOGGING_TEST_TMPDIR)
end

if Test::Unit::TestCase.respond_to? :test_order=
  Test::Unit::TestCase.test_order = :random
end

require "logging"

module TestLogging
  module LoggingTestCase

    def setup
      super
      Logging.reset
      @tmpdir = LOGGING_TEST_TMPDIR
      FileUtils.rm_rf(Dir.glob(File.join(@tmpdir, "*")))
    end

    def teardown
      super
      FileUtils.rm_rf(Dir.glob(File.join(@tmpdir, "*")))
    end
  end
end

end