Class: Asciidoctor::DocTest::TestReporter

Inherits:
Minitest::StatisticsReporter
  • Object
show all
Defined in:
lib/asciidoctor/doctest/test_reporter.rb

Overview

This class is responsible for printing a formatted output of the test run.

Instance Method Summary collapse

Instance Method Details

#passesInteger

Returns number of passed tests (examples).

Returns:

  • (Integer)

    number of passed tests (examples).


85
86
87
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 85

def passes
  count - failures - errors - skips
end

#record(result) ⇒ void

Note:

Overrides method from Minitest::StatisticsReporter.

Parameters:

  • result (Minitest::Test)

    a single test result.


28
29
30
31
32
33
34
35
36
37
38
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 28

def record(result)
  result.extend ResultExt

  if verbose?
    io.puts [ result.symbol.color(result.color), result.name ].join('  ')
  else
    io.print result.result_code.color(result.color)
  end

  super
end

#reportvoid

Note:

Overrides method from Minitest::StatisticsReporter.

Outputs the summary of the run.


43
44
45
46
47
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 43

def report
  super
  io.puts unless verbose? # finish the dots
  io.puts ['', aggregated_results, summary, ''].compact.join("\n")
end

#startvoid

Note:

Overrides method from Minitest::StatisticsReporter.


20
21
22
23
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 20

def start
  super
  io.puts "\n" + (options[:title] || 'Running DocTest:') + "\n\n"
end

#verbose?Boolean

Returns whether verbose mode is enabled.

Returns:

  • (Boolean)

    whether verbose mode is enabled.


91
92
93
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 91

def verbose?
  !!options[:verbose]
end