rspec-mocks 2.99.0.beta2 → 2.99.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b0603e74e956b37b8638b4c7c2bb0c4b9ffd87ab
4
+ data.tar.gz: 0a5d3fc77a83c1d7967f10cb623bbf6423b1764a
5
+ SHA512:
6
+ metadata.gz: 1e89c42e14ca3118f667649a74a48c5e4afb24365e9e056f8de12458c3f13af049f6209363a3871979757cc0f67f6aed37b2426add030b28d84d6bfd9deaf022
7
+ data.tar.gz: 0cb781818c11a2c41f395efcc3b2b7bbdb5dba1730a3dd680c6501a2e473ce3b318d173056d8cdc18b49b487f888ed8aea7cc2eeced2596ad38f0b42b77f4009
data/Changelog.md CHANGED
@@ -1,5 +1,14 @@
1
+ ### 2.99.0.rc1 / 2014-05-18
2
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.beta2...v2.99.0.rc1)
3
+
4
+ Deprecations:
5
+
6
+ * Deprecate `RSpec::Mocks::TestDouble.extend_onto`. (Myron Marston)
7
+ * Deprecate `RSpec::Mocks::ConstantStubber`. (Jon Rowe)
8
+ * Deprecate `Marshal.dump` monkey-patch without opt-in. (Xavier Shay)
9
+
1
10
  ### 2.99.0.beta2 / 2014-02-17
2
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.beta1...v2.99.0.beta2)
11
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.beta1...v2.99.0.beta2)
3
12
 
4
13
  Deprecations:
5
14
 
@@ -14,7 +23,7 @@ Deprecations:
14
23
  * Deprecate `and_return { value }` and `and_return` without arguments. (Yuji Nakayama)
15
24
 
16
25
  ### 2.99.0.beta1 / 2013-11-07
17
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.4...v2.99.0.beta1)
26
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.4...v2.99.0.beta1)
18
27
 
19
28
  Deprecations:
20
29
 
@@ -38,8 +47,16 @@ Enhancements:
38
47
  * Add a config option to yield the receiver to `any_instance` implementation
39
48
  blocks. (Sam Phippen)
40
49
 
50
+ ### 2.14.6 / 2014-02-20
51
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.5...v2.14.6)
52
+
53
+ Bug Fixes:
54
+
55
+ * Ensure `any_instance` method stubs and expectations are torn down regardless of
56
+ expectation failures. (Sam Phippen)
57
+
41
58
  ### 2.14.5 / 2014-02-01
42
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.4...v2.14.5)
59
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.4...v2.14.5)
43
60
 
44
61
  Bug Fixes:
45
62
 
@@ -49,7 +66,7 @@ Bug Fixes:
49
66
  receives a block, too. (Myron Marston)
50
67
 
51
68
  ### 2.14.4 / 2013-10-15
52
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.3...v2.14.4)
69
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.3...v2.14.4)
53
70
 
54
71
  Bug Fixes:
55
72
 
@@ -59,7 +76,7 @@ Bug Fixes:
59
76
  the usage of modifications (`and_return` etc) (Jon Rowe)
60
77
 
61
78
  ### 2.14.3 / 2013-08-08
62
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.2...v2.14.3)
79
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.2...v2.14.3)
63
80
 
64
81
  Bug Fixes:
65
82
 
@@ -67,7 +84,7 @@ Bug Fixes:
67
84
  a prepended Module (Bradley Schaefer)
68
85
 
69
86
  ### 2.14.2 / 2013-07-30
70
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.1...v2.14.2)
87
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.1...v2.14.2)
71
88
 
72
89
  Bug Fixes:
73
90
 
@@ -77,7 +94,7 @@ Bug Fixes:
77
94
  return a test double rather than stub a method (Myron Marston).
78
95
 
79
96
  ### 2.14.1 / 2013-07-07
80
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.0...v2.14.1)
97
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.0...v2.14.1)
81
98
 
82
99
  Bug Fixes:
83
100
 
@@ -89,7 +106,7 @@ Bug Fixes:
89
106
  in 3.0. (Myron Marston)
90
107
 
91
108
  ### 2.14.0 / 2013-07-06
92
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.0.rc1...v2.14.0)
109
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.0.rc1...v2.14.0)
93
110
 
94
111
  Enhancements:
95
112
 
@@ -113,7 +130,7 @@ Bug Fixes:
113
130
  similar preloading gems (Andy Lindeman).
114
131
 
115
132
  ### 2.14.0.rc1 / 2013-05-27
116
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.13.0...v2.14.0.rc1)
133
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.13.0...v2.14.0.rc1)
117
134
 
118
135
  Enhancements:
119
136
 
@@ -162,7 +179,7 @@ Deprecations
162
179
  * Deprecate `at_least(0).times` and `any_number_of_times` (Michi Huber).
163
180
 
164
181
  ### 2.13.1 / 2013-04-06
165
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.13.0...v2.13.1)
182
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.13.0...v2.13.1)
166
183
 
167
184
  Bug fixes
168
185
 
@@ -170,7 +187,7 @@ Bug fixes
170
187
  `and_yield`, `and_raise`, `and_return` or `and_throw` (Myron Marston).
