Module: Mocha::Integration::TestUnit::GemVersion203To207

Included in:
Test::Unit::TestCase
Defined in:
lib/mocha/integration/test_unit/gem_version_203_to_207.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



12
13
14
# File 'lib/mocha/integration/test_unit/gem_version_203_to_207.rb', line 12

def self.included(mod)
  warn "Monkey patching Test::Unit gem >= v2.0.3 and <= v2.0.7"
end

Instance Method Details

#run(result) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/mocha/integration/test_unit/gem_version_203_to_207.rb', line 15

def run(result)
  assertion_counter = AssertionCounter.new(result)
  begin
    @_result = result
    yield(Test::Unit::TestCase::STARTED, name)
    begin
      begin
        run_setup
        run_test
        mocha_verify(assertion_counter)
      rescue Mocha::ExpectationError => e
        add_failure(e.message, e.backtrace)
      rescue Exception
        @interrupted = true
        raise unless handle_exception($!)
      ensure
        begin
          run_teardown
        rescue Exception
          raise unless handle_exception($!)
        end
      end
    ensure
      mocha_teardown
    end
    result.add_run
    yield(Test::Unit::TestCase::FINISHED, name)
  ensure
    # @_result = nil # For test-spec's after_all :<
  end
end