Class: HtmlFormatter
Instance Attribute Summary
#exceptions, #tally, #timer
Instance Method Summary
collapse
#abort, #before, #exception?, #failure?, #initialize, #print
Instance Method Details
#after(state) ⇒ Object
53
54
55
|
# File 'lib/extensions/mspec/mspec/runner/formatters/html.rb', line 53
def after(state)
print %[<li class="pass">- #{state.it}</li>\n] unless exception?
end
|
#enter(describe) ⇒ Object
38
39
40
|
# File 'lib/extensions/mspec/mspec/runner/formatters/html.rb', line 38
def enter(describe)
print "<div><p>#{describe}</p>\n<ul>\n"
end
|
#escape(string) ⇒ Object
78
79
80
|
# File 'lib/extensions/mspec/mspec/runner/formatters/html.rb', line 78
def escape(string)
string.gsub("&", " ").gsub("<", "<").gsub(">", ">")
end
|
#exception(exception) ⇒ Object
46
47
48
49
50
51
|
# File 'lib/extensions/mspec/mspec/runner/formatters/html.rb', line 46
def exception(exception)
super
outcome = exception.failure? ? "FAILED" : "ERROR"
print %[<li class="fail">- #{exception.it} (<a href="#details-#{@count}">]
print %[#{outcome} - #{@count}</a>)</li>\n]
end
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/extensions/mspec/mspec/runner/formatters/html.rb', line 57
def finish
success = @exceptions.empty?
unless success
print "<hr>\n"
print %[<ol id="details">]
count = 0
@exceptions.each do |exc|
outcome = exc.failure? ? "FAILED" : "ERROR"
print %[\n<li id="details-#{count += 1}"><p>#{escape(exc.description)} #{outcome}</p>\n<p>]
print escape(exc.message)
print "</p>\n<pre>\n"
print escape(exc.backtrace)
print "</pre>\n</li>\n"
end
print "</ol>\n"
end
print %[<p>#{@timer.format}</p>\n]
print %[<p class="#{success ? "pass" : "fail"}">#{@tally.format}</p>\n]
print "</body>\n</html>\n"
end
|
42
43
44
|
# File 'lib/extensions/mspec/mspec/runner/formatters/html.rb', line 42
def leave
print "</ul>\n</div>\n"
end
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/extensions/mspec/mspec/runner/formatters/html.rb', line 12
def start
print <<-EOH
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Spec Output For #{RUBY_NAME} (#{RUBY_VERSION})</title>
<style type="text/css">
ul {
list-style: none;
}
.fail {
color: red;
}
.pass {
color: green;
}
#details :target {
background-color: #ffffe0;
}
</style>
</head>
<body>
EOH
end
|