171
188
 
172
189
  ### 2.13.0 / 2013-02-23
173
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.2...v2.13.0)
190
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.2...v2.13.0)
174
191
 
175
192
  Bug fixes
176
193
 
@@ -200,7 +217,7 @@ Bug fixes
200
217
  (Myron Marston).
201
218
 
202
219
  ### 2.12.2 / 2013-01-27
203
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.1...v.2.12.2)
220
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.1...v.2.12.2)
204
221
 
205
222
  Bug fixes
206
223
 
@@ -215,7 +232,7 @@ Bug fixes
215
232
  versions (Andy Lindeman).
216
233
 
217
234
  ### 2.12.1 / 2012-12-21
218
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.0...v2.12.1)
235
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.0...v2.12.1)
219
236
 
220
237
  Bug fixes
221
238
 
@@ -227,7 +244,7 @@ Bug fixes
227
244
  work properly with constant strings that are prefixed with `::` (Myron Marston).
228
245
 
229
246
  ### 2.12.0 / 2012-11-12
230
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.3...v2.12.0)
247
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.3...v2.12.0)
231
248
 
232
249
  Enhancements
233
250
 
@@ -243,7 +260,7 @@ Deprecations:
243
260
  (Neha Kumari)
244
261
 
245
262
  ### 2.11.3 / 2012-09-19
246
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.2...v2.11.3)
263
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.2...v2.11.3)
247
264
 
248
265
  Bug fixes
249
266
 
@@ -257,7 +274,7 @@ Bug fixes
257
274
  extra time with the wrong arguments (Myron Marston).
258
275
 
259
276
  ### 2.11.2 / 2012-08-11
260
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.1...v2.11.2)
277
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.1...v2.11.2)
261
278
 
262
279
  Bug fixes
263
280
 
@@ -269,7 +286,7 @@ Bug fixes
269
286
  Marston)
270
287
 
271
288
  ### 2.11.1 / 2012-07-09
272
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.0...v2.11.1)
289
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.0...v2.11.1)
273
290
 
274
291
  Bug fixes
275
292
 
@@ -279,7 +296,7 @@ Bug fixes
279
296
  overriden with the null object implementation--`return self`). (Myron Marston)
280
297
 
281
298
  ### 2.11.0 / 2012-07-07
282
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.10.1...v2.11.0)
299
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.10.1...v2.11.0)
283
300
 
284
301
  Enhancements
285
302
 
@@ -304,7 +321,7 @@ Bug fixes
304
321
  `Exception` by default, just like ruby does. (Andrew Marshall)
305
322
 
306
323
  ### 2.10.1 / 2012-05-05
307
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.10.0...v2.10.1)
324
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.10.0...v2.10.1)
308
325
 
309
326
  Bug fixes
310
327
 
@@ -314,14 +331,14 @@ Bug fixes
314
331
  * fixed failure of `object.should_not_receive(:message).and_return value`
315
332
 
316
333
  ### 2.10.0 / 2012-05-03
317
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.9.0...v2.10.0)
334
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.9.0...v2.10.0)
318
335
 
319
336
  Bug fixes
320
337
 
321
338
  * fail fast when an `exactly` or `at_most` expectation is exceeded
322
339
 
323
340
  ### 2.9.0 / 2012-03-17
324
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0...v2.9.0)
341
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0...v2.9.0)
325
342
 
326
343
  Enhancements
327
344
 
@@ -336,19 +353,19 @@ Bug fixes
336
353
 
337
354
  ### 2.8.0 / 2012-01-04
338
355
 
339
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0.rc2...v2.8.0)
356
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0.rc2...v2.8.0)
340
357
 
341
358
  No changes for this release. Just releasing with the other rspec gems.
342
359
 
343
360
  ### 2.8.0.rc2 / 2011-12-19
344
361
 
345
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0.rc1...v2.8.0.rc2)
362
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0.rc1...v2.8.0.rc2)
346
363
 
347
364
  No changes for this release. Just releasing with the other rspec gems.
348
365
 
349
366
  ### 2.8.0.rc1 / 2011-11-06
350
367
 
351
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.7.0...v2.8.0.rc1)
368
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.7.0...v2.8.0.rc1)
352
369
 
353
370
  Enhancements
354
371
 
@@ -356,7 +373,7 @@ Enhancements
356
373
 
357
374
  ### 2.7.0 / 2011-10-16
358
375
 
359
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.6.0...v2.7.0)
376
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.6.0...v2.7.0)
360
377
 
361
378
  Enhancements
362
379
 
@@ -379,7 +396,7 @@ Bug fixes
379
396
 
380
397
  ### 2.6.0 / 2011-05-12
381
398
 
382
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.5.0...v2.6.0)
399
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.5.0...v2.6.0)
383
400
 
384
401
  Enhancements
385
402
 
@@ -393,7 +410,7 @@ Bug fixes
393
410
 
394
411
  ### 2.5.0 / 2011-02-05
395
412
 
396
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.4.0...v2.5.0)
413
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.4.0...v2.5.0)
397
414
 
