Class: Turn::CueReporter
Overview
Cue Reporter
Inspired by Shindo.
Constant Summary
Constants included
from Colorize
Turn::Colorize::COLORLESS_TERMINALS
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, color_supported?, colorize?, #colorize?, error, fail, green, included, magenta, pass, red, skip
Constructor Details
This class inherits a constructor from Turn::Reporter
Instance Method Details
#error(exception, message = nil) ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'lib/turn/reporters/cue_reporter.rb', line 61
def error(exception, message=nil)
message = message || exception.to_s
io.puts("#{ERROR}")
io.puts(message)
prompt
end
|
#fail(assertion, message = nil) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/turn/reporters/cue_reporter.rb', line 46
def fail(assertion, message=nil)
io.puts(" #{FAIL}")
message = message || assertion.to_s
message = Colorize.red(message)
message = message.to_s.tabto(8)
io.puts(message)
show_captured_output
prompt
end
|
#finish_suite(suite) ⇒ Object
def finish_case(kase) end
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/turn/reporters/cue_reporter.rb', line 110
def finish_suite(suite)
total = suite.count_tests
passes = suite.count_passes
assertions = suite.count_assertions
failures = suite.count_failures
errors = suite.count_errors
skips = suite.count_skips
bar = '=' * 78
if colorize?
bar = if pass == total then Colorize.green(bar)
else Colorize.red(bar) end
end
tally = [total, assertions, (Time.new - @time)]
io.puts bar
io.puts " pass: %d, fail: %d, error: %d, skip: %d" % [passes, failures, errors, skips]
io.puts " total: %d tests with %d assertions in %f seconds" % tally
io.puts bar
end
|
#finish_test(test) ⇒ Object
79
80
81
82
|
# File 'lib/turn/reporters/cue_reporter.rb', line 79
def finish_test(test)
$stdout = STDOUT
$stderr = STDERR
end
|
#pass(message = nil) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/turn/reporters/cue_reporter.rb', line 37
def pass(message=nil)
io.puts " #{PASS}"
if message
message = Colorize.green(message)
message = message.to_s.tabto(8)
io.puts(message)
end
end
|
#show_captured_output ⇒ Object
84
85
86
87
|
# File 'lib/turn/reporters/cue_reporter.rb', line 84
def show_captured_output
show_captured_stdout
show_captured_stderr
end
|
#show_captured_stderr ⇒ Object
98
99
100
101
102
103
104
105
|
# File 'lib/turn/reporters/cue_reporter.rb', line 98
def show_captured_stderr
@stderr.rewind
return if @stderr.eof?
STDOUT.puts(<<-output.tabto(8))
\nSTDERR:
#{@stderr.read}
output
end
|
#show_captured_stdout ⇒ Object
89
90
91
92
93
94
95
96
|
# File 'lib/turn/reporters/cue_reporter.rb', line 89
def show_captured_stdout
@stdout.rewind
return if @stdout.eof?
STDOUT.puts(<<-output.tabto(8))
\nSTDOUT:
#{@stdout.read}
output
end
|
#skip(exception, message = nil) ⇒ Object
70
71
72
73
74
75
76
|
# File 'lib/turn/reporters/cue_reporter.rb', line 70
def skip(exception, message=nil)
message = message || exception.to_s
io.puts("#{SKIP}")
io.puts(message)
end
|
#start_case(kase) ⇒ Object
21
22
23
|
# File 'lib/turn/reporters/cue_reporter.rb', line 21
def start_case(kase)
io.puts(kase.name)
end
|
#start_suite(suite) ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/turn/reporters/cue_reporter.rb', line 11
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
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/turn/reporters/cue_reporter.rb', line 25
def start_test(test)
io.print Colorize.blue(" %-69s" % test.name)
$stdout = @stdout
$stderr = @stderr
$stdout.rewind
$stderr.rewind
end
|