Class: Turn::CueReporter
Overview
Cue Reporter
Inspired by Shindo.
Constant Summary
Constants included
from Colorize
Turn::Colorize::COLORIZE, Turn::Colorize::ERROR, Turn::Colorize::FAIL, Turn::Colorize::PASS, Turn::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, 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/turn/reporters/cue_reporter.rb', line 101
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
70
71
72
73
|
# File 'lib/turn/reporters/cue_reporter.rb', line 70
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
75
76
77
78
|
# File 'lib/turn/reporters/cue_reporter.rb', line 75
def show_captured_output
show_captured_stdout
show_captured_stderr
end
|
#show_captured_stderr ⇒ Object
89
90
91
92
93
94
95
96
|
# File 'lib/turn/reporters/cue_reporter.rb', line 89
def show_captured_stderr
@stderr.rewind
return if @stderr.eof?
STDOUT.puts(<<-output.tabto(8))
\nSTDERR:
#{@stderr.read}
output
end
|
#show_captured_stdout ⇒ Object
80
81
82
83
84
85
86
87
|
# File 'lib/turn/reporters/cue_reporter.rb', line 80
def show_captured_stdout
@stdout.rewind
return if @stdout.eof?
STDOUT.puts(<<-output.tabto(8))
\nSTDOUT:
#{@stdout.read}
output
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
|