398
415
  Bug fixes
399
416
 
@@ -404,14 +421,14 @@ Bug fixes
404
421
 
405
422
  ### 2.4.0 / 2011-01-02
406
423
 
407
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.3.0...v2.4.0)
424
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.3.0...v2.4.0)
408
425
 
409
426
  No functional changes in this release, which was made to align with the
410
427
  rspec-core-2.4.0 release.
411
428
 
412
429
  ### 2.3.0 / 2010-12-12
413
430
 
414
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.2.0...v2.3.0)
431
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.2.0...v2.3.0)
415
432
 
416
433
  Bug fixes
417
434
 
@@ -420,7 +437,7 @@ Bug fixes
420
437
 
421
438
  ### 2.2.0 / 2010-11-28
422
439
 
423
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.1.0...v2.2.0)
440
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.1.0...v2.2.0)
424
441
 
425
442
  Enhancements
426
443
 
@@ -434,7 +451,7 @@ Bug fix
434
451
 
435
452
  ### 2.1.0 / 2010-11-07
436
453
 
437
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.1...v2.1.0)
454
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.1...v2.1.0)
438
455
 
439
456
  Bug fixes
440
457
 
@@ -442,11 +459,11 @@ Bug fixes
442
459
 
443
460
  ### 2.0.0 / 2010-10-10
444
461
 
445
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.22...v2.0.0)
462
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.22...v2.0.0)
446
463
 
447
464
  ### 2.0.0.rc / 2010-10-05
448
465
 
449
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.22...v2.0.0.rc)
466
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.22...v2.0.0.rc)
450
467
 
451
468
  Enhancements
452
469
 
@@ -460,7 +477,7 @@ Bug fixes
460
477
 
461
478
  ### 2.0.0.beta.22 / 2010-09-12
462
479
 
463
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.20...v2.0.0.beta.22)
480
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.20...v2.0.0.beta.22)
464
481
 
465
482
  Bug fixes
466
483
 
data/lib/rspec/mocks.rb CHANGED
@@ -2,7 +2,6 @@ require 'rspec/mocks/framework'
2
2
  require 'rspec/mocks/version'
3
3
 
4
4
  module RSpec
5
-
6
5
  module Mocks
7
6
  class << self
8
7
  attr_accessor :space
@@ -108,6 +107,20 @@ module RSpec
108
107
  IGNORED_BACKTRACE_LINE = 'this backtrace line is ignored'
109
108
 
110
109
  self.space = RSpec::Mocks::Space.new
110
+
111
+ DEPRECATED_CONSTANTS =
112
+ {
113
+ :Mock => Double,
114
+ :ConstantStubber => ConstantMutator,
115
+ }
116
+
117
+ def self.const_missing(name)
118
+ if const = DEPRECATED_CONSTANTS[name]
119
+ RSpec.deprecate("RSpec::Mocks::#{name}", :replacement => const.name)
120
+ const
121
+ else
122
+ super
123
+ end
124
+ end
111
125
  end
112
126
  end
113
-
@@ -88,9 +88,6 @@ module RSpec
88
88
  if @expectation_set && !message_chains.all_expectations_fulfilled?
89
89
  raise RSpec::Mocks::MockExpectationError, "Exactly one instance should have received the following message(s) but didn't: #{message_chains.unfulfilled_expectations.sort.join(', ')}"
90
90
  end
91
- ensure
92
- stop_all_observation!
93
- ::RSpec::Mocks.space.remove_any_instance_recorder_for(@klass)
94
91
  end
95
92
 
96
93
  # @private
@@ -6,6 +6,7 @@ module RSpec
6
6
  def initialize
7
7
  @yield_receiver_to_any_instance_implementation_blocks = false
8
8
  @should_warn_about_any_instance_blocks = true
9
+ @marshal_patched = false
9
10
  end
10
11
 
11
12
  def yield_receiver_to_any_instance_implementation_blocks?
@@ -62,6 +63,14 @@ module RSpec
62
63
  syntaxes << :expect if Syntax.expect_enabled?
63
64
  syntaxes
64
65
  end
66
+
67
+ def patch_marshal_to_support_partial_doubles=(val)
68
+ @marshal_patched = val
69
+ end
70
+
71
+ def marshal_patched?
72
+ @marshal_patched
73
+ end
65
74
  end
66
75
 
67
76
  def self.configuration
@@ -6,6 +6,21 @@ module Marshal
6
6
  if ::RSpec::Mocks.space.nil? || !::RSpec::Mocks.space.registered?(object) || NilClass === object
7
7
  dump_without_mocks(object, *rest)
8
8
  else
9
+ unless ::RSpec::Mocks.configuration.marshal_patched?
10
+ RSpec.warn_deprecation(<<-EOS.gsub(/^\s+\|/, ''))
11
+ |Using Marshal.dump on stubbed objects relies on a monkey-patch
12
+ |that is being made opt-in in RSpec 3. To silence this warning
13
+ |please explicitly enable it:
14
+ |
15
+ |RSpec.configure do |rspec|
16
+ | rspec.mock_with :rspec do |mocks|
17
+ | mocks.patch_marshal_to_support_partial_doubles = true
18
+ | end
19
+ |end
20
+ |
21
+ |Called from #{RSpec::CallerFilter.first_non_rspec_line}."
22
+ EOS
23
+ end
9
24
  dump_without_mocks(object.dup, *rest)
