rsanheim-micronaut 0.1.3.2 → 0.1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,346 +1,348 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
2
2
 
3
- describe "should raise_error" do
4
-
5
- it "should pass if anything is raised" do
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
- it "should fail if nothing is raised" do
10
- lambda {
11
- lambda {}.should raise_error
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
- end
16
-
17
- describe "should_not raise_error" do
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
- it "should fail if anything is raised" do
24
- lambda {
25
- lambda {raise}.should_not raise_error
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
- end
30
-
31
- describe "should raise_error(message)" do
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
- it "should pass if RuntimeError is raised with a matching message" do
38
- lambda {raise 'blah'}.should raise_error(/blah/)
39
- end
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
- it "should pass if any other error is raised with the right message" do
42
- lambda {raise NameError.new('blah')}.should raise_error('blah')
43
- end
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
- it "should fail if RuntimeError error is raised with the wrong message" do
46
- lambda do
47
- lambda {raise 'blarg'}.should raise_error('blah')
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
- it "should fail if any other error is raised with the wrong message" do
52
- lambda do
53
- lambda {raise NameError.new('blarg')}.should raise_error('blah')
54
- end.should fail_with("expected Exception with \"blah\", got #<NameError: blarg>")
55
- end
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
- end
58
-
59
- describe "should_not raise_error(message)" do
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
- it "should pass if any other error is raised with the wrong message" do
66
- lambda {raise NameError.new('blarg')}.should_not raise_error('blah')
67
- end
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
- it "should fail if RuntimeError is raised with message" do
70
- lambda do
71
- lambda {raise 'blah'}.should_not raise_error('blah')
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
- it "should fail if any other error is raised with message" do
76
- lambda do
77
- lambda {raise NameError.new('blah')}.should_not raise_error('blah')
78
- end.should fail_with(%Q|expected no Exception with "blah", got #<NameError: blah>|)
79
- end
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
- end
82
-
83
- describe "should raise_error(NamedError)" do
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
- it "should fail if nothing is raised" do
90
- lambda {
91
- lambda { }.should raise_error(NameError)
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
- it "should fail if another error is raised (NameError)" do
96
- lambda {
97
- lambda { raise }.should raise_error(NameError)
98
- }.should fail_with("expected NameError, got RuntimeError")
99
- end
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
- it "should fail if another error is raised (NameError)" do
102
- lambda {
103
- lambda { load "non/existent/file" }.should raise_error(NameError)
104
- }.should fail_with(/expected NameError, got #<LoadError/)
105
- end
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
- end
108
-
109
- describe "should_not raise_error(NamedError)" do
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
- it "should pass if another error is raised" do
116
- lambda { raise }.should_not raise_error(NameError)
117
- end
113
+ it "should pass if nothing is raised" do
114
+ lambda { }.should_not raise_error(NameError)
115
+ end
118
116
 
119
- it "should fail if named error is raised" do
120
- lambda {
121
- lambda { non_existent_method }.should_not raise_error(NameError)
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
- end
126
-
127
- describe "should raise_error(NamedError, error_message) with String" do
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
- it "should fail if nothing is raised" do
134
- lambda {
135
- lambda {}.should raise_error(RuntimeError, "example message")
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
- it "should fail if incorrect error is raised" do
140
- lambda {
141
- lambda { raise }.should raise_error(NameError, "example message")
142
- }.should fail_with("expected NameError with \"example message\", got RuntimeError")
143
- end
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
- it "should fail if correct error is raised with incorrect message" do
146
- lambda {
147
- lambda { raise RuntimeError.new("not the example message") }.should raise_error(RuntimeError, "example message")
148
- }.should fail_with(/expected RuntimeError with \"example message\", got #<RuntimeError: not the example message/)
149
- end
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
- end
152
-
153
- describe "should raise_error(NamedError, error_message) { |err| ... }" do
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
- it "yielded block should be able to fail on it's own right" do
170
- ran, passed = false, false
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
- 5.should == 4
178
- passed = true
164
+ err.class.should == RuntimeError
165
+ err.message.should == "example message"
179
166
  }
180
- }.should fail_with(/expected: 4/m)
181
167
 
182
- ran.should == true
183
- passed.should == false
184
- end
168
+ ran.should == true
169
+ end
185
170
 
186
- it "should NOT yield exception if no error was thrown" do
187
- ran = false
171
+ it "yielded block should be able to fail on it's own right" do
172
+ ran, passed = false, false
188
173
 
189
- lambda {
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")
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
- ran.should == false
196
- end
182
+ ran.should == true
183
+ passed.should == false
184
+ end
197
185
 
198
- it "should not yield exception if error class is not matched" do
199
- ran = false
186
+ it "should NOT yield exception if no error was thrown" do
187
+ ran = false
200
188
 
201
- lambda {
202
189
  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>")
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
- ran.should == false
210
- end
195
+ ran.should == false
196
+ end
211
197
 
212
- it "should NOT yield exception if error message is not matched" do
213
- ran = false
198
+ it "should not yield exception if error class is not matched" do
199
+ ran = false
214
200
 
215
- lambda {
216
201
  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>")
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
- ran.should == false
224
- end
225
-
226
- end
209
+ ran.should == false
210
+ end
227
211
 
228
- describe "should_not raise_error(NamedError, error_message) { |err| ... }" do
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
- lambda {}.should_not raise_error(RuntimeError, "example message") { |err|
234
- ran = true
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
- ran.should == false
223
+ ran.should == false
224
+ end
225
+
238
226
  end
239
227
 
240
- it "should pass if a different error is raised" do
241
- ran = false
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
- lambda { raise }.should_not raise_error(NameError, "example message") { |err|
244
- ran = true
245
- }
233
+ lambda {}.should_not raise_error(RuntimeError, "example message") { |err|
234
+ ran = true
235
+ }
246
236
 
247
- ran.should == false
248
- end
237
+ ran.should == false
238
+ end
249
239
 
250
- it "should pass if same error is raised with different message" do
251
- ran = false
240
+ it "should pass if a different error is raised" do
241
+ ran = false
252
242
 
253
- lambda {
254
- raise RuntimeError.new("not the example message")
255
- }.should_not raise_error(RuntimeError, "example message") { |err|
256
- ran = true
257
- }
243
+ lambda { raise }.should_not raise_error(NameError, "example message") { |err|
244
+ ran = true
245
+ }
258
246
 
259
- ran.should == false
260
- end
247
+ ran.should == false
248
+ end
261
249
 
262
- it "should fail if named error is raised with same message" do
263
- ran = false
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
- ran.should == false
274
- end
275
-
276
- end
259
+ ran.should == false
260
+ end
277
261
 
278
- describe "should_not raise_error(NamedError, error_message) with String" do
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
- it "should pass if a different error is raised" do
285
- lambda { raise }.should_not raise_error(NameError, "example message")
286
- end
280
+ it "should pass if nothing is raised" do
281
+ lambda {}.should_not raise_error(RuntimeError, "example message")
282
+ end
287
283
 
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
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
- 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
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
- end
299
-
300
- describe "should raise_error(NamedError, error_message) with Regexp" do
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
- 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
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
- 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
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
- 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
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
- end
325
-
326
- describe "should_not raise_error(NamedError, error_message) with Regexp" do
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
- it "should pass if a different error is raised" do
333
- lambda { raise }.should_not raise_error(NameError, /ample mess/)
334
- end
328
+ it "should pass if nothing is raised" do
329
+ lambda {}.should_not raise_error(RuntimeError, /ample mess/)
330
+ end
335
331
 
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
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