Class: Riot::IOReporter

Inherits:
Reporter show all
Defined in:
lib/riot/reporter.rb

Overview

Reporter

Direct Known Subclasses

DotMatrixReporter, StoryReporter

Instance Attribute Summary

Attributes inherited from Reporter

#current_context, #errors, #failures, #passes

Instance Method Summary collapse

Methods inherited from Reporter

#describe_context, #error, #fail, #new, #pass, #report, #success?, #summarize

Constructor Details

#initialize(writer = STDOUT) ⇒ IOReporter

Returns a new instance of IOReporter.



45
46
47
48
# File 'lib/riot/reporter.rb', line 45

def initialize(writer=STDOUT)
  super()
  @writer = writer
end

Instance Method Details

#format_error(e) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/riot/reporter.rb', line 61

def format_error(e)
  format = []
  format << "    #{e.class.name} occurred"
  format << "#{e.to_s}"
  filter_backtrace(e.backtrace) { |line| format << "      at #{line}" }

  format.join("\n")
end

#line_info(line, file) ⇒ Object



52
53
54
# File 'lib/riot/reporter.rb', line 52

def line_info(line, file)
  line ? "(on line #{line} in #{file})" : ""
end


50
# File 'lib/riot/reporter.rb', line 50

def print(message) @writer.print(message); end

#puts(message) ⇒ Object



49
# File 'lib/riot/reporter.rb', line 49

def puts(message) @writer.puts(message); end

#results(time_taken) ⇒ Object



56
57
58
59
# File 'lib/riot/reporter.rb', line 56

def results(time_taken)
  values = [passes, failures, errors, ("%0.6f" % time_taken)]
  puts "\n%d passes, %d failures, %d errors in %s seconds" % values
end