10
25
  end
11
26
  end
@@ -3,12 +3,5 @@ module RSpec
3
3
  class Double
4
4
  include TestDouble
5
5
  end
6
-
7
- def self.const_missing(name)
8
- return super unless name == :Mock
9
- RSpec.deprecate("RSpec::Mocks::Mock", :replacement => "RSpec::Mocks::Double")
10
- Double
11
- end
12
6
  end
13
7
  end
14
-
@@ -399,11 +399,5 @@ module RSpec
399
399
  end
400
400
  end
401
401
  end
402
-
403
- # Keeps backwards compatibility since we had released an rspec-mocks that
404
- # only supported stubbing. Later, we released the hide_const feature and
405
- # decided that the term "mutator" was a better term to wrap up the concept
406
- # of both stubbing and hiding.
407
- ConstantStubber = ConstantMutator
408
402
  end
409
403
  end
@@ -29,6 +29,11 @@ module RSpec
29
29
  end
30
30
 
31
31
  proxies.clear
32
+
33
+ any_instance_recorders.each_value do |recorder|
34
+ recorder.stop_all_observation!
35
+ end
36
+
32
37
  any_instance_recorders.clear
33
38
  expectation_ordering.clear
34
39
  end
@@ -45,10 +50,6 @@ module RSpec
45
50
  end
46
51
  end
47
52
 
48
- def remove_any_instance_recorder_for(klass)
49
- any_instance_recorders.delete(klass.__id__)
50
- end
51
-
52
53
  def proxies_of(klass)
53
54
  proxies.values.select { |proxy| klass === proxy.object }
54
55
  end
@@ -13,6 +13,7 @@ module RSpec
13
13
  # RSpec::Mocks::TestDouble.extend_onto(module, "MyMixin", :foo => "bar")
14
14
  # module.foo #=> "bar"
15
15
  def self.extend_onto(object, name=nil, stubs_and_options={})
16
+ RSpec.deprecate("`RSpec::Mocks::TestDouble.extend_onto(...)`")
16
17
  object.extend self
17
18
  object.send(:__initialize_as_test_double, name, stubs_and_options)
18
19
  end
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Mocks
3
3
  module Version
4
- STRING = '2.99.0.beta2'
4
+ STRING = '2.99.0.rc1'
5
5
  end
6
6
  end
7
7
  end
@@ -48,12 +48,12 @@ module RSpec
48
48
  end
49
49
 
50
50
  it "raises an error if 'with' follows 'and_return'" do
51
- pending "see Github issue #42"
51
+ skip "see Github issue #42"
52
52
  expect { klass.any_instance.should_receive(:foo).and_return(1).with("1") }.to raise_error(NoMethodError)
53
53
  end
54
54
 
55
55
  it "raises an error if 'with' follows 'and_raise'" do
56
- pending "see Github issue #42"
56
+ skip "see Github issue #42"
57
57
  expect { klass.any_instance.should_receive(:foo).and_raise(1).with("1") }.to raise_error(NoMethodError)
58
58
  end
59
59
  end
@@ -377,6 +377,7 @@ module RSpec
377
377
  klass.any_instance.should_not_receive(:bar)
378
378
  klass.new.foo
379
379
  RSpec::Mocks.space.verify_all
380
+ RSpec::Mocks.space.reset_all
380
381
  end
381
382
  end
382
383
 
@@ -399,24 +400,36 @@ module RSpec
399
400
 
400
401
  it "fails if an instance is created but no invocation occurs" do
401
402
  expect do
402
- klass.any_instance.should_receive(:foo)
403
- klass.new
404
- RSpec::Mocks.space.verify_all
403
+ begin
404
+ klass.any_instance.should_receive(:foo)
405
+ klass.new
406
+ RSpec::Mocks.space.verify_all
407
+ ensure
408
+ RSpec::Mocks.space.reset_all
409
+ end
405
410
  end.to raise_error(RSpec::Mocks::MockExpectationError, foo_expectation_error_message)
406
411
  end
407
412
 
408
413
  it "fails if no instance is created" do
409
414
  expect do
410
- klass.any_instance.should_receive(:foo).and_return(1)
411
- RSpec::Mocks.space.verify_all
415
+ begin
416
+ klass.any_instance.should_receive(:foo).and_return(1)
417
+ RSpec::Mocks.space.verify_all
418
+ ensure
419
+ RSpec::Mocks.space.reset_all
420
+ end
412
421
  end.to raise_error(RSpec::Mocks::MockExpectationError, foo_expectation_error_message)
413
422
  end
414
423
 
415
424
  it "fails if no instance is created and there are multiple expectations" do
416
425
  expect do
