Module: Assay::Adapter::TestUnit

Defined in:
lib/assay/adapter/testunit.rb

Overview

Teaches Test::Unit that any exception answering true to assertion? (the BRASS standard) is a failed assertion, not an error. Without this Test::Unit still runs tests that use Assay, but counts their failures as errors.

Loaded with require 'assay/adapter/testunit'. Needs the test-unit gem, version 3 or newer.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



16
17
18
# File 'lib/assay/adapter/testunit.rb', line 16

def self.included(base)
  base.exception_handler(:handle_brass_assertion)
end

Instance Method Details

#handle_brass_assertion(exception) ⇒ Object (private)



22
23
24
25
26
27
28
# File 'lib/assay/adapter/testunit.rb', line 22

def handle_brass_assertion(exception)
  return false if exception.is_a?(::Test::Unit::AssertionFailedError)
  return false unless exception.respond_to?(:assertion?) && exception.assertion?
  problem_occurred
  add_failure(exception.message, exception.backtrace)
  true
end