Sha256: 63e6e04a5221ced07fbeefc6ccf4db81618a8d0b931f66eb212aefa3efb8bfdc

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

require 'ae'

AE.assertion_error = ::MiniTest::Assertion

module MiniTest #:nodoc:
  class Unit #:nodoc:

    # 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.
    #
    # @return [Integer] Number of assertions made.
    def assertion_count
      @assertion_count + AE::Assertor.counts[:total]
    end

    # To teach MiniTest to recognize AE's expanded concept of assertions
    # we add in an extra capture clause to it's #puke method.
    #
    # @return [String] Status code is `S`, `F`, or `E`.
    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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ae-1.8.2 lib/ae/adapters/minitest.rb
ae-1.8.1 lib/ae/adapters/minitest.rb
ae-1.8.0 lib/ae/adapters/minitest.rb