417
- klass.any_instance.should_receive(:foo)
418
- klass.any_instance.should_receive(:bar)
419
- RSpec::Mocks.space.verify_all
426
+ begin
427
+ klass.any_instance.should_receive(:foo)
428
+ klass.any_instance.should_receive(:bar)
429
+ RSpec::Mocks.space.verify_all
430
+ ensure
431
+ RSpec::Mocks.space.reset_all
432
+ end
420
433
  end.to raise_error(RSpec::Mocks::MockExpectationError, 'Exactly one instance should have received the following message(s) but didn\'t: bar, foo')
421
434
  end
422
435
 
@@ -478,24 +491,36 @@ module RSpec
478
491
 
479
492
  it "fails if an instance is created but no invocation occurs" do
480
493
  expect do
481
- klass.any_instance.should_receive(:existing_method)
482
- klass.new
483
- RSpec::Mocks.space.verify_all
494
+ begin
495
+ klass.any_instance.should_receive(:existing_method)
496
+ klass.new
497
+ RSpec::Mocks.space.verify_all
498
+ ensure
499
+ RSpec::Mocks.space.reset_all
500
+ end
484
501
  end.to raise_error(RSpec::Mocks::MockExpectationError, existing_method_expectation_error_message)
485
502
  end
486
503
 
487
504
  it "fails if no instance is created" do
488
505
  expect do
489
- klass.any_instance.should_receive(:existing_method)
490
- RSpec::Mocks.space.verify_all
506
+ begin
507
+ klass.any_instance.should_receive(:existing_method)
508
+ RSpec::Mocks.space.verify_all
509
+ ensure
510
+ RSpec::Mocks.space.reset_all
511
+ end
491
512
  end.to raise_error(RSpec::Mocks::MockExpectationError, existing_method_expectation_error_message)
492
513
  end
493
514
 
494
515
  it "fails if no instance is created and there are multiple expectations" do
495
516
  expect do
496
- klass.any_instance.should_receive(:existing_method)
497
- klass.any_instance.should_receive(:another_existing_method)
498
- RSpec::Mocks.space.verify_all
517
+ begin
518
+ klass.any_instance.should_receive(:existing_method)
519
+ klass.any_instance.should_receive(:another_existing_method)
520
+ RSpec::Mocks.space.verify_all
521
+ ensure
522
+ RSpec::Mocks.space.reset_all
523
+ end
499
524
  end.to raise_error(RSpec::Mocks::MockExpectationError, 'Exactly one instance should have received the following message(s) but didn\'t: another_existing_method, existing_method')
500
525
  end
501
526
 
@@ -588,16 +613,24 @@ module RSpec
588
613
 
589
614
  it "fails when no instances are declared" do
590
615
  expect do
591
- klass.any_instance.should_receive(:foo).once
592
- RSpec::Mocks.space.verify_all
616
+ begin
617
+ klass.any_instance.should_receive(:foo).once
618
+ RSpec::Mocks.space.verify_all
619
+ ensure
620
+ RSpec::Mocks.space.reset_all
621
+ end
593
622
  end.to raise_error(RSpec::Mocks::MockExpectationError, foo_expectation_error_message)
594
623
  end
595
624
 
596
625
  it "fails when an instance is declared but there are no invocations" do
597
626
  expect do
598
- klass.any_instance.should_receive(:foo).once
599
- klass.new
600
- RSpec::Mocks.space.verify_all
627
+ begin
628
+ klass.any_instance.should_receive(:foo).once
629
+ klass.new
630
+ RSpec::Mocks.space.verify_all
631
+ ensure
632
+ RSpec::Mocks.space.reset_all
633
+ end
601
634
  end.to raise_error(RSpec::Mocks::MockExpectationError, foo_expectation_error_message)
602
635
  end
603
636
 
@@ -722,9 +755,13 @@ module RSpec
722
755
 
723
756
  it "fails when the other expecations are not met" do
724
757
  expect do
725
- klass.any_instance.should_receive(:foo).never
726
- klass.any_instance.should_receive(:existing_method).and_return(5)
727
- RSpec::Mocks.space.verify_all
758
+ begin
759
+ klass.any_instance.should_receive(:foo).never
760
+ klass.any_instance.should_receive(:existing_method).and_return(5)
761
+ RSpec::Mocks.space.verify_all
762
+ ensure
763
+ RSpec::Mocks.space.reset_all
764
+ end
728
765
  end.to raise_error(RSpec::Mocks::MockExpectationError, existing_method_expectation_error_message)
729
766
  end
730
767
  end
@@ -760,9 +797,13 @@ module RSpec
760
797
 
761
798
  it "fails when the other expecations are not met" do
762
799
  expect do
763
- klass.any_instance.should_receive(:foo).any_number_of_times
764
- klass.any_instance.should_receive(:existing_method).and_return(5)
765
- RSpec::Mocks.space.verify_all
800
+ begin
801
+ klass.any_instance.should_receive(:foo).any_number_of_times
802
+ klass.any_instance.should_receive(:existing_method).and_return(5)
803
+ RSpec::Mocks.space.verify_all
804
+ ensure
805
+ RSpec::Mocks.space.reset_all
806
+ end
766
807
  end.to raise_error(RSpec::Mocks::MockExpectationError, existing_method_expectation_error_message)
767
808
  end
