Module: Test::Unit::TestCaseOmissionSupport

Included in:
TestCase
Defined in:
lib/test/unit/omission.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



52
53
54
55
56
# File 'lib/test/unit/omission.rb', line 52

def included(base)
  base.class_eval do
    include OmissionHandler
  end
end

Instance Method Details

#omit(message = nil, &block) ⇒ Object

Omit the test of part of the test.

Example:

def test_omission
  omit
  # Not reached here
end

def test_omission_with_here
  omit do
    # Not ran here
  end
  # Reached here
end


73
74
75
76
77
78
79
80
81
# File 'lib/test/unit/omission.rb', line 73

def omit(message=nil, &block)
  message ||= "omitted."
  if block_given?
    omission = Omission.new(name, filter_backtrace(caller), message)
    add_omission(omission)
  else
    raise OmittedError.new(message)
  end
end

#omit_if(condition, *args, &block) ⇒ Object



83
84
85
# File 'lib/test/unit/omission.rb', line 83

def omit_if(condition, *args, &block)
  omit(*args, &block) if condition
end

#omit_unless(condition, *args, &block) ⇒ Object



87
88
89
# File 'lib/test/unit/omission.rb', line 87

def omit_unless(condition, *args, &block)
  omit(*args, &block) unless condition
end