123456789_123456789_123456789_123456789_123456789_

Module: Test::Unit::ExceptionHandler::ClassMethods

Relationships & Source Files
Defined in: lib/test/unit/exception-handler.rb

Instance Method Summary

Instance Method Details

#exception_handler(method_name) ⇒ void #exception_handler {|test, exception| ... } ⇒ void

This is a public API for developers who extend test-unit.

[ GitHub ]

  
# File 'lib/test/unit/exception-handler.rb', line 52

def exception_handler(*method_name_or_handlers, &block)
  if block_given?
    exception_handlers.unshift(block)
  else
    method_name_or_handlers.each do |method_name_or_handler|
      if method_name_or_handler.respond_to?(:call)
        handler = method_name_or_handler
        exception_handlers.unshift(handler)
      else
        method_name = method_name_or_handler
        attribute(:exception_handler, true, {}, method_name)
      end
    end
  end
end

#exception_handlers

[ GitHub ]

  
# File 'lib/test/unit/exception-handler.rb', line 25

def exception_handlers
  ExceptionHandler.exception_handlers
end

#unregister_exception_handler(*method_name_or_handlers)

[ GitHub ]

  
# File 'lib/test/unit/exception-handler.rb', line 68

def unregister_exception_handler(*method_name_or_handlers)
  method_name_or_handlers.each do |method_name_or_handler|
    if method_name_or_handler.respond_to?(:call)
      handler = method_name_or_handler
      exception_handlers.delete(handler)
    else
      method_name = method_name_or_handler
      attribute(:exception_handler, false, {}, method_name)
    end
  end
end