768
809
  end
@@ -787,6 +828,7 @@ module RSpec
787
828
 
788
829
  it "restores the class to its original state after each example when no instance is created" do
789
830
  space.verify_all
831
+ space.reset_all
790
832
 
791
833
  expect(klass.method_defined?(:__existing_method_without_any_instance__)).to be false
792
834
  expect(klass.new.existing_method).to eq(existing_method_return_value)
@@ -796,6 +838,7 @@ module RSpec
796
838
  klass.new.existing_method
797
839
 
798
840
  space.verify_all
841
+ space.reset_all
799
842
 
800
843
  expect(klass.method_defined?(:__existing_method_without_any_instance__)).to be false
801
844
  expect(klass.new.existing_method).to eq(existing_method_return_value)
@@ -806,6 +849,7 @@ module RSpec
806
849
  klass.new.existing_method
807
850
 
808
851
  space.verify_all
852
+ space.reset_all
809
853
 
810
854
  expect(klass.method_defined?(:__existing_method_without_any_instance__)).to be false
811
855
  expect(klass.new.existing_method).to eq(existing_method_return_value)
@@ -816,6 +860,7 @@ module RSpec
816
860
  before :each do
817
861
  klass.any_instance.stub(:private_method).and_return(:something)
818
862
  space.verify_all
863
+ space.reset_all
819
864
  end
820
865
 
821
866
  it "cleans up the backed up method" do
@@ -838,6 +883,7 @@ module RSpec
838
883
  klass.any_instance.should_receive(:private_method).and_return(:something)
839
884
  klass.new.private_method
840
885
  space.verify_all
886
+ space.reset_all
841
887
  end
842
888
 
843
889
  it "cleans up the backed up method" do
@@ -885,6 +931,7 @@ module RSpec
885
931
  klass.any_instance.should_receive(:existing_method).and_return(Object.new)
886
932
  klass.new.existing_method
887
933
  space.verify_all
934
+ space.reset_all
888
935
 
889
936
  expect(klass.new.existing_method).to eq(existing_method_return_value)
890
937
  end
@@ -897,6 +944,7 @@ module RSpec
897
944
  klass.any_instance.stub(:existing_method).and_return(true)
898
945
 
899
946
  RSpec::Mocks.space.verify_all
947
+ RSpec::Mocks.space.reset_all
900
948
  expect(klass.new).to respond_to(:existing_method)
901
949
  expect(klass.new.existing_method).to eq(existing_method_return_value)
902
950
  end
@@ -1178,6 +1226,7 @@ module RSpec
1178
1226
  expect(instance.existing_method).to eq :stubbed_return_value
1179
1227
 
1180
1228
  RSpec::Mocks.verify
1229
+ RSpec::Mocks.teardown
1181
1230
 
1182
1231
  expect(instance.existing_method).to eq :existing_method_return_value
1183
1232
  end
@@ -31,13 +31,21 @@ describe Marshal, 'extensions' do
31
31
  end
32
32
 
33
33
  context 'when rspec-mocks has been fully initialized' do
34
+ include_context 'with isolated configuration'
35
+
34
36
  it 'duplicates objects with stubbed or mocked implementations before serialization' do
37
+ RSpec::Mocks.configuration.patch_marshal_to_support_partial_doubles = true
35
38
  obj = double(:foo => "bar")
36
39
 
37
40
  serialized = Marshal.dump(obj)
38
41
  expect(Marshal.load(serialized)).to be_an(obj.class)
39
42
  end
40
43
 
44
+ it 'provides a deprecation warning' do
45
+ expect_warn_deprecation_with_call_site('marshal_spec.rb', __LINE__ + 1)
46
+ Marshal.dump double(:foo => "bar")
47
+ end
48
+
41
49
  it 'does not duplicate other objects before serialization' do
42
50
  obj = UndupableObject.new
43
51
 
@@ -9,6 +9,10 @@ module RSpec
9
9
  ::RSpec::Mocks.space.verify_all
10
10
  end
11
11
 
12
+ def reset_all
13
+ ::RSpec::Mocks.space.reset_all
14
+ end
15
+
12
16
  shared_examples_for "a receive matcher" do |*options|
13
17
  it 'allows the caller to configure how the subject responds' do
14
18
  wrapped.to receive(:foo).and_return(5)
@@ -105,6 +109,8 @@ module RSpec
105
109
  expect {
106
110
  verify_all
107
111
  }.to raise_error(RSpec::Mocks::MockExpectationError)
112
+
113
+ reset_all
108
114
  end
109
115
 
110
116
  it "reports the line number of expectation of unreceived message", :pending => options.include?(:does_not_report_line_num) do
@@ -98,16 +98,6 @@ module RSpec
98
98
  expect(r1).to be(r2)
99
99
  expect(r1).not_to be(r3)
100
100
  end
101
-
102
- it 'removes an any_instance_recorder when requested' do
103
- klass = Class.new
104
-
105
- space.any_instance_recorder_for(klass)
106
-
107
- expect {
108
- space.remove_any_instance_recorder_for(klass)
109
- }.to change { space.any_instance_recorders.size }.by(-1)
110
- end
111
101
  end
