123456789_123456789_123456789_123456789_123456789_

Module: Test::Unit::TestCaseOmissionSupport

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/test/unit/omission.rb

Class Method Summary

Instance Method Summary

Class Method Details

.included(base)

[ GitHub ]

  
# File 'lib/test/unit/omission.rb', line 58

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

Instance Method Details

#add_omission(omission) (private)

[ GitHub ]

  
# File 'lib/test/unit/omission.rb', line 146

def add_omission(omission)
  current_result.add_omission(omission)
end

#omit(message = nil, &block)

Omit the test or 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
[ GitHub ]

  
# File 'lib/test/unit/omission.rb', line 80

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

#omit_if(condition, *args, &block)

Omit the test or part of the test if condition is true.

Example:

def test_omission
  omit_if("".empty?)
  # Not reached here
end

def test_omission_with_here
  omit_if(true) do
    # Not ran here
  end
  omit_if(false) do
    # Reached here
  end
  # Reached here too
end
[ GitHub ]

  
# File 'lib/test/unit/omission.rb', line 110

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

#omit_unless(condition, *args, &block)

Omit the test or part of the test if condition is not true.

Example:

def test_omission
  omit_unless("string".empty?)
  # Not reached here
end

def test_omission_with_here
  omit_unless(true) do
    # Reached here
  end
  omit_unless(false) do
    # Not ran here
  end
  # Reached here too
end
[ GitHub ]

  
# File 'lib/test/unit/omission.rb', line 137

def omit_unless(condition, *args, &block)
  if condition
    block.call if block
  else
    omit(*args, &block)
  end
end