lib/tap/test.rb in bahuvrihi-tap-0.10.6 vs lib/tap/test.rb in bahuvrihi-tap-0.10.7
- old
+ new
@@ -1,22 +1,28 @@
require 'test/unit'
$:.unshift File.expand_path("#{File.dirname(__FILE__)}/..")
+require 'tap/test/extensions'
module Test # :nodoc:
module Unit # :nodoc:
# Methods extending TestCase. For more information see:
- # - Tap::Test::SubsetMethods
- # - Tap::Test::FileMethods
- # - Tap::Test::TapMethods
+ # - Tap::Test::SubsetTest
+ # - Tap::Test::FileTest
+ # - Tap::Test::TapTest
#
#--
#See the TestTutorial for more information.
class TestCase
+ extend Tap::Test::Extensions
+
class << self
+ alias tap_original_test_case_inherited inherited
def inherited(child)
+ super
+ tap_original_test_case_inherited(child)
child.instance_variable_set(:@skip_messages, [])
child.instance_variable_set(:@run_test_suite, true)
end
# Indicates when the test suite should be run or skipped.
@@ -50,88 +56,9 @@
# return an empty test suite of the appropriate name
Test::Unit::TestSuite.new(name)
end
end
-
- # Causes a TestCase to act as a file test, by including FileMethods and
- # instantiating class_test_root (a Tap::Root). The root and directories
- # used by class_test_root may be specified as options.
- #
- # Note: by default acts_as_file_test determines a root directory
- # <em>based on the calling file</em>. Be sure to specify the root
- # directory manually if you call acts_as_file_test from a file that
- # isn't the test file.
- def acts_as_file_test(options={})
- include Tap::Test::FileMethods
-
- options = {
- :root => test_root_dir,
- :directories => {
- :input => 'input',
- :output => 'output',
- :expected => 'expected'}
- }.merge(options)
-
- self.class_test_root = Tap::Root.new(options[:root], options[:directories])
- end
-
- # Causes a unit test to act as a tap test -- resulting in the following:
- # - setup using acts_as_file_test
- # - inclusion of Tap::Test::SubsetMethods
- # - inclusion of Tap::Test::InstanceMethods
- #
- # Note: by default acts_as_tap_test determines a root directory
- # <em>based on the calling file</em>. Be sure to specify the root
- # directory manually if you call acts_as_file_test from a file that
- # isn't the test file.
- def acts_as_tap_test(options={})
- include Tap::Test::SubsetMethods
- include Tap::Test::FileMethods
- include Tap::Test::TapMethods
-
- acts_as_file_test({:root => test_root_dir}.merge(options))
- end
-
- def acts_as_script_test(options={})
- include Tap::Test::FileMethods
- include Tap::Test::ScriptMethods
-
- acts_as_file_test({:root => test_root_dir}.merge(options))
- end
-
- private
-
- # Infers the test root directory from the calling file.
- # 'some_class.rb' => 'some_class'
- # 'some_class_test.rb' => 'some_class'
- def test_root_dir # :nodoc:
- # caller[1] is considered the calling file (which should be the test case)
- # note that the output of calller.first is like:
- # ./path/to/file.rb:10
- # ./path/to/file.rb:10:in 'method'
- calling_file = caller[1].gsub(/:\d+(:in .*)?$/, "")
- calling_file.chomp(File.extname(calling_file)).chomp("_test")
- end
-
end
end
end
end
-
-module Tap
-
- # Modules facilitating testing. TapMethods are specific to
- # Tap, but SubsetMethods and FileMethods are more general in
- # their utility.
- module Test
- autoload(:SubsetMethods, 'tap/test/subset_methods')
- autoload(:FileMethods, 'tap/test/file_methods')
- autoload(:TapMethods, 'tap/test/tap_methods')
- autoload(:ScriptMethods, 'tap/test/script_methods')
- autoload(:Utils, 'tap/test/utils')
- end
-end
-
-
-
-