112
102
  end
113
103
  end
@@ -32,6 +32,11 @@ module RSpec
32
32
  ::RSpec::Mocks.space.reset_all
33
33
  end
34
34
 
35
+ specify "the use of ConstantStubber is deprecated" do
36
+ expect_deprecation_with_call_site(__FILE__, __LINE__ + 1)
37
+ expect(RSpec::Mocks::ConstantStubber).to eq RSpec::Mocks::ConstantMutator
38
+ end
39
+
35
40
  shared_context "constant example methods" do |const_name|
36
41
  define_method :const do
37
42
  recursive_const_get(const_name)
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  module RSpec
4
4
  module Mocks
5
5
  describe "Serialization of mocked objects" do
6
+ include_context 'with isolated configuration'
6
7
 
7
8
  class SerializableObject < Struct.new(:foo, :bar); end
8
9
 
@@ -82,6 +83,7 @@ module RSpec
82
83
  end
83
84
 
84
85
  it 'marshals the same with and without stubbing' do
86
+ RSpec::Mocks.configuration.patch_marshal_to_support_partial_doubles = true
85
87
  expect { set_stub }.to_not change { Marshal.dump(serializable_object) }
86
88
  end
87
89
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  module RSpec
4
4
  module Mocks
5
5
  describe TestDouble do
6
+ before { allow_deprecation }
7
+
6
8
  before(:all) do
7
9
  Module.class_eval do
8
10
  private
@@ -31,6 +33,11 @@ module RSpec
31
33
  expect { double.foo }.to raise_error(/Mock "MyDouble" received/)
32
34
  end
33
35
 
36
+ it 'warns when `extend_onto` is used' do
37
+ expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /RSpec::Mocks::TestDouble.extend_onto/)
38
+ Module.new { TestDouble.extend_onto(self) }
39
+ end
40
+
34
41
  [[:should, :expect], [:expect], [:should]].each do |syntax|
35
42
  context "with syntax #{syntax.inspect}" do
36
43
  include_context "with syntax", syntax
data/spec/spec_helper.rb CHANGED
@@ -37,7 +37,7 @@ module HelperMethods
37
37
  end
38
38
 
39
39
  def allow_deprecation
40
- allow(RSpec.configuration.reporter).to receive(:deprecation)
40
+ RSpec::Mocks.allow_message(RSpec.configuration.reporter, :deprecation)
41
41
  end
42
42
 
43
43
  def allow_unavoidable_1_8_deprecation
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-mocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.99.0.beta2
5
- prerelease: 7
4
+ version: 2.99.0.rc1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Steven Baker
@@ -10,54 +9,48 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2014-02-18 00:00:00.000000000 Z
12
+ date: 2014-05-18 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rake
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ~>
18
+ - - "~>"
21
19
  - !ruby/object:Gem::Version
22
20
  version: 10.0.0
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ~>
25
+ - - "~>"
29
26
  - !ruby/object:Gem::Version
30
27
  version: 10.0.0
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: cucumber
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ~>
32
+ - - "~>"
37
33
  - !ruby/object:Gem::Version
38
34
  version: 1.1.9
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ~>
39
+ - - "~>"
45
40
  - !ruby/object:Gem::Version
46
41
  version: 1.1.9
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: aruba
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ~>
46
+ - - "~>"
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0.5'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ~>
53
+ - - "~>"
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0.5'
63
56
  description: RSpec's 'test double' framework, with support for stubbing and mocking
@@ -66,48 +59,11 @@ executables: []
66
59
  extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
- - lib/rspec/mocks.rb
70
- - lib/rspec/mocks/any_instance/chain.rb
71
- - lib/rspec/mocks/any_instance/expectation_chain.rb
72
- - lib/rspec/mocks/any_instance/message_chains.rb
73
- - lib/rspec/mocks/any_instance/recorder.rb
74
- - lib/rspec/mocks/any_instance/stub_chain.rb
75
- - lib/rspec/mocks/any_instance/stub_chain_chain.rb
76
- - lib/rspec/mocks/argument_list_matcher.rb
77
- - lib/rspec/mocks/argument_matchers.rb
78
- - lib/rspec/mocks/caller_filter.rb
79
- - lib/rspec/mocks/configuration.rb
80
- - lib/rspec/mocks/deprecation.rb
81
- - lib/rspec/mocks/error_generator.rb
82
- - lib/rspec/mocks/errors.rb
83
- - lib/rspec/mocks/example_methods.rb
84
- - lib/rspec/mocks/extensions/instance_exec.rb
85
- - lib/rspec/mocks/extensions/marshal.rb
86
- - lib/rspec/mocks/extensions/proc.rb
87
- - lib/rspec/mocks/framework.rb
88
- - lib/rspec/mocks/instance_method_stasher.rb
89
- - lib/rspec/mocks/matchers/have_received.rb
90
- - lib/rspec/mocks/matchers/receive.rb
91
- - lib/rspec/mocks/message_expectation.rb
92
- - lib/rspec/mocks/method_double.rb
93
- - lib/rspec/mocks/mock.rb
94
- - lib/rspec/mocks/mutate_const.rb
95
- - lib/rspec/mocks/order_group.rb
96
- - lib/rspec/mocks/proxy.rb
97
- - lib/rspec/mocks/proxy_for_nil.rb
98
- - lib/rspec/mocks/space.rb
99
- - lib/rspec/mocks/standalone.rb
100
- - lib/rspec/mocks/stub_chain.rb
101
- - lib/rspec/mocks/syntax.rb
102
- - lib/rspec/mocks/targets.rb
103
- - lib/rspec/mocks/test_double.rb
104
- - lib/rspec/mocks/version.rb
105
- - lib/spec/mocks.rb
106
- - README.md
107
- - License.txt
62
+ - ".document"
63
+ - ".yardopts"
108
64
  - Changelog.md
