lib/tap/test.rb in bahuvrihi-tap-0.11.1 vs lib/tap/test.rb in bahuvrihi-tap-0.11.2

- old
+ new

@@ -1,64 +1,69 @@ -require 'test/unit' $:.unshift File.expand_path("#{File.dirname(__FILE__)}/..") require 'tap/test/extensions' +require 'test/unit' -module Test # :nodoc: - module Unit # :nodoc: - - # Methods extending TestCase. For more information see: - # - 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. - attr_accessor :run_test_suite - - # An array of messages printed when a test is skipped - # by setting run_test_suite to false. - attr_reader :skip_messages +# Methods extending TestCase. For more information see: +# - Tap::Test::SubsetTest +# - Tap::Test::FileTest +# - Tap::Test::TapTest +# +#-- +#See the TestTutorial for more information. +class Test::Unit::TestCase + extend Tap::Test::Extensions - # Causes a test suite to be skipped. If a message is given, it will - # print and notify the user the test suite has been skipped. - def skip_test(msg=nil) - self.run_test_suite = false + class << self + # Causes a test suite to be skipped. If a message is given, it will + # print and notify the user the test suite has been skipped. + def skip_test(msg=nil) + @@test_suites.delete(self) + puts "Skipping #{self}#{msg.empty? ? '' : ': ' + msg}" + end + end +end - # experimental -- perhaps use this so that a test can be skipped - # for multiple reasons? - skip_messages << msg - end +# :stopdoc: +class Test::Unit::TestCase + 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. + attr_accessor :run_test_suite + + # An array of messages printed when a test is skipped + # by setting run_test_suite to false. + attr_reader :skip_messages + + undef_method :skip_test + + def skip_test(msg=nil) + self.run_test_suite = false + skip_messages << msg + end + + alias :original_suite :suite - alias :original_suite :suite + # Modifies the default suite method to skip the suit unless + # run_test_suite is true. If the test is skipped, the skip_messages + # will be printed along with the default 'Skipping <Test>' message. + def suite # :nodoc: + if run_test_suite + original_suite + else + skip_message = skip_messages.compact.join(', ') + puts "Skipping #{name}#{skip_message.empty? ? '' : ': ' + skip_message}" - # Modifies the default suite method to skip the suit unless - # run_test_suite is true. If the test is skipped, the skip_messages - # will be printed along with the default 'Skipping <Test>' message. - def suite # :nodoc: - if run_test_suite - original_suite - else - skip_message = skip_messages.compact.join(', ') - puts "Skipping #{name}#{skip_message.empty? ? '' : ': ' + skip_message}" - - # return an empty test suite of the appropriate name - Test::Unit::TestSuite.new(name) - end - end + # return an empty test suite of the appropriate name + Test::Unit::TestSuite.new(name) end end end -end +end unless Object.const_defined?(:MiniTest) +# :startdoc: \ No newline at end of file