Class: Turn::OutlineReporter
Overview
Outline Reporter (Turn’s Original)
– TODO: Should we fit reporter output to width of console? TODO: Running percentages? ++
Constant Summary
Constants included
from Colorize
Colorize::COLORIZE, Colorize::ERROR, Colorize::FAIL, Colorize::PASS, Colorize::SKIP
Instance Attribute Summary
Attributes inherited from Reporter
#io
Instance Method Summary
collapse
Methods inherited from Reporter
#finish_case, #initialize
Methods included from Colorize
blue, bold, error, fail, green, magenta, pass, red, skip
Constructor Details
This class inherits a constructor from Turn::Reporter
Instance Method Details
#error(exception) ⇒ Object
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/turn/reporters/outline_reporter.rb', line 71
def error(exception)
message = exception.message
backtrace = "Exception `#{exception.class}' at " + filter_backtrace(exception.backtrace).join("\n")
message = Colorize.bold(message)
io.puts("#{ERROR}")
io.puts(message.tabto(8))
io.puts "STDERR:".tabto(8)
io.puts(backtrace.tabto(8))
show_captured_output
end
|
#fail(assertion) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/turn/reporters/outline_reporter.rb', line 56
def fail(assertion)
message = assertion.message.to_s
backtrace = filter_backtrace(assertion.backtrace)
io.puts(" #{FAIL}")
io.puts Colorize.bold(message).tabto(8)
unless backtrace.empty?
backtrace = "Assertion at " + filter_backtrace(assertion.backtrace).first
io.puts "STDERR:".tabto(8)
io.puts(backtrace.tabto(8))
end
show_captured_output
end
|
#finish_suite(suite) ⇒ Object
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/turn/reporters/outline_reporter.rb', line 121
def finish_suite(suite)
total = suite.count_tests
failure = suite.count_failures
error = suite.count_errors
pass = total - failure - error
bar = '=' * 78
if COLORIZE
bar = if pass == total then Colorize.green(bar)
else Colorize.red(bar) end
end
tally = [total, suite.count_assertions]
io.puts bar
io.puts " pass: %d, fail: %d, error: %d" % [pass, failure, error]
io.puts " total: %d tests with %d assertions in #{Time.new - @time} seconds" % tally
io.puts bar
end
|
#finish_test(test) ⇒ Object
83
84
85
86
|
# File 'lib/turn/reporters/outline_reporter.rb', line 83
def finish_test(test)
$stdout = STDOUT
$stderr = STDERR
end
|
#pass(message = nil) ⇒ Object
46
47
48
49
50
51
52
53
|
# File 'lib/turn/reporters/outline_reporter.rb', line 46
def pass(message=nil)
io.puts " #{PASS}"
if message
message = Colorize.magenta(message)
message = message.to_s.tabto(8)
io.puts(message)
end
end
|
#show_captured_output ⇒ Object
89
90
91
92
|
# File 'lib/turn/reporters/outline_reporter.rb', line 89
def show_captured_output
show_captured_stdout
end
|
#show_captured_stdout ⇒ Object
95
96
97
98
99
100
101
102
|
# File 'lib/turn/reporters/outline_reporter.rb', line 95
def show_captured_stdout
@stdout.rewind
return if @stdout.eof?
STDOUT.puts(<<-output.tabto(8))
\nSTDOUT:
#{@stdout.read}
output
end
|
#start_case(kase) ⇒ Object
26
27
28
|
# File 'lib/turn/reporters/outline_reporter.rb', line 26
def start_case(kase)
io.puts(Colorize.bold("#{kase.name}"))
end
|
#start_suite(suite) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/turn/reporters/outline_reporter.rb', line 15
def start_suite(suite)
@suite = suite
@time = Time.now
@stdout = StringIO.new
@stderr = StringIO.new
io.puts "LOADED SUITE #{suite.name}"
end
|
#start_test(test) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/turn/reporters/outline_reporter.rb', line 31
def start_test(test)
io.print " %-69s" % test.name
@stdout.rewind
@stderr.rewind
$stdout = @stdout
$stderr = @stderr unless $DEBUG
end
|