109
- - .yardopts
110
- - .document
65
+ - License.txt
66
+ - README.md
111
67
  - features/README.md
112
68
  - features/Scope.md
113
69
  - features/Upgrade.md
@@ -146,6 +102,43 @@ files:
146
102
  - features/support/env.rb
147
103
  - features/support/rubinius.rb
148
104
  - features/test_frameworks/test_unit.feature
105
+ - lib/rspec/mocks.rb
106
+ - lib/rspec/mocks/any_instance/chain.rb
107
+ - lib/rspec/mocks/any_instance/expectation_chain.rb
108
+ - lib/rspec/mocks/any_instance/message_chains.rb
109
+ - lib/rspec/mocks/any_instance/recorder.rb
110
+ - lib/rspec/mocks/any_instance/stub_chain.rb
111
+ - lib/rspec/mocks/any_instance/stub_chain_chain.rb
112
+ - lib/rspec/mocks/argument_list_matcher.rb
113
+ - lib/rspec/mocks/argument_matchers.rb
114
+ - lib/rspec/mocks/caller_filter.rb
115
+ - lib/rspec/mocks/configuration.rb
116
+ - lib/rspec/mocks/deprecation.rb
117
+ - lib/rspec/mocks/error_generator.rb
118
+ - lib/rspec/mocks/errors.rb
119
+ - lib/rspec/mocks/example_methods.rb
120
+ - lib/rspec/mocks/extensions/instance_exec.rb
121
+ - lib/rspec/mocks/extensions/marshal.rb
122
+ - lib/rspec/mocks/extensions/proc.rb
123
+ - lib/rspec/mocks/framework.rb
124
+ - lib/rspec/mocks/instance_method_stasher.rb
125
+ - lib/rspec/mocks/matchers/have_received.rb
126
+ - lib/rspec/mocks/matchers/receive.rb
127
+ - lib/rspec/mocks/message_expectation.rb
128
+ - lib/rspec/mocks/method_double.rb
129
+ - lib/rspec/mocks/mock.rb
130
+ - lib/rspec/mocks/mutate_const.rb
131
+ - lib/rspec/mocks/order_group.rb
132
+ - lib/rspec/mocks/proxy.rb
133
+ - lib/rspec/mocks/proxy_for_nil.rb
134
+ - lib/rspec/mocks/space.rb
135
+ - lib/rspec/mocks/standalone.rb
136
+ - lib/rspec/mocks/stub_chain.rb
137
+ - lib/rspec/mocks/syntax.rb
138
+ - lib/rspec/mocks/targets.rb
139
+ - lib/rspec/mocks/test_double.rb
140
+ - lib/rspec/mocks/version.rb
141
+ - lib/spec/mocks.rb
149
142
  - spec/rspec/mocks/and_call_original_spec.rb
150
143
  - spec/rspec/mocks/and_return_spec.rb
151
144
  - spec/rspec/mocks/and_yield_spec.rb
@@ -207,32 +200,28 @@ files:
207
200
  homepage: http://github.com/rspec/rspec-mocks
208
201
  licenses:
209
202
  - MIT
203
+ metadata: {}
210
204
  post_install_message:
211
205
  rdoc_options:
212
- - --charset=UTF-8
206
+ - "--charset=UTF-8"
213
207
  require_paths:
214
208
  - lib
215
209
  required_ruby_version: !ruby/object:Gem::Requirement
216
- none: false
217
210
  requirements:
218
- - - ! '>='
211
+ - - ">="
219
212
  - !ruby/object:Gem::Version
220
213
  version: '0'
221
- segments:
222
- - 0
223
- hash: 1858263502933685358
224
214
  required_rubygems_version: !ruby/object:Gem::Requirement
225
- none: false
226
215
  requirements:
227
- - - ! '>'
216
+ - - ">"
228
217
  - !ruby/object:Gem::Version
229
218
  version: 1.3.1
230
219
  requirements: []
231
220
  rubyforge_project: rspec
232
- rubygems_version: 1.8.23
221
+ rubygems_version: 2.2.2
233
222
  signing_key:
234
- specification_version: 3
235
- summary: rspec-mocks-2.99.0.beta2
223
+ specification_version: 4
224
+ summary: rspec-mocks-2.99.0.rc1
236
225
  test_files:
237
226
  - features/README.md
238
227
  - features/Scope.md