Class: TapOut::Reporters::PrettyReporter
- Inherits:
-
Abstract
- Object
- Abstract
- TapOut::Reporters::PrettyReporter
show all
- Defined in:
- lib/tapout/reporters/pretty_reporter.rb
Overview
Pretty Reporter (by Paydro)
Constant Summary
collapse
- PADDING_SIZE =
4
- PASS =
"PASS".ansi(:green)
- FAIL =
"FAIL".ansi(:red)
- ERROR =
"ERROR".ansi(:yellow)
Constants inherited
from Abstract
Abstract::INTERNALS
Instance Method Summary
collapse
Methods inherited from Abstract
#<<, #clean_backtrace, #code_snippet, #complete_cases, #exit_code, #finalize, #handle, inherited, #initialize, #note, #omit, #parse_source_location, #skip, #source, #tally, #tally_message
Instance Method Details
#error(test) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/tapout/reporters/pretty_reporter.rb', line 95
def error(test)
print pad_with_size("#{ERROR}")
print " #{test['label']}"
print " (%.2fs) " % (Time.now - @test_time)
message = test['exception']['message']
if bt = test['exception']['backtrace']
_trace = clean_backtrace(bt)
else
_trace = filter_backtrace(bt)
end
trace = _trace.shift
puts
tabsize = 10
puts message.tabto(tabsize)
puts trace.tabto(tabsize)
if depth = TapOut.trace
puts _trace[0,depth].map{|l| l.tabto(tabsize) }.join("\n")
end
end
|
#fail(test) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/tapout/reporters/pretty_reporter.rb', line 67
def fail(test)
print pad_with_size("#{FAIL}")
print " #{test['label']}"
print " (%.2fs) " % (Time.now - @test_time)
message = test['exception']['message']
if bt = test['exception']['backtrace']
_trace = clean_backtrace(bt)
else
_trace = clean_backtrace(bt)
end
puts
tabsize = 10
puts message.tabto(tabsize)
puts _trace.shift.tabto(tabsize)
if depth = TapOut.trace
puts _trace[0,depth].map{|l| l.tabto(tabsize) }.join("\n")
end
end
|
#finish_case(kase) ⇒ Object
def show_captured_output
show_captured_stdout
show_captured_stderr
end
def show_captured_stdout
@stdout.rewind
return if @stdout.eof?
STDOUT.puts(<<-output.tabto(8))
\nSTDOUT:
#{@stdout.read}
output
end
def show_captured_stderr
@stderr.rewind
return if @stderr.eof?
STDOUT.puts(<<-output.tabto(8))
\nSTDERR:
#{@stderr.read}
output
end
159
160
161
162
163
|
# File 'lib/tapout/reporters/pretty_reporter.rb', line 159
def finish_case(kase)
end
|
#finish_suite(final) ⇒ Object
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/tapout/reporters/pretty_reporter.rb', line 166
def finish_suite(final)
total = final['counts']['total'] || 0
failure = final['counts']['fail'] || 0
error = final['counts']['error'] || 0
skip = final['counts']['skip'] || 0
omit = final['counts']['omit'] || 0
puts
puts "Finished in #{'%.6f' % (Time.now - @time)} seconds."
puts
print "%d tests, " % total
print ("%d failures" % failure).ansi(:red) + ', '
print ("%d errors" % error).ansi(:yellow) + ', '
print ("%d pending" % skip).ansi(:cyan)
puts
end
|
#finish_test(test) ⇒ Object
126
127
128
129
130
131
132
|
# File 'lib/tapout/reporters/pretty_reporter.rb', line 126
def finish_test(test)
puts
end
|
#pad(str, size = PADDING_SIZE) ⇒ Object
191
192
193
|
# File 'lib/tapout/reporters/pretty_reporter.rb', line 191
def pad(str, size=PADDING_SIZE)
" " * size + str
end
|
#pad_with_size(str) ⇒ Object
196
197
198
|
# File 'lib/tapout/reporters/pretty_reporter.rb', line 196
def pad_with_size(str)
" " * (18 - str.size) + str
end
|
#pass(test) ⇒ Object
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/tapout/reporters/pretty_reporter.rb', line 55
def pass(test)
print pad_with_size("#{PASS}")
print " #{test['label']}"
print " (%.2fs) " % (Time.now - @test_time)
end
|
#start_case(kase) ⇒ Object
33
34
35
36
37
|
# File 'lib/tapout/reporters/pretty_reporter.rb', line 33
def start_case(kase)
print "\n#{kase['label']}:\n"
end
|
#start_suite(suite) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/tapout/reporters/pretty_reporter.rb', line 20
def start_suite(suite)
@suite = suite
@time = Time.now
puts "Suite seed: #{suite['seed']}" if suite['seed']
puts "Started"
end
|
#start_test(test) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/tapout/reporters/pretty_reporter.rb', line 40
def start_test(test)
@test_time = Time.now
@test = test
end
|