Module: Mocha::Integration::TestUnit::RubyVersion186AndAbove

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



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

def self.included(mod)
  warn "Monkey patching Test::Unit for Ruby >= v1.8.6"
end

Instance Method Details

#run(result) {|Test::Unit::TestCase::STARTED, name| ... } ⇒ Object

Yields:

  • (Test::Unit::TestCase::STARTED, name)


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
46
# File 'lib/mocha/integration/test_unit/ruby_version_186_and_above.rb', line 15

def run(result)
  assertion_counter = AssertionCounter.new(result)
  yield(Test::Unit::TestCase::STARTED, name)
  @_result = result
  begin
    begin
      setup
      __send__(@method_name)
      mocha_verify(assertion_counter)
    rescue Mocha::ExpectationError => e
      add_failure(e.message, e.backtrace)
    rescue Test::Unit::AssertionFailedError => e
      add_failure(e.message, e.backtrace)
    rescue Exception
      raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
      add_error($!)
    ensure
      begin
        teardown
      rescue Test::Unit::AssertionFailedError => e
        add_failure(e.message, e.backtrace)
      rescue Exception
        raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
        add_error($!)
      end
    end
  ensure
    mocha_teardown
  end
  result.add_run
  yield(Test::Unit::TestCase::FINISHED, name)
end