spicycode-micronaut 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/examples/example_helper.rb +2 -1
- data/examples/lib/micronaut/configuration_example.rb +9 -9
- data/examples/lib/micronaut/expectations/wrap_expectation_example.rb +21 -25
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +3 -2
- data/examples/lib/micronaut/matchers/matcher_methods_example.rb +73 -61
- data/examples/lib/micronaut/matchers/operator_matcher_example.rb +141 -137
- data/examples/lib/micronaut/matchers/raise_error_example.rb +251 -249
- data/lib/micronaut/behaviour.rb +1 -1
- data/lib/micronaut/configuration.rb +3 -0
- data/lib/micronaut/formatters/base_formatter.rb +5 -0
- data/lib/micronaut/formatters/base_text_formatter.rb +29 -1
- metadata +2 -4
@@ -1,346 +1,348 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
2
|
|
3
|
-
describe "
|
4
|
-
|
5
|
-
|
6
|
-
lambda {raise}.should raise_error
|
7
|
-
end
|
3
|
+
describe Micronaut::Matchers, "raise_error" do
|
4
|
+
|
5
|
+
describe "should raise_error" do
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}.should fail_with("expected Exception but nothing was raised")
|
13
|
-
end
|
7
|
+
it "should pass if anything is raised" do
|
8
|
+
lambda {raise}.should raise_error
|
9
|
+
end
|
14
10
|
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
it "should fail if nothing is raised" do
|
12
|
+
lambda {
|
13
|
+
lambda {}.should raise_error
|
14
|
+
}.should fail_with("expected Exception but nothing was raised")
|
15
|
+
end
|
18
16
|
|
19
|
-
it "should pass if nothing is raised" do
|
20
|
-
lambda {}.should_not raise_error
|
21
17
|
end
|
18
|
+
|
19
|
+
describe "should_not raise_error" do
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}.should fail_with("expected no Exception, got RuntimeError")
|
27
|
-
end
|
21
|
+
it "should pass if nothing is raised" do
|
22
|
+
lambda {}.should_not raise_error
|
23
|
+
end
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
it "should fail if anything is raised" do
|
26
|
+
lambda {
|
27
|
+
lambda {raise}.should_not raise_error
|
28
|
+
}.should fail_with("expected no Exception, got RuntimeError")
|
29
|
+
end
|
32
30
|
|
33
|
-
it "should pass if RuntimeError is raised with the right message" do
|
34
|
-
lambda {raise 'blah'}.should raise_error('blah')
|
35
31
|
end
|
32
|
+
|
33
|
+
describe "should raise_error(message)" do
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
it "should pass if RuntimeError is raised with the right message" do
|
36
|
+
lambda {raise 'blah'}.should raise_error('blah')
|
37
|
+
end
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
it "should pass if RuntimeError is raised with a matching message" do
|
40
|
+
lambda {raise 'blah'}.should raise_error(/blah/)
|
41
|
+
end
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end.should fail_with("expected Exception with \"blah\", got #<RuntimeError: blarg>")
|
49
|
-
end
|
43
|
+
it "should pass if any other error is raised with the right message" do
|
44
|
+
lambda {raise NameError.new('blah')}.should raise_error('blah')
|
45
|
+
end
|
50
46
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
it "should fail if RuntimeError error is raised with the wrong message" do
|
48
|
+
lambda do
|
49
|
+
lambda {raise 'blarg'}.should raise_error('blah')
|
50
|
+
end.should fail_with("expected Exception with \"blah\", got #<RuntimeError: blarg>")
|
51
|
+
end
|
56
52
|
|
57
|
-
|
58
|
-
|
59
|
-
|
53
|
+
it "should fail if any other error is raised with the wrong message" do
|
54
|
+
lambda do
|
55
|
+
lambda {raise NameError.new('blarg')}.should raise_error('blah')
|
56
|
+
end.should fail_with("expected Exception with \"blah\", got #<NameError: blarg>")
|
57
|
+
end
|
60
58
|
|
61
|
-
it "should pass if RuntimeError error is raised with the different message" do
|
62
|
-
lambda {raise 'blarg'}.should_not raise_error('blah')
|
63
59
|
end
|
60
|
+
|
61
|
+
describe "should_not raise_error(message)" do
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
it "should pass if RuntimeError error is raised with the different message" do
|
64
|
+
lambda {raise 'blarg'}.should_not raise_error('blah')
|
65
|
+
end
|
68
66
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end.should fail_with(%Q|expected no Exception with "blah", got #<RuntimeError: blah>|)
|
73
|
-
end
|
67
|
+
it "should pass if any other error is raised with the wrong message" do
|
68
|
+
lambda {raise NameError.new('blarg')}.should_not raise_error('blah')
|
69
|
+
end
|
74
70
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
71
|
+
it "should fail if RuntimeError is raised with message" do
|
72
|
+
lambda do
|
73
|
+
lambda {raise 'blah'}.should_not raise_error('blah')
|
74
|
+
end.should fail_with(%Q|expected no Exception with "blah", got #<RuntimeError: blah>|)
|
75
|
+
end
|
80
76
|
|
81
|
-
|
82
|
-
|
83
|
-
|
77
|
+
it "should fail if any other error is raised with message" do
|
78
|
+
lambda do
|
79
|
+
lambda {raise NameError.new('blah')}.should_not raise_error('blah')
|
80
|
+
end.should fail_with(%Q|expected no Exception with "blah", got #<NameError: blah>|)
|
81
|
+
end
|
84
82
|
|
85
|
-
it "should pass if named error is raised" do
|
86
|
-
lambda { non_existent_method }.should raise_error(NameError)
|
87
83
|
end
|
84
|
+
|
85
|
+
describe "should raise_error(NamedError)" do
|
88
86
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
}.should fail_with("expected NameError but nothing was raised")
|
93
|
-
end
|
87
|
+
it "should pass if named error is raised" do
|
88
|
+
lambda { non_existent_method }.should raise_error(NameError)
|
89
|
+
end
|
94
90
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
91
|
+
it "should fail if nothing is raised" do
|
92
|
+
lambda {
|
93
|
+
lambda { }.should raise_error(NameError)
|
94
|
+
}.should fail_with("expected NameError but nothing was raised")
|
95
|
+
end
|
100
96
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
97
|
+
it "should fail if another error is raised (NameError)" do
|
98
|
+
lambda {
|
99
|
+
lambda { raise }.should raise_error(NameError)
|
100
|
+
}.should fail_with("expected NameError, got RuntimeError")
|
101
|
+
end
|
106
102
|
|
107
|
-
|
108
|
-
|
109
|
-
|
103
|
+
it "should fail if another error is raised (NameError)" do
|
104
|
+
lambda {
|
105
|
+
lambda { load "non/existent/file" }.should raise_error(NameError)
|
106
|
+
}.should fail_with(/expected NameError, got #<LoadError/)
|
107
|
+
end
|
110
108
|
|
111
|
-
it "should pass if nothing is raised" do
|
112
|
-
lambda { }.should_not raise_error(NameError)
|
113
109
|
end
|
110
|
+
|
111
|
+
describe "should_not raise_error(NamedError)" do
|
114
112
|
|
115
|
-
|
116
|
-
|
117
|
-
|
113
|
+
it "should pass if nothing is raised" do
|
114
|
+
lambda { }.should_not raise_error(NameError)
|
115
|
+
end
|
118
116
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
}.should fail_with(/expected no NameError, got #<NameError: undefined/)
|
123
|
-
end
|
117
|
+
it "should pass if another error is raised" do
|
118
|
+
lambda { raise }.should_not raise_error(NameError)
|
119
|
+
end
|
124
120
|
|
125
|
-
|
126
|
-
|
127
|
-
|
121
|
+
it "should fail if named error is raised" do
|
122
|
+
lambda {
|
123
|
+
lambda { non_existent_method }.should_not raise_error(NameError)
|
124
|
+
}.should fail_with(/expected no NameError, got #<NameError: undefined/)
|
125
|
+
end
|
128
126
|
|
129
|
-
it "should pass if named error is raised with same message" do
|
130
|
-
lambda { raise "example message" }.should raise_error(RuntimeError, "example message")
|
131
127
|
end
|
128
|
+
|
129
|
+
describe "should raise_error(NamedError, error_message) with String" do
|
132
130
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
}.should fail_with("expected RuntimeError with \"example message\" but nothing was raised")
|
137
|
-
end
|
131
|
+
it "should pass if named error is raised with same message" do
|
132
|
+
lambda { raise "example message" }.should raise_error(RuntimeError, "example message")
|
133
|
+
end
|
138
134
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
135
|
+
it "should fail if nothing is raised" do
|
136
|
+
lambda {
|
137
|
+
lambda {}.should raise_error(RuntimeError, "example message")
|
138
|
+
}.should fail_with("expected RuntimeError with \"example message\" but nothing was raised")
|
139
|
+
end
|
144
140
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
141
|
+
it "should fail if incorrect error is raised" do
|
142
|
+
lambda {
|
143
|
+
lambda { raise }.should raise_error(NameError, "example message")
|
144
|
+
}.should fail_with("expected NameError with \"example message\", got RuntimeError")
|
145
|
+
end
|
150
146
|
|
151
|
-
|
152
|
-
|
153
|
-
|
147
|
+
it "should fail if correct error is raised with incorrect message" do
|
148
|
+
lambda {
|
149
|
+
lambda { raise RuntimeError.new("not the example message") }.should raise_error(RuntimeError, "example message")
|
150
|
+
}.should fail_with(/expected RuntimeError with \"example message\", got #<RuntimeError: not the example message/)
|
151
|
+
end
|
154
152
|
|
155
|
-
it "should yield exception if named error is raised with same message" do
|
156
|
-
ran = false
|
157
|
-
|
158
|
-
lambda {
|
159
|
-
raise "example message"
|
160
|
-
}.should raise_error(RuntimeError, "example message") { |err|
|
161
|
-
ran = true
|
162
|
-
err.class.should == RuntimeError
|
163
|
-
err.message.should == "example message"
|
164
|
-
}
|
165
|
-
|
166
|
-
ran.should == true
|
167
153
|
end
|
168
154
|
|
169
|
-
|
170
|
-
|
155
|
+
describe "should raise_error(NamedError, error_message) { |err| ... }" do
|
156
|
+
|
157
|
+
it "should yield exception if named error is raised with same message" do
|
158
|
+
ran = false
|
171
159
|
|
172
|
-
lambda {
|
173
160
|
lambda {
|
174
161
|
raise "example message"
|
175
162
|
}.should raise_error(RuntimeError, "example message") { |err|
|
176
163
|
ran = true
|
177
|
-
|
178
|
-
|
164
|
+
err.class.should == RuntimeError
|
165
|
+
err.message.should == "example message"
|
179
166
|
}
|
180
|
-
}.should fail_with(/expected: 4/m)
|
181
167
|
|
182
|
-
|
183
|
-
|
184
|
-
end
|
168
|
+
ran.should == true
|
169
|
+
end
|
185
170
|
|
186
|
-
|
187
|
-
|
171
|
+
it "yielded block should be able to fail on it's own right" do
|
172
|
+
ran, passed = false, false
|
188
173
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
174
|
+
lambda {
|
175
|
+
lambda { raise "example message" }.should raise_error(RuntimeError, "example message") { |err|
|
176
|
+
ran = true
|
177
|
+
5.should == 4
|
178
|
+
passed = true
|
179
|
+
}
|
180
|
+
}.should fail_with(/expected: 4/m)
|
194
181
|
|
195
|
-
|
196
|
-
|
182
|
+
ran.should == true
|
183
|
+
passed.should == false
|
184
|
+
end
|
197
185
|
|
198
|
-
|
199
|
-
|
186
|
+
it "should NOT yield exception if no error was thrown" do
|
187
|
+
ran = false
|
200
188
|
|
201
|
-
lambda {
|
202
189
|
lambda {
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
}
|
207
|
-
}.should fail_with("expected SyntaxError with \"example message\", got #<RuntimeError: example message>")
|
190
|
+
lambda {}.should raise_error(RuntimeError, "example message") { |err|
|
191
|
+
ran = true
|
192
|
+
}
|
193
|
+
}.should fail_with("expected RuntimeError with \"example message\" but nothing was raised")
|
208
194
|
|
209
|
-
|
210
|
-
|
195
|
+
ran.should == false
|
196
|
+
end
|
211
197
|
|
212
|
-
|
213
|
-
|
198
|
+
it "should not yield exception if error class is not matched" do
|
199
|
+
ran = false
|
214
200
|
|
215
|
-
lambda {
|
216
201
|
lambda {
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
202
|
+
lambda {
|
203
|
+
raise "example message"
|
204
|
+
}.should raise_error(SyntaxError, "example message") { |err|
|
205
|
+
ran = true
|
206
|
+
}
|
207
|
+
}.should fail_with("expected SyntaxError with \"example message\", got #<RuntimeError: example message>")
|
222
208
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
end
|
209
|
+
ran.should == false
|
210
|
+
end
|
227
211
|
|
228
|
-
|
229
|
-
|
230
|
-
it "should pass if nothing is raised" do
|
231
|
-
ran = false
|
212
|
+
it "should NOT yield exception if error message is not matched" do
|
213
|
+
ran = false
|
232
214
|
|
233
|
-
|
234
|
-
|
235
|
-
|
215
|
+
lambda {
|
216
|
+
lambda {
|
217
|
+
raise "example message"
|
218
|
+
}.should raise_error(RuntimeError, "different message") { |err|
|
219
|
+
ran = true
|
220
|
+
}
|
221
|
+
}.should fail_with("expected RuntimeError with \"different message\", got #<RuntimeError: example message>")
|
236
222
|
|
237
|
-
|
223
|
+
ran.should == false
|
224
|
+
end
|
225
|
+
|
238
226
|
end
|
239
227
|
|
240
|
-
|
241
|
-
|
228
|
+
describe "should_not raise_error(NamedError, error_message) { |err| ... }" do
|
229
|
+
|
230
|
+
it "should pass if nothing is raised" do
|
231
|
+
ran = false
|
242
232
|
|
243
|
-
|
244
|
-
|
245
|
-
|
233
|
+
lambda {}.should_not raise_error(RuntimeError, "example message") { |err|
|
234
|
+
ran = true
|
235
|
+
}
|
246
236
|
|
247
|
-
|
248
|
-
|
237
|
+
ran.should == false
|
238
|
+
end
|
249
239
|
|
250
|
-
|
251
|
-
|
240
|
+
it "should pass if a different error is raised" do
|
241
|
+
ran = false
|
252
242
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
ran = true
|
257
|
-
}
|
243
|
+
lambda { raise }.should_not raise_error(NameError, "example message") { |err|
|
244
|
+
ran = true
|
245
|
+
}
|
258
246
|
|
259
|
-
|
260
|
-
|
247
|
+
ran.should == false
|
248
|
+
end
|
261
249
|
|
262
|
-
|
263
|
-
|
250
|
+
it "should pass if same error is raised with different message" do
|
251
|
+
ran = false
|
264
252
|
|
265
|
-
lambda {
|
266
253
|
lambda {
|
267
|
-
raise "example message"
|
254
|
+
raise RuntimeError.new("not the example message")
|
268
255
|
}.should_not raise_error(RuntimeError, "example message") { |err|
|
269
256
|
ran = true
|
270
257
|
}
|
271
|
-
}.should fail_with("expected no RuntimeError with \"example message\", got #<RuntimeError: example message>")
|
272
258
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
end
|
259
|
+
ran.should == false
|
260
|
+
end
|
277
261
|
|
278
|
-
|
262
|
+
it "should fail if named error is raised with same message" do
|
263
|
+
ran = false
|
264
|
+
|
265
|
+
lambda {
|
266
|
+
lambda {
|
267
|
+
raise "example message"
|
268
|
+
}.should_not raise_error(RuntimeError, "example message") { |err|
|
269
|
+
ran = true
|
270
|
+
}
|
271
|
+
}.should fail_with("expected no RuntimeError with \"example message\", got #<RuntimeError: example message>")
|
272
|
+
|
273
|
+
ran.should == false
|
274
|
+
end
|
279
275
|
|
280
|
-
it "should pass if nothing is raised" do
|
281
|
-
lambda {}.should_not raise_error(RuntimeError, "example message")
|
282
276
|
end
|
277
|
+
|
278
|
+
describe "should_not raise_error(NamedError, error_message) with String" do
|
283
279
|
|
284
|
-
|
285
|
-
|
286
|
-
|
280
|
+
it "should pass if nothing is raised" do
|
281
|
+
lambda {}.should_not raise_error(RuntimeError, "example message")
|
282
|
+
end
|
287
283
|
|
288
|
-
|
289
|
-
|
290
|
-
|
284
|
+
it "should pass if a different error is raised" do
|
285
|
+
lambda { raise }.should_not raise_error(NameError, "example message")
|
286
|
+
end
|
291
287
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
}.should fail_with("expected no RuntimeError with \"example message\", got #<RuntimeError: example message>")
|
296
|
-
end
|
288
|
+
it "should pass if same error is raised with different message" do
|
289
|
+
lambda { raise RuntimeError.new("not the example message") }.should_not raise_error(RuntimeError, "example message")
|
290
|
+
end
|
297
291
|
|
298
|
-
|
299
|
-
|
300
|
-
|
292
|
+
it "should fail if named error is raised with same message" do
|
293
|
+
lambda {
|
294
|
+
lambda { raise "example message" }.should_not raise_error(RuntimeError, "example message")
|
295
|
+
}.should fail_with("expected no RuntimeError with \"example message\", got #<RuntimeError: example message>")
|
296
|
+
end
|
301
297
|
|
302
|
-
it "should pass if named error is raised with matching message" do
|
303
|
-
lambda { raise "example message" }.should raise_error(RuntimeError, /ample mess/)
|
304
298
|
end
|
299
|
+
|
300
|
+
describe "should raise_error(NamedError, error_message) with Regexp" do
|
305
301
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
}.should fail_with("expected RuntimeError with message matching /ample mess/ but nothing was raised")
|
310
|
-
end
|
302
|
+
it "should pass if named error is raised with matching message" do
|
303
|
+
lambda { raise "example message" }.should raise_error(RuntimeError, /ample mess/)
|
304
|
+
end
|
311
305
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
306
|
+
it "should fail if nothing is raised" do
|
307
|
+
lambda {
|
308
|
+
lambda {}.should raise_error(RuntimeError, /ample mess/)
|
309
|
+
}.should fail_with("expected RuntimeError with message matching /ample mess/ but nothing was raised")
|
310
|
+
end
|
317
311
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
312
|
+
it "should fail if incorrect error is raised" do
|
313
|
+
lambda {
|
314
|
+
lambda { raise }.should raise_error(NameError, /ample mess/)
|
315
|
+
}.should fail_with("expected NameError with message matching /ample mess/, got RuntimeError")
|
316
|
+
end
|
323
317
|
|
324
|
-
|
325
|
-
|
326
|
-
|
318
|
+
it "should fail if correct error is raised with incorrect message" do
|
319
|
+
lambda {
|
320
|
+
lambda { raise RuntimeError.new("not the example message") }.should raise_error(RuntimeError, /less than ample mess/)
|
321
|
+
}.should fail_with("expected RuntimeError with message matching /less than ample mess/, got #<RuntimeError: not the example message>")
|
322
|
+
end
|
327
323
|
|
328
|
-
it "should pass if nothing is raised" do
|
329
|
-
lambda {}.should_not raise_error(RuntimeError, /ample mess/)
|
330
324
|
end
|
325
|
+
|
326
|
+
describe "should_not raise_error(NamedError, error_message) with Regexp" do
|
331
327
|
|
332
|
-
|
333
|
-
|
334
|
-
|
328
|
+
it "should pass if nothing is raised" do
|
329
|
+
lambda {}.should_not raise_error(RuntimeError, /ample mess/)
|
330
|
+
end
|
335
331
|
|
336
|
-
|
337
|
-
|
338
|
-
|
332
|
+
it "should pass if a different error is raised" do
|
333
|
+
lambda { raise }.should_not raise_error(NameError, /ample mess/)
|
334
|
+
end
|
335
|
+
|
336
|
+
it "should pass if same error is raised with non-matching message" do
|
337
|
+
lambda { raise RuntimeError.new("non matching message") }.should_not raise_error(RuntimeError, /ample mess/)
|
338
|
+
end
|
339
|
+
|
340
|
+
it "should fail if named error is raised with matching message" do
|
341
|
+
lambda {
|
342
|
+
lambda { raise "example message" }.should_not raise_error(RuntimeError, /ample mess/)
|
343
|
+
}.should fail_with("expected no RuntimeError with message matching /ample mess/, got #<RuntimeError: example message>")
|
344
|
+
end
|
339
345
|
|
340
|
-
it "should fail if named error is raised with matching message" do
|
341
|
-
lambda {
|
342
|
-
lambda { raise "example message" }.should_not raise_error(RuntimeError, /ample mess/)
|
343
|
-
}.should fail_with("expected no RuntimeError with message matching /ample mess/, got #<RuntimeError: example message>")
|
344
346
|
end
|
345
347
|
|
346
348
|
end
|