Sha256: c91a5b5316a8a7176c210fe8ca95e5cb4da7a1041a3f84cfb8b4542f2de1d61e

Contents?: true

Size: 906 Bytes

Versions: 11

Compression:

Stored size: 906 Bytes

Contents

require 'forwardable'

class MinitestResult

  class Failure
    extend Forwardable
    def_delegators :@failure, :message, :backtrace

    def initialize(failure)
      @failure = failure
    end

    def location
      Minitest.filter_backtrace(backtrace)
    end
  end

  def initialize(tests)
    @tests = tests
  end

  def failures
    @tests.map(&:failures).flatten.select { |r| Minitest::Assertion === r }.map { |f| Failure.new(f) }
  end

  def failure_count
    failures.length
  end

  def failure_message_lines
    failures.map { |f| f.message.split("\n") }.flatten
  end

  def errors
    @tests.map(&:failures).flatten.select { |r| Minitest::UnexpectedError === r }
  end

  def error_count
    errors.length
  end

  def error_messages
    errors.map { |e| e.message.split("\n") }.flatten
  end

  def assertion_count
    @tests.inject(0) { |total, test| total + test.assertions }
  end
end

Version data entries

11 entries across 8 versions & 4 rubygems

Version Path
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/test/minitest_result.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/test/minitest_result.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/test/minitest_result.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/test/minitest_result.rb
mocha-1.1.0 test/minitest_result.rb
mocha-1.0.0 test/minitest_result.rb
mocha-1.0.0.alpha test/minitest_result.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/minitest_result.rb
challah-1.0.0 vendor/bundle/gems/mocha-0.14.0/test/minitest_result.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/test/minitest_result.rb
mocha-0.14.0 test/minitest_result.rb