Sha256: 1c2ec1ee9c0c9f6a2aa51a00578c9b589f6ae868329030f745fe9116a54b980b

Contents?: true

Size: 925 Bytes

Versions: 13

Compression:

Stored size: 925 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| r.instance_of?(Minitest::Assertion) }.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| r.instance_of?(Minitest::UnexpectedError) }
  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

13 entries across 13 versions & 2 rubygems

Version Path
mocha-1.11.2 test/minitest_result.rb
mocha-1.11.1 test/minitest_result.rb
mocha-1.11.0 test/minitest_result.rb
mocha-1.10.2 test/minitest_result.rb
mocha-1.10.1 test/minitest_result.rb
mocha-1.10.0 test/minitest_result.rb
mocha-1.10.0.beta.1 test/minitest_result.rb
mocha-1.10.0.alpha test/minitest_result.rb
mocha-1.9.0 test/minitest_result.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/mocha-1.8.0/test/minitest_result.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/mocha-1.8.0/test/minitest_result.rb
mocha-1.8.0 test/minitest_result.rb
mocha-1.7.0 test/minitest_result.rb