Class: Test::Unit::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/linecook/test/shim.rb,
lib/linecook/test/shim.rb

Overview

Test::Unit shims (< ruby 1.9)

:stopdoc: Implementing skip_test in the original Test::Unit is considerably more tricky than in the Mini::Test Test::Unit.

Class Method Summary collapse

Class Method Details

.inherited(child) ⇒ Object



38
39
40
41
42
43
# File 'lib/linecook/test/shim.rb', line 38

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

.original_suiteObject



52
# File 'lib/linecook/test/shim.rb', line 52

alias :original_suite :suite

.skip_test(msg = nil) ⇒ Object

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.



12
13
14
15
# File 'lib/linecook/test/shim.rb', line 12

def skip_test(msg=nil)
  @@test_suites.delete(self)
  puts "Skipping #{self}#{msg.empty? ? '' : ': ' + msg}"
end

.suiteObject

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.



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/linecook/test/shim.rb', line 57

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

.tap_original_test_case_inheritedObject



36
# File 'lib/linecook/test/shim.rb', line 36

alias tap_original_test_case_inherited inherited