Class: Riot::DotMatrixReporter
- Inherits:
-
IOReporter
- Object
- Reporter
- IOReporter
- Riot::DotMatrixReporter
- Defined in:
- lib/riot/reporter/dot_matrix.rb
Overview
Outputs in the dot-notion almost everyone should be familiar with, “.” implies pass, “F” implies a failure, and “E” implies an error. If ansi-coloring is available, it is used. Error and failure messages are buffered for output until the end.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Reporter
#current_context, #errors, #failures, #passes
Instance Method Summary collapse
-
#error(description, e) ⇒ Object
Prints a “E” and saves the error details (including backtrace) for the end.
-
#fail(description, message, line, file) ⇒ Object
Prints a “F” and saves the failure details (including line number and file) for the end.
-
#initialize(*args) ⇒ DotMatrixReporter
constructor
Creates a new DotMatrixReporter and initializes the failure/error details buffer.
-
#pass(description, message) ⇒ Object
Prints a “.”.
-
#results(time_taken) ⇒ Object
Called after all contexts have finished.
Methods inherited from IOReporter
#filter_backtrace, #format_error, #green, #line_info, #plain?, #print, #puts, #red, #with_color, #yellow
Methods inherited from Reporter
#describe_context, #new, #report, #success?, #summarize
Constructor Details
#initialize(*args) ⇒ DotMatrixReporter
Creates a new DotMatrixReporter and initializes the failure/error details buffer.
9 10 11 12 |
# File 'lib/riot/reporter/dot_matrix.rb', line 9 def initialize(*args) super @details = [] end |
Instance Method Details
#error(description, e) ⇒ Object
Prints a “E” and saves the error details (including backtrace) for the end. Prints in red if possible.
33 34 35 36 |
# File 'lib/riot/reporter/dot_matrix.rb', line 33 def error(description, e) print red("E") @details << "ERROR - #{test_detail(description, format_error(e))}" end |
#fail(description, message, line, file) ⇒ Object
Prints a “F” and saves the failure details (including line number and file) for the end. Prints in yellow if possible.
25 26 27 28 |
# File 'lib/riot/reporter/dot_matrix.rb', line 25 def fail(description, , line, file) print yellow("F") @details << "FAILURE - #{test_detail(description, )} #{line_info(line, file)}".strip end |
#pass(description, message) ⇒ Object
Prints a “.”. Prints in green if possible.
17 18 19 |
# File 'lib/riot/reporter/dot_matrix.rb', line 17 def pass(description, ) print green(".") end |
#results(time_taken) ⇒ Object
Called after all contexts have finished. This is where the final results can be output.
39 40 41 42 |
# File 'lib/riot/reporter/dot_matrix.rb', line 39 def results(time_taken) puts "\n#{@details.join("\n\n")}" unless @details.empty? super end |