public
Description: RSpec-syntax compatible framework for RubySpecs
Homepage: http://rubyspec.org
Clone URL: git://github.com/brixen/mspec.git
Fixed spec failures for html formatter.
Brian Ford (author)
Fri May 23 22:52:37 -0700 2008
commit  9e4dd3abfbdf8f87c455414647f1070a5a6d39f5
tree    4262285222515713ec6132de5561fb23ea04dea4
parent  4218fed7333151c4fd737056aee4175a5cd1638a
...
11
12
13
14
 
15
16
17
...
11
12
13
 
14
15
16
17
0
@@ -11,7 +11,7 @@ class HtmlFormatter < DottedFormatter
0
 
0
   def start
0
     print <<-EOH
0
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
0
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
0
     "http://www.w3.org/TR/html4/strict.dtd">
0
 <html>
0
 <head>
...
31
32
33
34
 
 
 
35
36
37
 
 
38
39
40
...
44
45
46
47
 
 
 
 
48
49
50
...
105
106
107
108
 
 
 
 
109
110
111
...
121
122
123
 
 
124
125
126
...
128
129
130
131
 
132
133
134
...
136
137
138
139
 
140
141
142
...
155
156
157
158
 
159
160
161
162
163
164
165
166
 
 
 
167
168
169
...
31
32
33
 
34
35
36
37
 
 
38
39
40
41
42
...
46
47
48
 
49
50
51
52
53
54
55
...
110
111
112
 
113
114
115
116
117
118
119
...
129
130
131
132
133
134
135
136
...
138
139
140
 
141
142
143
144
...
146
147
148
 
149
150
151
152
...
165
166
167
 
168
169
170
171
172
173
174
 
 
175
176
177
178
179
180
0
@@ -31,10 +31,12 @@ describe HtmlFormatter, "#start" do
0
   it "prints the HTML head" do
0
     @formatter.start
0
     @out.should ==
0
-%[<html>
0
+%[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
0
+    "http://www.w3.org/TR/html4/strict.dtd">
0
+<html>
0
 <head>
0
-<title>Spec Output For #{RUBY_NAME} (#{RUBY_VERSION})</title>
0
-<script type="text/css">
0
+<title>Spec Output For ruby (1.8.6)</title>
0
+<style type="text/css">
0
 ul {
0
   list-style: none;
0
 }
0
@@ -44,7 +46,10 @@ ul {
0
 .pass {
0
   color: green;
0
 }
0
-</script>
0
+#details :target {
0
+  background-color: #ffffe0;
0
+}
0
+</style>
0
 </head>
0
 <body>
0
 ]
0
@@ -105,7 +110,10 @@ describe HtmlFormatter, "#after" do
0
     @state.exceptions << ["msg", MSpecExampleError.new("painful")]
0
     @formatter.tally.after @state
0
     @formatter.after @state
0
-    @out.should == %[<li class="fail">- it (FAILED - 1)</li>\n<li class="fail">- it (ERROR - 2)</li>\n]
0
+    @out.should == 
0
+%[<li class="fail">- it (<a href="#details-1">FAILED - 1</a>)</li>
0
+<li class="fail">- it (<a href="#details-2">ERROR - 2</a>)</li>
0
+]
0
   end
0
 end
0
 
0
@@ -121,6 +129,8 @@ describe HtmlFormatter, "#finish" do
0
     MSpec.stub!(:register)
0
     @formatter = HtmlFormatter.new
0
     @formatter.register
0
+    @exception = MSpecExampleError.new("broken")
0
+    @exception.stub!(:backtrace).and_return(["file.rb:1", "file.rb:2"])
0
   end
0
 
0
   after :each do
0
@@ -128,7 +138,7 @@ describe HtmlFormatter, "#finish" do
0
   end
0
 
0
   it "prints a failure message for an exception" do
0
-    @state.exceptions << ["msg", MSpecExampleError.new("broken")]
0
+    @state.exceptions << ["msg", @exception]
0
     @formatter.instance_variable_set :@states, [@state]
0
     @formatter.finish
0
     @out.should =~ %r[<p>describe it ERROR</p>]
0
@@ -136,7 +146,7 @@ describe HtmlFormatter, "#finish" do
0
 
0
   it "prints a backtrace for an exception" do
0
     @formatter.stub!(:backtrace).and_return("path/to/some/file.rb:35:in method")
0
-    @state.exceptions << ["msg", MSpecExampleError.new("broken")]
0
+    @state.exceptions << ["msg", @exception]
0
     @formatter.instance_variable_set :@states, [@state]
0
     @formatter.finish
0
     @out.should =~ %r[<pre>.*path/to/some/file.rb:35:in method.*</pre>]m
0
@@ -155,15 +165,16 @@ describe HtmlFormatter, "#finish" do
0
   end
0
 
0
   it "prints errors, backtraces, elapsed time, and tallies" do
0
-    @state.exceptions << ["msg", MSpecExampleError.new("broken")]
0
+    @state.exceptions << ["msg", @exception]
0
     @formatter.stub!(:backtrace).and_return("path/to/some/file.rb:35:in method")
0
     @timer.should_receive(:format).and_return("Finished in 2.0 seconds")
0
     @tally.should_receive(:format).and_return("1 example, 1 failures")
0
     @formatter.instance_variable_set :@states, [@state]
0
     @formatter.finish
0
     @out.should ==
0
-%[<ol>
0
-<li><p>describe it ERROR</p>
0
+%[<hr>
0
+<ol id="details">
0
+<li id="details-1"><p>describe it ERROR</p>
0
 <p>MSpecExampleError: broken</p>
0
 <pre>
0
 path/to/some/file.rb:35:in method</pre>

Comments