mspec 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/mspec/runner/actions/tag.rb +41 -7
- data/lib/mspec/runner/actions/tally.rb +16 -7
- data/lib/mspec/runner/{state.rb → context.rb} +22 -54
- data/lib/mspec/runner/example.rb +37 -0
- data/lib/mspec/runner/exception.rb +39 -0
- data/lib/mspec/runner/formatters/dotted.rb +61 -45
- data/lib/mspec/runner/formatters/html.rb +16 -22
- data/lib/mspec/runner/formatters/specdoc.rb +24 -11
- data/lib/mspec/runner/formatters/spinner.rb +20 -10
- data/lib/mspec/runner/formatters/summary.rb +4 -1
- data/lib/mspec/runner/formatters/unit.rb +5 -9
- data/lib/mspec/runner/formatters/yaml.rb +11 -10
- data/lib/mspec/runner/mspec.rb +15 -16
- data/lib/mspec/version.rb +1 -1
- data/spec/runner/actions/debug_spec.rb +2 -2
- data/spec/runner/actions/gdb_spec.rb +2 -2
- data/spec/runner/actions/tag_spec.rb +76 -22
- data/spec/runner/actions/tally_spec.rb +26 -6
- data/spec/runner/{state_spec.rb → context_spec.rb} +80 -167
- data/spec/runner/example_spec.rb +96 -0
- data/spec/runner/exception_spec.rb +110 -0
- data/spec/runner/formatters/dotted_spec.rb +117 -27
- data/spec/runner/formatters/html_spec.rb +44 -21
- data/spec/runner/formatters/specdoc_spec.rb +52 -12
- data/spec/runner/formatters/spinner_spec.rb +2 -2
- data/spec/runner/formatters/summary_spec.rb +7 -11
- data/spec/runner/formatters/unit_spec.rb +12 -11
- data/spec/runner/formatters/yaml_spec.rb +7 -6
- data/spec/runner/mspec_spec.rb +28 -29
- metadata +7 -3
@@ -0,0 +1,96 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'mspec/matchers/base'
|
3
|
+
require 'mspec/runner/mspec'
|
4
|
+
require 'mspec/mocks/mock'
|
5
|
+
require 'mspec/runner/example'
|
6
|
+
|
7
|
+
describe ExampleState do
|
8
|
+
it "is initialized with the describe and it strings" do
|
9
|
+
ExampleState.new("This", "does").should be_kind_of(ExampleState)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ExampleState, "#describe" do
|
14
|
+
before :each do
|
15
|
+
@state = ExampleState.new("describe", "it")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns the arguments to the #describe block stringified and concatenated" do
|
19
|
+
@state.describe.should == "describe"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ExampleState, "#it" do
|
24
|
+
before :each do
|
25
|
+
@state = ExampleState.new("describe", "it")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns the argument to the #it block" do
|
29
|
+
@state.it.should == "it"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ExampleState, "#unfiltered?" do
|
34
|
+
before :each do
|
35
|
+
MSpec.store :include, nil
|
36
|
+
MSpec.store :exclude, nil
|
37
|
+
|
38
|
+
@state = ExampleState.new("describe", "it")
|
39
|
+
@filter = mock("filter")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns true if MSpec include filters list is empty" do
|
43
|
+
@state.unfiltered?.should == true
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns true if MSpec include filters match this spec" do
|
47
|
+
@filter.should_receive(:===).and_return(true)
|
48
|
+
MSpec.register :include, @filter
|
49
|
+
@state.unfiltered?.should == true
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns false if MSpec include filters do not match this spec" do
|
53
|
+
@filter.should_receive(:===).and_return(false)
|
54
|
+
MSpec.register :include, @filter
|
55
|
+
@state.unfiltered?.should == false
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns true if MSpec exclude filters list is empty" do
|
59
|
+
@state.unfiltered?.should == true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns true if MSpec exclude filters do not match this spec" do
|
63
|
+
@filter.should_receive(:===).and_return(false)
|
64
|
+
MSpec.register :exclude, @filter
|
65
|
+
@state.unfiltered?.should == true
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns false if MSpec exclude filters match this spec" do
|
69
|
+
@filter.should_receive(:===).and_return(true)
|
70
|
+
MSpec.register :exclude, @filter
|
71
|
+
@state.unfiltered?.should == false
|
72
|
+
end
|
73
|
+
|
74
|
+
it "returns false if MSpec include and exclude filters match this spec" do
|
75
|
+
@filter.should_receive(:===).twice.and_return(true)
|
76
|
+
MSpec.register :include, @filter
|
77
|
+
MSpec.register :exclude, @filter
|
78
|
+
@state.unfiltered?.should == false
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe ExampleState, "#filtered?" do
|
83
|
+
before :each do
|
84
|
+
@state = ExampleState.new("describe", "it")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "returns true if #unfiltered returns false" do
|
88
|
+
@state.should_receive(:unfiltered?).and_return(false)
|
89
|
+
@state.filtered?.should == true
|
90
|
+
end
|
91
|
+
|
92
|
+
it "returns false if #unfiltered returns true" do
|
93
|
+
@state.should_receive(:unfiltered?).and_return(true)
|
94
|
+
@state.filtered?.should == false
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'mspec/expectations/expectations'
|
3
|
+
require 'mspec/runner/example'
|
4
|
+
require 'mspec/runner/exception'
|
5
|
+
|
6
|
+
describe ExceptionState, "#initialize" do
|
7
|
+
it "takes a state, location (e.g. before :each), and exception" do
|
8
|
+
state = ExampleState.new "Class#method", "does something"
|
9
|
+
exc = Exception.new "Fail!"
|
10
|
+
ExceptionState.new(state, "location", exc).should be_kind_of(ExceptionState)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ExceptionState, "#description" do
|
15
|
+
before :each do
|
16
|
+
@state = ExampleState.new "Class#method", "does something"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns the state description if state was not nil" do
|
20
|
+
exc = ExceptionState.new(@state, nil, nil)
|
21
|
+
exc.description.should == "Class#method does something"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns the location if it is not nil and description is nil" do
|
25
|
+
exc = ExceptionState.new(nil, "location", nil)
|
26
|
+
exc.description.should == "An exception occurred during: location"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns both description and location if neither are nil" do
|
30
|
+
exc = ExceptionState.new(@state, "location", nil)
|
31
|
+
exc.description.should == "An exception occurred during: location\nClass#method does something"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ExceptionState, "#describe" do
|
36
|
+
before :each do
|
37
|
+
@state = ExampleState.new "Class#method", "does something"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns the ExampleState#describe string if created with a non-nil state" do
|
41
|
+
ExceptionState.new(@state, nil, nil).describe.should == @state.describe
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns an empty string if created with a nil state" do
|
45
|
+
ExceptionState.new(nil, nil, nil).describe.should == ""
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ExceptionState, "#it" do
|
50
|
+
before :each do
|
51
|
+
@state = ExampleState.new "Class#method", "does something"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns the ExampleState#it string if created with a non-nil state" do
|
55
|
+
ExceptionState.new(@state, nil, nil).it.should == @state.it
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns an empty string if created with a nil state" do
|
59
|
+
ExceptionState.new(nil, nil, nil).it.should == ""
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe ExceptionState, "#failure?" do
|
64
|
+
before :each do
|
65
|
+
@state = ExampleState.new "C#m", "works"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "returns true if the exception is an ExpectationNotMetError" do
|
69
|
+
exc = ExceptionState.new @state, "", ExpectationNotMetError.new("Fail!")
|
70
|
+
exc.failure?.should be_true
|
71
|
+
end
|
72
|
+
|
73
|
+
it "returns false if the exception is not an ExpectationNotMetError" do
|
74
|
+
exc = ExceptionState.new @state, "", Exception.new("Fail!")
|
75
|
+
exc.failure?.should be_false
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe ExceptionState, "#message" do
|
80
|
+
it "returns <No message> if the exception message is empty" do
|
81
|
+
exc = ExceptionState.new @state, "", Exception.new("")
|
82
|
+
exc.message.should == "<No message>"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "returns the message without exception class when the exception is ExpectationNotMetError" do
|
86
|
+
exc = ExceptionState.new @state, "", ExpectationNotMetError.new("Fail!")
|
87
|
+
exc.message.should == "Fail!"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "returns the message with exception class when the exception is not ExpectationNotMetError" do
|
91
|
+
exc = ExceptionState.new @state, "", Exception.new("Fail!")
|
92
|
+
exc.message.should == "Exception: Fail!"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe ExceptionState, "#backtrace" do
|
97
|
+
before :each do
|
98
|
+
begin
|
99
|
+
raise Exception, "mock backtrace"
|
100
|
+
rescue Exception => @exception
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
it "returns a string representation of the exception backtrace" do
|
105
|
+
exc = ExceptionState.new @state, "", @exception
|
106
|
+
exc.backtrace.should be_kind_of(String)
|
107
|
+
end
|
108
|
+
|
109
|
+
# TODO: spec the filtering of the backtrace so mspec files don't display
|
110
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
require 'mspec/runner/formatters/dotted'
|
3
3
|
require 'mspec/runner/mspec'
|
4
|
-
require 'mspec/runner/
|
4
|
+
require 'mspec/runner/example'
|
5
5
|
|
6
6
|
describe DottedFormatter, "#initialize" do
|
7
7
|
it "permits zero arguments" do
|
@@ -20,6 +20,8 @@ describe DottedFormatter, "#register" do
|
|
20
20
|
|
21
21
|
it "registers self with MSpec for appropriate actions" do
|
22
22
|
MSpec.stub!(:register)
|
23
|
+
MSpec.should_receive(:register).with(:exception, @formatter)
|
24
|
+
MSpec.should_receive(:register).with(:before, @formatter)
|
23
25
|
MSpec.should_receive(:register).with(:after, @formatter)
|
24
26
|
MSpec.should_receive(:register).with(:finish, @formatter)
|
25
27
|
@formatter.register
|
@@ -58,24 +60,106 @@ describe DottedFormatter, "#print" do
|
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
|
-
describe DottedFormatter, "#
|
63
|
+
describe DottedFormatter, "#exception" do
|
62
64
|
before :each do
|
63
65
|
@formatter = DottedFormatter.new
|
66
|
+
@failure = ExceptionState.new nil, nil, ExpectationNotMetError.new("failed")
|
67
|
+
@error = ExceptionState.new nil, nil, MSpecExampleError.new("boom!")
|
64
68
|
end
|
65
69
|
|
66
|
-
it "
|
67
|
-
|
68
|
-
@formatter.
|
70
|
+
it "sets the #failure? flag" do
|
71
|
+
@formatter.exception @failure
|
72
|
+
@formatter.failure?.should be_true
|
73
|
+
@formatter.exception @error
|
74
|
+
@formatter.failure?.should be_false
|
69
75
|
end
|
70
76
|
|
71
|
-
it "
|
72
|
-
|
73
|
-
@formatter.
|
77
|
+
it "sets the #exception? flag" do
|
78
|
+
@formatter.exception @error
|
79
|
+
@formatter.exception?.should be_true
|
80
|
+
@formatter.exception @failure
|
81
|
+
@formatter.exception?.should be_true
|
74
82
|
end
|
75
83
|
|
76
|
-
it "
|
77
|
-
|
78
|
-
@formatter.
|
84
|
+
it "addes the exception to the list of exceptions" do
|
85
|
+
@formatter.exceptions.should == []
|
86
|
+
@formatter.exception @error
|
87
|
+
@formatter.exception @failure
|
88
|
+
@formatter.exceptions.should == [@error, @failure]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe DottedFormatter, "#exception?" do
|
93
|
+
before :each do
|
94
|
+
@formatter = DottedFormatter.new
|
95
|
+
@failure = ExceptionState.new nil, nil, ExpectationNotMetError.new("failed")
|
96
|
+
@error = ExceptionState.new nil, nil, MSpecExampleError.new("boom!")
|
97
|
+
end
|
98
|
+
|
99
|
+
it "returns false if there have been no exceptions" do
|
100
|
+
@formatter.exception?.should be_false
|
101
|
+
end
|
102
|
+
|
103
|
+
it "returns true if any exceptions are errors" do
|
104
|
+
@formatter.exception @failure
|
105
|
+
@formatter.exception @error
|
106
|
+
@formatter.exception?.should be_true
|
107
|
+
end
|
108
|
+
|
109
|
+
it "returns true if all exceptions are failures" do
|
110
|
+
@formatter.exception @failure
|
111
|
+
@formatter.exception @failure
|
112
|
+
@formatter.exception?.should be_true
|
113
|
+
end
|
114
|
+
|
115
|
+
it "returns true if all exceptions are errors" do
|
116
|
+
@formatter.exception @error
|
117
|
+
@formatter.exception @error
|
118
|
+
@formatter.exception?.should be_true
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe DottedFormatter, "#failure?" do
|
123
|
+
before :each do
|
124
|
+
@formatter = DottedFormatter.new
|
125
|
+
@failure = ExceptionState.new nil, nil, ExpectationNotMetError.new("failed")
|
126
|
+
@error = ExceptionState.new nil, nil, MSpecExampleError.new("boom!")
|
127
|
+
end
|
128
|
+
|
129
|
+
it "returns false if there have been no exceptions" do
|
130
|
+
@formatter.failure?.should be_false
|
131
|
+
end
|
132
|
+
|
133
|
+
it "returns false if any exceptions are errors" do
|
134
|
+
@formatter.exception @failure
|
135
|
+
@formatter.exception @error
|
136
|
+
@formatter.failure?.should be_false
|
137
|
+
end
|
138
|
+
|
139
|
+
it "returns true if all exceptions are failures" do
|
140
|
+
@formatter.exception @failure
|
141
|
+
@formatter.exception @failure
|
142
|
+
@formatter.failure?.should be_true
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe DottedFormatter, "#before" do
|
147
|
+
before :each do
|
148
|
+
@state = ExampleState.new("describe", "it")
|
149
|
+
@formatter = DottedFormatter.new
|
150
|
+
@formatter.exception ExceptionState.new(nil, nil, ExpectationNotMetError.new("Failed!"))
|
151
|
+
end
|
152
|
+
|
153
|
+
it "resets the #failure? flag to false" do
|
154
|
+
@formatter.failure?.should be_true
|
155
|
+
@formatter.before @state
|
156
|
+
@formatter.failure?.should be_false
|
157
|
+
end
|
158
|
+
|
159
|
+
it "resets the #exception? flag to false" do
|
160
|
+
@formatter.exception?.should be_true
|
161
|
+
@formatter.before @state
|
162
|
+
@formatter.exception?.should be_false
|
79
163
|
end
|
80
164
|
end
|
81
165
|
|
@@ -83,7 +167,7 @@ describe DottedFormatter, "#after" do
|
|
83
167
|
before :each do
|
84
168
|
$stdout = @out = IOStub.new
|
85
169
|
@formatter = DottedFormatter.new
|
86
|
-
@state =
|
170
|
+
@state = ExampleState.new("describe", "it")
|
87
171
|
end
|
88
172
|
|
89
173
|
after :each do
|
@@ -96,20 +180,24 @@ describe DottedFormatter, "#after" do
|
|
96
180
|
end
|
97
181
|
|
98
182
|
it "prints an 'F' if there was an expectation failure" do
|
99
|
-
|
183
|
+
exc = ExpectationNotMetError.new "failed"
|
184
|
+
@formatter.exception ExceptionState.new(@state, nil, exc)
|
100
185
|
@formatter.after(@state)
|
101
186
|
@out.should == "F"
|
102
187
|
end
|
103
188
|
|
104
189
|
it "prints an 'E' if there was an exception other than expectation failure" do
|
105
|
-
|
190
|
+
exc = MSpecExampleError.new("boom!")
|
191
|
+
@formatter.exception ExceptionState.new(@state, nil, exc)
|
106
192
|
@formatter.after(@state)
|
107
193
|
@out.should == "E"
|
108
194
|
end
|
109
195
|
|
110
196
|
it "prints an 'E' if there are mixed exceptions and exepctation failures" do
|
111
|
-
|
112
|
-
@
|
197
|
+
exc = ExpectationNotMetError.new "failed"
|
198
|
+
@formatter.exception ExceptionState.new(@state, nil, exc)
|
199
|
+
exc = MSpecExampleError.new("boom!")
|
200
|
+
@formatter.exception ExceptionState.new(@state, nil, exc)
|
113
201
|
@formatter.after(@state)
|
114
202
|
@out.should == "E"
|
115
203
|
end
|
@@ -123,7 +211,7 @@ describe DottedFormatter, "#finish" do
|
|
123
211
|
TimerAction.stub!(:new).and_return(@timer)
|
124
212
|
|
125
213
|
$stdout = @out = IOStub.new
|
126
|
-
@state =
|
214
|
+
@state = ExampleState.new("Class#method", "runs")
|
127
215
|
MSpec.stub!(:register)
|
128
216
|
@formatter = DottedFormatter.new
|
129
217
|
@formatter.register
|
@@ -134,15 +222,17 @@ describe DottedFormatter, "#finish" do
|
|
134
222
|
end
|
135
223
|
|
136
224
|
it "prints a failure message for an exception" do
|
137
|
-
@state
|
225
|
+
exc = ExceptionState.new @state, nil, MSpecExampleError.new("broken")
|
226
|
+
@formatter.exception exc
|
138
227
|
@formatter.after @state
|
139
228
|
@formatter.finish
|
140
|
-
@out.should =~ /^1\)\
|
229
|
+
@out.should =~ /^1\)\nClass#method runs ERROR$/
|
141
230
|
end
|
142
231
|
|
143
232
|
it "prints a backtrace for an exception" do
|
144
|
-
@
|
145
|
-
|
233
|
+
exc = ExceptionState.new @state, nil, MSpecExampleError.new("broken")
|
234
|
+
exc.stub!(:backtrace).and_return("path/to/some/file.rb:35:in method")
|
235
|
+
@formatter.exception exc
|
146
236
|
@formatter.after @state
|
147
237
|
@formatter.finish
|
148
238
|
@out.should =~ %r[path/to/some/file.rb:35:in method$]
|
@@ -161,24 +251,24 @@ describe DottedFormatter, "#finish" do
|
|
161
251
|
end
|
162
252
|
|
163
253
|
it "prints errors, backtraces, elapsed time, and tallies" do
|
164
|
-
@state
|
165
|
-
|
254
|
+
exc = ExceptionState.new @state, nil, MSpecExampleError.new("broken")
|
255
|
+
exc.stub!(:backtrace).and_return("path/to/some/file.rb:35:in method")
|
256
|
+
@formatter.exception exc
|
166
257
|
@timer.should_receive(:format).and_return("Finished in 2.0 seconds")
|
167
|
-
@tally.should_receive(:format).and_return("1 example,
|
258
|
+
@tally.should_receive(:format).and_return("1 example, 1 failure")
|
168
259
|
@formatter.after @state
|
169
260
|
@formatter.finish
|
170
261
|
@out.should ==
|
171
262
|
%[E
|
172
263
|
|
173
264
|
1)
|
174
|
-
|
175
|
-
MSpecExampleError occurred during: msg
|
265
|
+
Class#method runs ERROR
|
176
266
|
MSpecExampleError: broken
|
177
267
|
path/to/some/file.rb:35:in method
|
178
268
|
|
179
269
|
Finished in 2.0 seconds
|
180
270
|
|
181
|
-
1 example,
|
271
|
+
1 example, 1 failure
|
182
272
|
]
|
183
273
|
end
|
184
274
|
end
|
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
require 'mspec/guards/guard'
|
3
3
|
require 'mspec/runner/formatters/html'
|
4
4
|
require 'mspec/runner/mspec'
|
5
|
-
require 'mspec/runner/
|
5
|
+
require 'mspec/runner/example'
|
6
6
|
|
7
7
|
describe HtmlFormatter do
|
8
8
|
before :each do
|
@@ -90,11 +90,36 @@ describe HtmlFormatter, "#leave" do
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
+
describe HtmlFormatter, "#exception" do
|
94
|
+
before :each do
|
95
|
+
$stdout = @out = IOStub.new
|
96
|
+
@formatter = HtmlFormatter.new
|
97
|
+
@formatter.register
|
98
|
+
@state = ExampleState.new("describe", "it")
|
99
|
+
end
|
100
|
+
|
101
|
+
after :each do
|
102
|
+
$stdout = STDOUT
|
103
|
+
end
|
104
|
+
|
105
|
+
it "prints the #it string once for each exception raised" do
|
106
|
+
exc = ExceptionState.new @state, nil, ExpectationNotMetError.new("disappointing")
|
107
|
+
@formatter.exception exc
|
108
|
+
exc = ExceptionState.new @state, nil, MSpecExampleError.new("painful")
|
109
|
+
@formatter.exception exc
|
110
|
+
@out.should ==
|
111
|
+
%[<li class="fail">- it (<a href="#details-1">FAILED - 1</a>)</li>
|
112
|
+
<li class="fail">- it (<a href="#details-2">ERROR - 2</a>)</li>
|
113
|
+
]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
93
117
|
describe HtmlFormatter, "#after" do
|
94
118
|
before :each do
|
95
119
|
$stdout = @out = IOStub.new
|
96
120
|
@formatter = HtmlFormatter.new
|
97
|
-
@
|
121
|
+
@formatter.register
|
122
|
+
@state = ExampleState.new("describe", "it")
|
98
123
|
end
|
99
124
|
|
100
125
|
after :each do
|
@@ -106,16 +131,12 @@ describe HtmlFormatter, "#after" do
|
|
106
131
|
@out.should == %[<li class="pass">- it</li>\n]
|
107
132
|
end
|
108
133
|
|
109
|
-
it "
|
110
|
-
@
|
111
|
-
@
|
112
|
-
|
113
|
-
@formatter.tally.after @state
|
134
|
+
it "does not print any output if an exception is raised" do
|
135
|
+
exc = ExceptionState.new @state, nil, ExpectationNotMetError.new("disappointing")
|
136
|
+
@formatter.exception exc
|
137
|
+
out = @out.dup
|
114
138
|
@formatter.after @state
|
115
|
-
@out.should ==
|
116
|
-
%[<li class="fail">- it (<a href="#details-1">FAILED - 1</a>)</li>
|
117
|
-
<li class="fail">- it (<a href="#details-2">ERROR - 2</a>)</li>
|
118
|
-
]
|
139
|
+
@out.should == out
|
119
140
|
end
|
120
141
|
end
|
121
142
|
|
@@ -127,7 +148,7 @@ describe HtmlFormatter, "#finish" do
|
|
127
148
|
TimerAction.stub!(:new).and_return(@timer)
|
128
149
|
|
129
150
|
$stdout = @out = IOStub.new
|
130
|
-
@state =
|
151
|
+
@state = ExampleState.new("describe", "it")
|
131
152
|
MSpec.stub!(:register)
|
132
153
|
@formatter = HtmlFormatter.new
|
133
154
|
@formatter.register
|
@@ -140,16 +161,16 @@ describe HtmlFormatter, "#finish" do
|
|
140
161
|
end
|
141
162
|
|
142
163
|
it "prints a failure message for an exception" do
|
143
|
-
@state
|
144
|
-
@formatter.
|
164
|
+
exc = ExceptionState.new @state, nil, @exception
|
165
|
+
@formatter.exception exc
|
145
166
|
@formatter.finish
|
146
167
|
@out.should =~ %r[<p>describe it ERROR</p>]
|
147
168
|
end
|
148
169
|
|
149
170
|
it "prints a backtrace for an exception" do
|
150
|
-
|
151
|
-
|
152
|
-
@formatter.
|
171
|
+
exc = ExceptionState.new @state, nil, @exception
|
172
|
+
exc.stub!(:backtrace).and_return("path/to/some/file.rb:35:in method")
|
173
|
+
@formatter.exception exc
|
153
174
|
@formatter.finish
|
154
175
|
@out.should =~ %r[<pre>.*path/to/some/file.rb:35:in method.*</pre>]m
|
155
176
|
end
|
@@ -167,14 +188,16 @@ describe HtmlFormatter, "#finish" do
|
|
167
188
|
end
|
168
189
|
|
169
190
|
it "prints errors, backtraces, elapsed time, and tallies" do
|
170
|
-
@state
|
171
|
-
|
191
|
+
exc = ExceptionState.new @state, nil, @exception
|
192
|
+
exc.stub!(:backtrace).and_return("path/to/some/file.rb:35:in method")
|
193
|
+
@formatter.exception exc
|
194
|
+
|
172
195
|
@timer.should_receive(:format).and_return("Finished in 2.0 seconds")
|
173
196
|
@tally.should_receive(:format).and_return("1 example, 1 failures")
|
174
|
-
@formatter.instance_variable_set :@states, [@state]
|
175
197
|
@formatter.finish
|
176
198
|
@out.should ==
|
177
|
-
%[<
|
199
|
+
%[<li class=\"fail\">- it (<a href=\"#details-1\">ERROR - 1</a>)</li>
|
200
|
+
<hr>
|
178
201
|
<ol id="details">
|
179
202
|
<li id="details-1"><p>describe it ERROR</p>
|
180
203
|
<p>MSpecExampleError: broken</p>
|