Class: Riot::DotMatrixReporter

Inherits:
IOReporter show all
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

PrettyDotMatrixReporter

Instance Attribute Summary

Attributes inherited from Reporter

#current_context, #errors, #failures, #passes

Instance Method Summary (collapse)

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

- (DotMatrixReporter) initialize(*args)

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

- (Object) error(description, e)

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

- (Object) fail(description, message, line, file)

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, message, line, file)
  print yellow("F")
  @details << "FAILURE - #{test_detail(description, message)} #{line_info(line, file)}".strip
end

- (Object) pass(description, message)

Prints a “.”. Prints in green if possible.



17
18
19
# File 'lib/riot/reporter/dot_matrix.rb', line 17

def pass(description, message)
  print green(".")
end

- (Object) results(time_taken)

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