Class: MiniTest::Unit

Inherits:
Object show all
Defined in:
lib/ae/adapters/minitest.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#assertion_countInteger

MiniTest tracks assertion counts internally in it's Unit class via the assertion_count attribute. To work with AE we need add in AE's assertion total by overriding the assertion_count method.

Returns:

  • (Integer)

    Number of assertions made.


13
14
15
# File 'lib/ae/adapters/minitest.rb', line 13

def assertion_count
  @assertion_count + AE::Assertor.counts[:total]
end

#puke(k, m, e) ⇒ String

To teach MiniTest to recognize AE's expanded concept of assertions we add in an extra capture clause to it's #puke method.

Returns:

  • (String)

    Status code is `S`, `F`, or `E`.


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ae/adapters/minitest.rb', line 21

def puke k, m, e
  case e
  when MiniTest::Skip
    @skips += 1
    return "S" unless @verbose
    e = "Skipped:\n#{m}(#{k}) [#{location e}]:\n#{e.message}\n"
  when MiniTest::Assertion
    @failures += 1
    e = "Failure:\n#{m}(#{k}) [#{location e}]:\n#{e.message}\n"
  else
    if e.respond_to?(:assertion?) && e.assertion?
      @failures += 1
      e = "Failure:\n#{m}(#{c}) [#{location e}]:\n#{e.message}\n"
    else
      @errors += 1
      b = MiniTest::filter_backtrace(e.backtrace).join "\n    "
      e = "Error:\n#{m}(#{k}):\n#{e.class}: #{e.message}\n    #{b}\n"
    end
  end
  @report << e
  e[0, 1]
end