Class: QED::Reporter::Verbatim
Overview
Verbose ANSI Console Reporter
Constant Summary
Constants inherited
from Abstract
Abstract::INFO_SIGNAL
Instance Attribute Summary
Attributes inherited from Abstract
#io, #record, #session
Instance Method Summary
collapse
Methods inherited from Abstract
After, Before, When, #after_demo, #after_eval, #after_import, #after_proc, #after_step, #before_demo, #before_eval, #before_import, #before_proc, #before_step, #call, #count_demo, #count_error, #count_fail, #count_pass, #count_step, #demo, #demos, #errors, #eval, #fails, #import, #initialize, #omits, #passes, #proc, #rule, #steps, #success?, #trace?
Instance Method Details
#after_session(session) ⇒ Object
136
137
138
139
140
|
# File 'lib/qed/reporter/verbatim.rb', line 136
def after_session(session)
trap 'INFO', 'DEFAULT' if INFO_SIGNAL
print_time
print_tally
end
|
#applique(step) ⇒ Object
32
33
34
35
|
# File 'lib/qed/reporter/verbatim.rb', line 32
def applique(step)
io.print "#{@_explain}".ansi(:cyan)
io.print "#{step.example}"
end
|
#before_session(session) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/qed/reporter/verbatim.rb', line 11
def before_session(session)
@start_time = Time.now
trap "INFO" do
print_time
print_tally
end if INFO_SIGNAL
end
|
#error(step, error) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/qed/reporter/verbatim.rb', line 93
def error(step, error)
super(step, error)
raise error if $DEBUG
tab = step.text.index(/\S/)
if step.heading?
if step.code?
io.print "#{@_explain}".ansi(:bold, :magenta)
else
io.print "#{@_explain}".ansi(:bold)
end
else
io.print "#{@_explain}".ansi(:magenta)
end
if step.has_example?
if step.data?
io.print "#{step.example}".ansi(:red)
else
io.print "#{step.example}".ansi(:red)
end
end
msg = []
msg << "ERROR: #{error.class} ".ansi(:bold,:red) + error.message
msg << sane_backtrace(error).join("\n").ansi(:bold)
msg = msg.join("\n")
io.puts msg.tabto(tab||2)
io.puts
end
|
#fail(step, error) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/qed/reporter/verbatim.rb', line 60
def fail(step, error)
super(step, error)
tab = step.text.index(/\S/)
if step.heading?
if step.code?
io.print "#{@_explain}".ansi(:bold, :magenta)
else
io.print "#{@_explain}".ansi(:bold)
end
else
io.print "#{@_explain}".ansi(:magenta)
end
if step.has_example?
if step.data?
io.print "#{step.example}".ansi(:red)
else
io.print "#{step.example}".ansi(:red)
end
end
msg = []
msg << "FAIL: ".ansi(:bold, :red) + error.message.to_s
msg << sane_backtrace(error).join("\n").ansi(:bold)
msg = msg.join("\n")
io.puts msg.tabto(tab||2)
io.puts
end
|
#match(step, md) ⇒ Object
25
26
27
28
29
|
# File 'lib/qed/reporter/verbatim.rb', line 25
def match(step, md)
unless md[0].empty?
@_explain.sub!(md[0], md[0].ansi(:bold))
end
end
|
#pass(step) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/qed/reporter/verbatim.rb', line 38
def pass(step)
super(step)
if step.heading?
if step.code?
io.print "#{@_explain}".ansi(:bold, :cyan)
else
io.print "#{@_explain}".ansi(:bold)
end
else
io.print "#{@_explain}".ansi(:cyan)
end
if step.has_example?
if step.data?
io.print "#{step.example}"
else
io.print "#{step.example}".ansi(:green)
end
end
end
|
#step(step) ⇒ Object
20
21
22
|
# File 'lib/qed/reporter/verbatim.rb', line 20
def step(step)
@_explain = step.explain.dup
end
|