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, #new, #report, #success?, #summarize

Constructor Details

#initialize(writer = STDOUT) ⇒ IOReporter

Returns a new instance of IOReporter.



41
42
43
44
# File 'lib/riot/reporter.rb', line 41

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

Instance Method Details

#format_error(e) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/riot/reporter.rb', line 57

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

  format.join("\n")
end

#line_info(line, file) ⇒ Object



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

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


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

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

#puts(message) ⇒ Object



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

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

#results(time_taken) ⇒ Object



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

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