Sha256: d4a99f1c6cd65ec44114a8f439eb93032a587565c31fb3003f65094126ef5c82

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require 'test/unit'
require 'shoulda'
require 'pathname'

$: << ( Pathname.new(__FILE__).parent.parent + 'lib' ).realpath.to_s

# Allow running of startup and shutdown things before
# an entire suite, instead of just one per test.
# Creation of a database would be an example.
class SuiteWrapper < Test::Unit::TestSuite
  attr_accessor :tests
  
  def initialize( name, test_case )
    super( name )
    @test_case = test_case
  end
  
  def startup
  end
  
  def shutdown
  end
  
  def run( *args )
    startup
    @test_case.startup if @test_case.respond_to? :startup
    retval = super
    @test_case.shutdown if @test_case.respond_to? :shutdown
    shutdown
    retval
  end
end

module Test
  module Unit
    class TestCase
      unless respond_to? :old_suite
        class << self
          alias_method :old_suite, :suite
        end
        
        def self.suite
          os = old_suite
          sw = SuiteWrapper.new( os.name, self )
          sw.tests = os.tests
          sw
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gather-0.0.6 test/test_helper.rb
gather-0.0.4 test/test_helper.rb