Methods
Constants
| PASSTHROUGH_EXCEPTIONS | = | Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS rescue [NoMemoryError, SignalException, Interrupt, SystemExit] |
| For compatibility with Ruby < 1.8.6 | ||
Public Instance methods
This redefinition is unfortunate but test/unit shows us no alternative. Doubly unfortunate: hax to support Mocha‘s hax.
[ show source ]
# File activesupport/lib/active_support/testing/setup_and_teardown.rb, line 44
44: def run(result)
45: return if @method_name.to_s == "default_test"
46:
47: if using_mocha = respond_to?(:mocha_verify)
48: assertion_counter_klass = if defined?(Mocha::TestCaseAdapter::AssertionCounter)
49: Mocha::TestCaseAdapter::AssertionCounter
50: else
51: Mocha::Integration::TestUnit::AssertionCounter
52: end
53: assertion_counter = assertion_counter_klass.new(result)
54: end
55:
56: yield(Test::Unit::TestCase::STARTED, name)
57: @_result = result
58: begin
59: begin
60: run_callbacks :setup
61: setup
62: __send__(@method_name)
63: mocha_verify(assertion_counter) if using_mocha
64: rescue Mocha::ExpectationError => e
65: add_failure(e.message, e.backtrace)
66: rescue Test::Unit::AssertionFailedError => e
67: add_failure(e.message, e.backtrace)
68: rescue Exception => e
69: raise if PASSTHROUGH_EXCEPTIONS.include?(e.class)
70: add_error(e)
71: ensure
72: begin
73: teardown
74: run_callbacks :teardown, :enumerator => :reverse_each
75: rescue Test::Unit::AssertionFailedError => e
76: add_failure(e.message, e.backtrace)
77: rescue Exception => e
78: raise if PASSTHROUGH_EXCEPTIONS.include?(e.class)
79: add_error(e)
80: end
81: end
82: ensure
83: mocha_teardown if using_mocha
84: end
85: result.add_run
86: yield(Test::Unit::TestCase::FINISHED, name)
87: end