rspec-expectations 2.13.0 → 2.14.0
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/Changelog.md +46 -0
- data/README.md +43 -87
- data/features/README.md +8 -9
- data/features/built_in_matchers/README.md +41 -41
- data/features/built_in_matchers/be_within.feature +3 -3
- data/features/built_in_matchers/expect_change.feature +6 -6
- data/features/built_in_matchers/expect_error.feature +2 -2
- data/features/built_in_matchers/start_with.feature +1 -1
- data/features/built_in_matchers/throw_symbol.feature +11 -11
- data/features/built_in_matchers/yield.feature +18 -3
- data/features/custom_matchers/define_diffable_matcher.feature +1 -1
- data/features/custom_matchers/define_matcher_outside_rspec.feature +6 -6
- data/features/custom_matchers/define_matcher_with_fluent_interface.feature +1 -1
- data/features/customized_message.feature +1 -1
- data/features/support/env.rb +10 -1
- data/features/syntax_configuration.feature +3 -0
- data/features/test_frameworks/test_unit.feature +15 -17
- data/lib/rspec/expectations/deprecation.rb +12 -33
- data/lib/rspec/expectations/differ.rb +25 -7
- data/lib/rspec/expectations/expectation_target.rb +7 -8
- data/lib/rspec/expectations/extensions/object.rb +2 -12
- data/lib/rspec/expectations/fail_with.rb +11 -1
- data/lib/rspec/expectations/handler.rb +11 -6
- data/lib/rspec/expectations/syntax.rb +2 -2
- data/lib/rspec/expectations/version.rb +1 -1
- data/lib/rspec/expectations.rb +1 -1
- data/lib/rspec/matchers/be_close.rb +1 -1
- data/lib/rspec/matchers/built_in/be.rb +2 -0
- data/lib/rspec/matchers/built_in/be_within.rb +1 -1
- data/lib/rspec/matchers/built_in/change.rb +9 -1
- data/lib/rspec/matchers/built_in/have.rb +20 -4
- data/lib/rspec/matchers/built_in/include.rb +2 -10
- data/lib/rspec/matchers/built_in/raise_error.rb +23 -7
- data/lib/rspec/matchers/built_in/yield.rb +78 -3
- data/lib/rspec/matchers/operator_matcher.rb +1 -1
- data/lib/rspec/matchers/pretty.rb +7 -1
- data/lib/rspec/matchers/test_unit_integration.rb +11 -0
- data/lib/rspec/matchers.rb +141 -143
- data/spec/rspec/expectations/differ_spec.rb +27 -5
- data/spec/rspec/expectations/expectation_target_spec.rb +10 -3
- data/spec/rspec/expectations/extensions/kernel_spec.rb +5 -5
- data/spec/rspec/expectations/fail_with_spec.rb +19 -0
- data/spec/rspec/expectations/handler_spec.rb +42 -21
- data/spec/rspec/expectations/syntax_spec.rb +45 -3
- data/spec/rspec/matchers/be_close_spec.rb +6 -6
- data/spec/rspec/matchers/be_spec.rb +36 -36
- data/spec/rspec/matchers/be_within_spec.rb +8 -0
- data/spec/rspec/matchers/change_spec.rb +17 -6
- data/spec/rspec/matchers/configuration_spec.rb +57 -89
- data/spec/rspec/matchers/description_generation_spec.rb +16 -2
- data/spec/rspec/matchers/exist_spec.rb +9 -9
- data/spec/rspec/matchers/has_spec.rb +1 -1
- data/spec/rspec/matchers/have_spec.rb +12 -2
- data/spec/rspec/matchers/include_matcher_integration_spec.rb +2 -2
- data/spec/rspec/matchers/include_spec.rb +4 -4
- data/spec/rspec/matchers/match_array_spec.rb +1 -1
- data/spec/rspec/matchers/match_spec.rb +1 -1
- data/spec/rspec/matchers/raise_error_spec.rb +189 -99
- data/spec/rspec/matchers/respond_to_spec.rb +4 -4
- data/spec/rspec/matchers/satisfy_spec.rb +1 -1
- data/spec/rspec/matchers/start_with_end_with_spec.rb +2 -2
- data/spec/rspec/matchers/yield_spec.rb +81 -4
- data/spec/spec_helper.rb +1 -1
- metadata +8 -7
|
@@ -10,6 +10,25 @@ describe "expect { ... }.to raise_error" do
|
|
|
10
10
|
expect {raise}.to raise_error
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
it "passes if an error instance is expected" do
|
|
14
|
+
s = StandardError.new
|
|
15
|
+
expect {raise s}.to raise_error(s)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "fails if a different error instance is thrown from the one that is expected" do
|
|
19
|
+
s = StandardError.new :bees
|
|
20
|
+
to_raise = StandardError.new(:faces)
|
|
21
|
+
expect do
|
|
22
|
+
expect {raise to_raise}.to raise_error(s)
|
|
23
|
+
end.to fail_with(Regexp.new("expected #{s.inspect}, got #{to_raise.inspect} with backtrace"))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "passes if an error class is expected and an instance of that class is thrown" do
|
|
27
|
+
s = StandardError.new :bees
|
|
28
|
+
|
|
29
|
+
expect { raise s }.to raise_error(StandardError)
|
|
30
|
+
end
|
|
31
|
+
|
|
13
32
|
it "fails if nothing is raised" do
|
|
14
33
|
expect {
|
|
15
34
|
expect {}.to raise_error
|
|
@@ -41,36 +60,53 @@ describe "expect { ... }.to raise_error {|err| ... }" do
|
|
|
41
60
|
end
|
|
42
61
|
end
|
|
43
62
|
|
|
44
|
-
describe "expect { ... }.
|
|
45
|
-
it "passes if nothing is raised" do
|
|
46
|
-
expect {}.to_not raise_error
|
|
47
|
-
end
|
|
63
|
+
describe "expect { ... }.not_to raise_error" do
|
|
48
64
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
context "with a specific error class" do
|
|
66
|
+
it "is deprecated" do
|
|
67
|
+
RSpec.should_receive :deprecate
|
|
68
|
+
expect {"bees"}.not_to raise_error(RuntimeError)
|
|
69
|
+
end
|
|
53
70
|
end
|
|
54
71
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
expect(
|
|
61
|
-
|
|
62
|
-
end
|
|
72
|
+
context "with no specific error class" do
|
|
73
|
+
it "is not deprecated" do
|
|
74
|
+
run = nil
|
|
75
|
+
allow(RSpec).to receive(:deprecate) { run = true }
|
|
76
|
+
expect {"bees"}.not_to raise_error
|
|
77
|
+
expect(run).to be_nil
|
|
78
|
+
end
|
|
63
79
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
and_return("formatted-backtrace")
|
|
80
|
+
it "passes if nothing is raised" do
|
|
81
|
+
expect {}.not_to raise_error
|
|
82
|
+
end
|
|
68
83
|
|
|
69
|
-
|
|
70
|
-
expect {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
it "fails if anything is raised" do
|
|
85
|
+
expect {
|
|
86
|
+
expect { raise RuntimeError, "example message" }.not_to raise_error
|
|
87
|
+
}.to fail_with(/expected no Exception, got #<RuntimeError: example message>/)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'includes the backtrace of the error that was raised in the error message' do
|
|
91
|
+
expect {
|
|
92
|
+
expect { raise "boom" }.not_to raise_error
|
|
93
|
+
}.to raise_error { |e|
|
|
94
|
+
backtrace_line = "#{File.basename(__FILE__)}:#{__LINE__ - 2}"
|
|
95
|
+
expect(e.message).to include("with backtrace", backtrace_line)
|
|
96
|
+
}
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'formats the backtrace using the configured backtrace formatter' do
|
|
100
|
+
RSpec::Matchers.configuration.backtrace_formatter.
|
|
101
|
+
stub(:format_backtrace).
|
|
102
|
+
and_return("formatted-backtrace")
|
|
103
|
+
|
|
104
|
+
expect {
|
|
105
|
+
expect { raise "boom" }.not_to raise_error
|
|
106
|
+
}.to raise_error { |e|
|
|
107
|
+
expect(e.message).to include("with backtrace", "formatted-backtrace")
|
|
108
|
+
}
|
|
109
|
+
end
|
|
74
110
|
end
|
|
75
111
|
end
|
|
76
112
|
|
|
@@ -109,24 +145,33 @@ describe "expect { ... }.to raise_error(message)" do
|
|
|
109
145
|
end
|
|
110
146
|
end
|
|
111
147
|
|
|
112
|
-
describe "expect { ... }.
|
|
148
|
+
describe "expect { ... }.not_to raise_error(message)" do
|
|
149
|
+
before do
|
|
150
|
+
allow(RSpec).to receive(:deprecate)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it "is deprecated" do
|
|
154
|
+
expect(RSpec).to receive(:deprecate).with(/not_to raise_error\(message\)/, :replacement =>"`expect { }.not_to raise_error()`")
|
|
155
|
+
expect {raise 'blarg'}.not_to raise_error('blah')
|
|
156
|
+
end
|
|
157
|
+
|
|
113
158
|
it "passes if RuntimeError error is raised with the different message" do
|
|
114
|
-
expect {raise 'blarg'}.
|
|
159
|
+
expect {raise 'blarg'}.not_to raise_error('blah')
|
|
115
160
|
end
|
|
116
161
|
|
|
117
162
|
it "passes if any other error is raised with the wrong message" do
|
|
118
|
-
expect {raise NameError.new('blarg')}.
|
|
163
|
+
expect {raise NameError.new('blarg')}.not_to raise_error('blah')
|
|
119
164
|
end
|
|
120
165
|
|
|
121
166
|
it "fails if RuntimeError is raised with message" do
|
|
122
167
|
expect do
|
|
123
|
-
expect {raise 'blah'}.
|
|
168
|
+
expect {raise 'blah'}.not_to raise_error('blah')
|
|
124
169
|
end.to fail_with(/expected no Exception with "blah", got #<RuntimeError: blah>/)
|
|
125
170
|
end
|
|
126
171
|
|
|
127
172
|
it "fails if any other error is raised with message" do
|
|
128
173
|
expect do
|
|
129
|
-
expect {raise NameError.new('blah')}.
|
|
174
|
+
expect {raise NameError.new('blah')}.not_to raise_error('blah')
|
|
130
175
|
end.to fail_with(/expected no Exception with "blah", got #<NameError: blah>/)
|
|
131
176
|
end
|
|
132
177
|
end
|
|
@@ -155,18 +200,27 @@ describe "expect { ... }.to raise_error(NamedError)" do
|
|
|
155
200
|
end
|
|
156
201
|
end
|
|
157
202
|
|
|
158
|
-
describe "expect { ... }.
|
|
203
|
+
describe "expect { ... }.not_to raise_error(NamedError)" do
|
|
204
|
+
before do
|
|
205
|
+
allow(RSpec).to receive(:deprecate)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
it "is deprecated" do
|
|
209
|
+
expect(RSpec).to receive(:deprecate).with(/not_to raise_error\(SpecificErrorClass\)/, :replacement => "`expect { }.not_to raise_error()`")
|
|
210
|
+
expect { }.not_to raise_error(NameError)
|
|
211
|
+
end
|
|
212
|
+
|
|
159
213
|
it "passes if nothing is raised" do
|
|
160
|
-
expect { }.
|
|
214
|
+
expect { }.not_to raise_error(NameError)
|
|
161
215
|
end
|
|
162
216
|
|
|
163
217
|
it "passes if another error is raised" do
|
|
164
|
-
expect { raise }.
|
|
218
|
+
expect { raise }.not_to raise_error(NameError)
|
|
165
219
|
end
|
|
166
220
|
|
|
167
221
|
it "fails if named error is raised" do
|
|
168
222
|
expect {
|
|
169
|
-
expect { 1 + 'b' }.
|
|
223
|
+
expect { 1 + 'b' }.not_to raise_error(TypeError)
|
|
170
224
|
}.to fail_with(/expected no TypeError, got #<TypeError: String can't be/)
|
|
171
225
|
end
|
|
172
226
|
end
|
|
@@ -195,6 +249,88 @@ describe "expect { ... }.to raise_error(NamedError, error_message) with String"
|
|
|
195
249
|
end
|
|
196
250
|
end
|
|
197
251
|
|
|
252
|
+
describe "expect { ... }.not_to raise_error(NamedError, error_message) with String" do
|
|
253
|
+
before do
|
|
254
|
+
allow(RSpec).to receive(:deprecate)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
it "is deprecated" do
|
|
258
|
+
expect(RSpec).to receive(:deprecate).with(/not_to raise_error\(SpecificErrorClass, message\)/, :replacement =>"`expect { }.not_to raise_error()`")
|
|
259
|
+
expect {}.not_to raise_error(RuntimeError, "example message")
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
it "passes if nothing is raised" do
|
|
263
|
+
expect {}.not_to raise_error(RuntimeError, "example message")
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
it "passes if a different error is raised" do
|
|
267
|
+
expect { raise }.not_to raise_error(NameError, "example message")
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
it "passes if same error is raised with different message" do
|
|
271
|
+
expect { raise RuntimeError.new("not the example message") }.not_to raise_error(RuntimeError, "example message")
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
it "fails if named error is raised with same message" do
|
|
275
|
+
expect {
|
|
276
|
+
expect { raise "example message" }.not_to raise_error(RuntimeError, "example message")
|
|
277
|
+
}.to fail_with(/expected no RuntimeError with \"example message\", got #<RuntimeError: example message>/)
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
describe "expect { ... }.to raise_error(NamedError, error_message) with Regexp" do
|
|
282
|
+
it "passes if named error is raised with matching message" do
|
|
283
|
+
expect { raise "example message" }.to raise_error(RuntimeError, /ample mess/)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
it "fails if nothing is raised" do
|
|
287
|
+
expect {
|
|
288
|
+
expect {}.to raise_error(RuntimeError, /ample mess/)
|
|
289
|
+
}.to fail_with(/expected RuntimeError with message matching \/ample mess\/ but nothing was raised/)
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
it "fails if incorrect error is raised" do
|
|
293
|
+
expect {
|
|
294
|
+
expect { raise RuntimeError, "example message" }.to raise_error(NameError, /ample mess/)
|
|
295
|
+
}.to fail_with(/expected NameError with message matching \/ample mess\/, got #<RuntimeError: example message>/)
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
it "fails if correct error is raised with incorrect message" do
|
|
299
|
+
expect {
|
|
300
|
+
expect { raise RuntimeError.new("not the example message") }.to raise_error(RuntimeError, /less than ample mess/)
|
|
301
|
+
}.to fail_with(/expected RuntimeError with message matching \/less than ample mess\/, got #<RuntimeError: not the example message>/)
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
describe "expect { ... }.not_to raise_error(NamedError, error_message) with Regexp" do
|
|
306
|
+
before do
|
|
307
|
+
allow(RSpec).to receive(:deprecate)
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
it "is deprecated" do
|
|
311
|
+
expect(RSpec).to receive(:deprecate)
|
|
312
|
+
expect {}.not_to raise_error(RuntimeError, /ample mess/)
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
it "passes if nothing is raised" do
|
|
316
|
+
expect {}.not_to raise_error(RuntimeError, /ample mess/)
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
it "passes if a different error is raised" do
|
|
320
|
+
expect { raise }.not_to raise_error(NameError, /ample mess/)
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
it "passes if same error is raised with non-matching message" do
|
|
324
|
+
expect { raise RuntimeError.new("non matching message") }.not_to raise_error(RuntimeError, /ample mess/)
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
it "fails if named error is raised with matching message" do
|
|
328
|
+
expect {
|
|
329
|
+
expect { raise "example message" }.not_to raise_error(RuntimeError, /ample mess/)
|
|
330
|
+
}.to fail_with(/expected no RuntimeError with message matching \/ample mess\/, got #<RuntimeError: example message>/)
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
|
|
198
334
|
describe "expect { ... }.to raise_error(NamedError, error_message) { |err| ... }" do
|
|
199
335
|
it "yields exception if named error is raised with same message" do
|
|
200
336
|
ran = false
|
|
@@ -268,11 +404,20 @@ describe "expect { ... }.to raise_error(NamedError, error_message) { |err| ... }
|
|
|
268
404
|
end
|
|
269
405
|
end
|
|
270
406
|
|
|
271
|
-
describe "expect { ... }.
|
|
407
|
+
describe "expect { ... }.not_to raise_error(NamedError, error_message) { |err| ... }" do
|
|
408
|
+
before do
|
|
409
|
+
allow(RSpec).to receive(:deprecate)
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
it "is deprecated" do
|
|
413
|
+
expect(RSpec).to receive(:deprecate)
|
|
414
|
+
expect {}.not_to raise_error(RuntimeError, "example message") { |err| }
|
|
415
|
+
end
|
|
416
|
+
|
|
272
417
|
it "passes if nothing is raised" do
|
|
273
418
|
ran = false
|
|
274
419
|
|
|
275
|
-
expect {}.
|
|
420
|
+
expect {}.not_to raise_error(RuntimeError, "example message") { |err|
|
|
276
421
|
ran = true
|
|
277
422
|
}
|
|
278
423
|
|
|
@@ -282,7 +427,7 @@ describe "expect { ... }.to_not raise_error(NamedError, error_message) { |err| .
|
|
|
282
427
|
it "passes if a different error is raised" do
|
|
283
428
|
ran = false
|
|
284
429
|
|
|
285
|
-
expect { raise }.
|
|
430
|
+
expect { raise }.not_to raise_error(NameError, "example message") { |err|
|
|
286
431
|
ran = true
|
|
287
432
|
}
|
|
288
433
|
|
|
@@ -294,7 +439,7 @@ describe "expect { ... }.to_not raise_error(NamedError, error_message) { |err| .
|
|
|
294
439
|
|
|
295
440
|
expect {
|
|
296
441
|
raise RuntimeError.new("not the example message")
|
|
297
|
-
}.
|
|
442
|
+
}.not_to raise_error(RuntimeError, "example message") { |err|
|
|
298
443
|
ran = true
|
|
299
444
|
}
|
|
300
445
|
|
|
@@ -307,7 +452,7 @@ describe "expect { ... }.to_not raise_error(NamedError, error_message) { |err| .
|
|
|
307
452
|
expect {
|
|
308
453
|
expect {
|
|
309
454
|
raise "example message"
|
|
310
|
-
}.
|
|
455
|
+
}.not_to raise_error(RuntimeError, "example message") { |err|
|
|
311
456
|
ran = true
|
|
312
457
|
}
|
|
313
458
|
}.to fail_with(/expected no RuntimeError with \"example message\", got #<RuntimeError: example message>/)
|
|
@@ -330,66 +475,11 @@ describe "expect { ... }.to_not raise_error(NamedError, error_message) { |err| .
|
|
|
330
475
|
end
|
|
331
476
|
end
|
|
332
477
|
|
|
333
|
-
describe "
|
|
334
|
-
it "
|
|
335
|
-
|
|
336
|
-
end
|
|
337
|
-
|
|
338
|
-
it "passes if a different error is raised" do
|
|
339
|
-
expect { raise }.to_not raise_error(NameError, "example message")
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
it "passes if same error is raised with different message" do
|
|
343
|
-
expect { raise RuntimeError.new("not the example message") }.to_not raise_error(RuntimeError, "example message")
|
|
344
|
-
end
|
|
345
|
-
|
|
346
|
-
it "fails if named error is raised with same message" do
|
|
347
|
-
expect {
|
|
348
|
-
expect { raise "example message" }.to_not raise_error(RuntimeError, "example message")
|
|
349
|
-
}.to fail_with(/expected no RuntimeError with \"example message\", got #<RuntimeError: example message>/)
|
|
350
|
-
end
|
|
351
|
-
end
|
|
352
|
-
|
|
353
|
-
describe "expect { ... }.to raise_error(NamedError, error_message) with Regexp" do
|
|
354
|
-
it "passes if named error is raised with matching message" do
|
|
355
|
-
expect { raise "example message" }.to raise_error(RuntimeError, /ample mess/)
|
|
356
|
-
end
|
|
357
|
-
|
|
358
|
-
it "fails if nothing is raised" do
|
|
359
|
-
expect {
|
|
360
|
-
expect {}.to raise_error(RuntimeError, /ample mess/)
|
|
361
|
-
}.to fail_with(/expected RuntimeError with message matching \/ample mess\/ but nothing was raised/)
|
|
362
|
-
end
|
|
363
|
-
|
|
364
|
-
it "fails if incorrect error is raised" do
|
|
365
|
-
expect {
|
|
366
|
-
expect { raise RuntimeError, "example message" }.to raise_error(NameError, /ample mess/)
|
|
367
|
-
}.to fail_with(/expected NameError with message matching \/ample mess\/, got #<RuntimeError: example message>/)
|
|
368
|
-
end
|
|
369
|
-
|
|
370
|
-
it "fails if correct error is raised with incorrect message" do
|
|
371
|
-
expect {
|
|
372
|
-
expect { raise RuntimeError.new("not the example message") }.to raise_error(RuntimeError, /less than ample mess/)
|
|
373
|
-
}.to fail_with(/expected RuntimeError with message matching \/less than ample mess\/, got #<RuntimeError: not the example message>/)
|
|
374
|
-
end
|
|
375
|
-
end
|
|
376
|
-
|
|
377
|
-
describe "expect { ... }.to_not raise_error(NamedError, error_message) with Regexp" do
|
|
378
|
-
it "passes if nothing is raised" do
|
|
379
|
-
expect {}.to_not raise_error(RuntimeError, /ample mess/)
|
|
380
|
-
end
|
|
381
|
-
|
|
382
|
-
it "passes if a different error is raised" do
|
|
383
|
-
expect { raise }.to_not raise_error(NameError, /ample mess/)
|
|
384
|
-
end
|
|
385
|
-
|
|
386
|
-
it "passes if same error is raised with non-matching message" do
|
|
387
|
-
expect { raise RuntimeError.new("non matching message") }.to_not raise_error(RuntimeError, /ample mess/)
|
|
388
|
-
end
|
|
389
|
-
|
|
390
|
-
it "fails if named error is raised with matching message" do
|
|
478
|
+
describe "misuse of raise_error, with (), not {}" do
|
|
479
|
+
it "fails with warning" do
|
|
480
|
+
::Kernel.should_receive(:warn).with(/`raise_error` was called with non-proc object 1\.7/)
|
|
391
481
|
expect {
|
|
392
|
-
expect
|
|
393
|
-
}.to fail_with(/
|
|
482
|
+
expect(Math.sqrt(3)).to raise_error
|
|
483
|
+
}.to fail_with(/nothing was raised/)
|
|
394
484
|
end
|
|
395
485
|
end
|
|
@@ -148,7 +148,7 @@ describe "expect(...).to respond_to(:sym).with(2).arguments" do
|
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
150
|
|
|
151
|
-
describe "expect(...).
|
|
151
|
+
describe "expect(...).not_to respond_to(:sym)" do
|
|
152
152
|
it "passes if target does not respond to :sym" do
|
|
153
153
|
expect(Object.new).not_to respond_to(:some_method)
|
|
154
154
|
end
|
|
@@ -160,7 +160,7 @@ describe "expect(...).to_not respond_to(:sym)" do
|
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
|
|
163
|
-
describe "expect(...).
|
|
163
|
+
describe "expect(...).not_to respond_to(:sym).with(1).argument" do
|
|
164
164
|
it "fails if target responds to :sym with 1 arg" do
|
|
165
165
|
obj = Object.new
|
|
166
166
|
def obj.foo(arg); end
|
|
@@ -209,7 +209,7 @@ describe "expect(...).to_not respond_to(:sym).with(1).argument" do
|
|
|
209
209
|
end
|
|
210
210
|
end
|
|
211
211
|
|
|
212
|
-
describe "expect(...).
|
|
212
|
+
describe "expect(...).not_to respond_to(message1, message2)" do
|
|
213
213
|
it "passes if target does not respond to either message1 or message2" do
|
|
214
214
|
expect(Object.new).not_to respond_to(:some_method, :some_other_method)
|
|
215
215
|
end
|
|
@@ -233,7 +233,7 @@ describe "expect(...).to_not respond_to(message1, message2)" do
|
|
|
233
233
|
end
|
|
234
234
|
end
|
|
235
235
|
|
|
236
|
-
describe "expect(...).
|
|
236
|
+
describe "expect(...).not_to respond_to(:sym).with(2).arguments" do
|
|
237
237
|
it "fails if target responds to :sym with 2 args" do
|
|
238
238
|
obj = Object.new
|
|
239
239
|
def obj.foo(a1, a2); end
|
|
@@ -28,7 +28,7 @@ describe "expect(...).to satisfy { block }" do
|
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
describe "expect(...).
|
|
31
|
+
describe "expect(...).not_to satisfy { block }" do
|
|
32
32
|
it "passes if block returns false" do
|
|
33
33
|
expect(false).not_to satisfy { |val| val }
|
|
34
34
|
expect(false).not_to satisfy do |val|
|
|
@@ -56,7 +56,7 @@ describe "expect(...).to start_with" do
|
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
describe "expect(...).
|
|
59
|
+
describe "expect(...).not_to start_with" do
|
|
60
60
|
context "with a string" do
|
|
61
61
|
it "passes if it does not match the start of the actual string" do
|
|
62
62
|
expect("this string").not_to start_with "that str"
|
|
@@ -149,7 +149,7 @@ describe "expect(...).to end_with" do
|
|
|
149
149
|
|
|
150
150
|
end
|
|
151
151
|
|
|
152
|
-
describe "expect(...).
|
|
152
|
+
describe "expect(...).not_to end_with" do
|
|
153
153
|
context "with a sting" do
|
|
154
154
|
it "passes if it does not match the end of the actual string" do
|
|
155
155
|
expect("this string").not_to end_with "stringy"
|
|
@@ -63,10 +63,87 @@ describe "yield_control matcher" do
|
|
|
63
63
|
}.to fail_with(/expected given block to yield control/)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
expect {
|
|
69
|
-
|
|
66
|
+
context "with exact count" do
|
|
67
|
+
it 'fails if the block yields wrong number of times' do
|
|
68
|
+
expect {
|
|
69
|
+
expect { |b| [1, 2, 3].each(&b) }.to yield_control.twice
|
|
70
|
+
}.to fail_with(/expected given block to yield control twice/)
|
|
71
|
+
|
|
72
|
+
expect {
|
|
73
|
+
expect { |b| [1, 2].each(&b) }.to yield_control.exactly(3).times
|
|
74
|
+
}.to fail_with(/expected given block to yield control 3 times/)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'passes if the block yields the specified number of times' do
|
|
78
|
+
expect { |b| [1].each(&b) }.to yield_control.once
|
|
79
|
+
expect { |b| [1, 2].each(&b) }.to yield_control.twice
|
|
80
|
+
expect { |b| [1, 2, 3].each(&b) }.to yield_control.exactly(3).times
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
context "with at_least count" do
|
|
85
|
+
it 'passes if the block yields the given number of times' do
|
|
86
|
+
expect { |b| [1, 2].each(&b) }.to yield_control.at_least(2).times
|
|
87
|
+
expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_least(3).times
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'passes if the block yields more times' do
|
|
91
|
+
expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_least(2).times
|
|
92
|
+
expect { |b| [1, 2, 3, 4].each(&b) }.to yield_control.at_least(3).times
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'allows :once and :twice to be passed as counts' do
|
|
96
|
+
expect { |b| [1].each(&b) }.to yield_control.at_least(:once)
|
|
97
|
+
expect { |b| [1, 2].each(&b) }.to yield_control.at_least(:once)
|
|
98
|
+
|
|
99
|
+
expect {
|
|
100
|
+
expect { |b| [].each(&b) }.to yield_control.at_least(:once)
|
|
101
|
+
}.to fail_with(/at least once/)
|
|
102
|
+
|
|
103
|
+
expect { |b| [1, 2].each(&b) }.to yield_control.at_least(:twice)
|
|
104
|
+
expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_least(:twice)
|
|
105
|
+
|
|
106
|
+
expect {
|
|
107
|
+
expect { |b| [1].each(&b) }.to yield_control.at_least(:twice)
|
|
108
|
+
}.to fail_with(/at least twice/)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it 'fails if the block yields too few times' do
|
|
112
|
+
expect {
|
|
113
|
+
expect { |b| _yield_with_no_args(&b) }.to yield_control.at_least(2).times
|
|
114
|
+
}.to fail_with(/expected given block to yield control at least twice/)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
context "with at_most count" do
|
|
119
|
+
it 'passes if the block yields the given number of times' do
|
|
120
|
+
expect { |b| [1, 2].each(&b) }.to yield_control.at_most(2).times
|
|
121
|
+
expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_most(3).times
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'passes if the block yields fewer times' do
|
|
125
|
+
expect { |b| [1, 2].each(&b) }.to yield_control.at_most(3).times
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it 'allows :once and :twice to be passed as counts' do
|
|
129
|
+
expect { |b| [1].each(&b) }.to yield_control.at_most(:once)
|
|
130
|
+
|
|
131
|
+
expect {
|
|
132
|
+
expect { |b| [1, 2].each(&b) }.to yield_control.at_most(:once)
|
|
133
|
+
}.to fail_with(/expected given block to yield control at most once/)
|
|
134
|
+
|
|
135
|
+
expect { |b| [1, 2].each(&b) }.to yield_control.at_most(:twice)
|
|
136
|
+
|
|
137
|
+
expect {
|
|
138
|
+
expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_most(:twice)
|
|
139
|
+
}.to fail_with(/expected given block to yield control at most twice/)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it 'fails if the block yields too many times' do
|
|
143
|
+
expect {
|
|
144
|
+
expect { |b| [1, 2, 3].each(&b) }.to yield_control.at_most(2).times
|
|
145
|
+
}.to fail_with(/expected given block to yield control at most twice/)
|
|
146
|
+
end
|
|
70
147
|
end
|
|
71
148
|
end
|
|
72
149
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: rspec-expectations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 2.
|
|
5
|
+
version: 2.14.0
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Steven Baker
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2013-
|
|
13
|
+
date: 2013-07-06 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -71,7 +71,7 @@ dependencies:
|
|
|
71
71
|
requirements:
|
|
72
72
|
- - ~>
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: 0.
|
|
74
|
+
version: '0.5'
|
|
75
75
|
none: false
|
|
76
76
|
prerelease: false
|
|
77
77
|
name: aruba
|
|
@@ -79,7 +79,7 @@ dependencies:
|
|
|
79
79
|
requirements:
|
|
80
80
|
- - ~>
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.
|
|
82
|
+
version: '0.5'
|
|
83
83
|
none: false
|
|
84
84
|
type: :development
|
|
85
85
|
description: rspec expectations (should[_not] and matchers)
|
|
@@ -135,6 +135,7 @@ files:
|
|
|
135
135
|
- lib/rspec/matchers/method_missing.rb
|
|
136
136
|
- lib/rspec/matchers/operator_matcher.rb
|
|
137
137
|
- lib/rspec/matchers/pretty.rb
|
|
138
|
+
- lib/rspec/matchers/test_unit_integration.rb
|
|
138
139
|
- README.md
|
|
139
140
|
- License.txt
|
|
140
141
|
- Changelog.md
|
|
@@ -232,7 +233,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
232
233
|
version: '0'
|
|
233
234
|
segments:
|
|
234
235
|
- 0
|
|
235
|
-
hash:
|
|
236
|
+
hash: -2919541554530046896
|
|
236
237
|
none: false
|
|
237
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
239
|
requirements:
|
|
@@ -241,14 +242,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
241
242
|
version: '0'
|
|
242
243
|
segments:
|
|
243
244
|
- 0
|
|
244
|
-
hash:
|
|
245
|
+
hash: -2919541554530046896
|
|
245
246
|
none: false
|
|
246
247
|
requirements: []
|
|
247
248
|
rubyforge_project: rspec
|
|
248
249
|
rubygems_version: 1.8.24
|
|
249
250
|
signing_key:
|
|
250
251
|
specification_version: 3
|
|
251
|
-
summary: rspec-expectations-2.
|
|
252
|
+
summary: rspec-expectations-2.14.0
|
|
252
253
|
test_files:
|
|
253
254
|
- features/README.md
|
|
254
255
|
- features/Upgrade.md
|