rspec-mocks 3.0.0.beta2 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Changelog.md +104 -36
  5. data/README.md +35 -4
  6. data/lib/rspec/mocks.rb +52 -13
  7. data/lib/rspec/mocks/any_instance.rb +10 -0
  8. data/lib/rspec/mocks/any_instance/chain.rb +17 -0
  9. data/lib/rspec/mocks/any_instance/expect_chain_chain.rb +1 -1
  10. data/lib/rspec/mocks/any_instance/expectation_chain.rb +9 -6
  11. data/lib/rspec/mocks/any_instance/message_chains.rb +10 -1
  12. data/lib/rspec/mocks/any_instance/proxy.rb +112 -0
  13. data/lib/rspec/mocks/any_instance/recorder.rb +49 -18
  14. data/lib/rspec/mocks/any_instance/stub_chain.rb +5 -3
  15. data/lib/rspec/mocks/any_instance/stub_chain_chain.rb +1 -1
  16. data/lib/rspec/mocks/argument_list_matcher.rb +5 -3
  17. data/lib/rspec/mocks/argument_matchers.rb +28 -12
  18. data/lib/rspec/mocks/configuration.rb +29 -0
  19. data/lib/rspec/mocks/error_generator.rb +2 -5
  20. data/lib/rspec/mocks/example_methods.rb +122 -13
  21. data/lib/rspec/mocks/instance_method_stasher.rb +26 -2
  22. data/lib/rspec/mocks/marshal_extension.rb +41 -0
  23. data/lib/rspec/mocks/matchers/expectation_customization.rb +20 -0
  24. data/lib/rspec/mocks/matchers/receive.rb +6 -20
  25. data/lib/rspec/mocks/matchers/receive_message_chain.rb +7 -5
  26. data/lib/rspec/mocks/matchers/receive_messages.rb +1 -2
  27. data/lib/rspec/mocks/message_chain.rb +9 -9
  28. data/lib/rspec/mocks/message_expectation.rb +6 -5
  29. data/lib/rspec/mocks/method_double.rb +67 -10
  30. data/lib/rspec/mocks/method_reference.rb +1 -1
  31. data/lib/rspec/mocks/mutate_const.rb +10 -14
  32. data/lib/rspec/mocks/object_reference.rb +7 -4
  33. data/lib/rspec/mocks/proxy.rb +95 -8
  34. data/lib/rspec/mocks/space.rb +58 -9
  35. data/lib/rspec/mocks/syntax.rb +128 -210
  36. data/lib/rspec/mocks/targets.rb +6 -8
  37. data/lib/rspec/mocks/test_double.rb +16 -25
  38. data/lib/rspec/mocks/verifying_double.rb +15 -12
  39. data/lib/rspec/mocks/verifying_message_expecation.rb +3 -3
  40. data/lib/rspec/mocks/verifying_proxy.rb +23 -17
  41. data/lib/rspec/mocks/version.rb +3 -1
  42. metadata +29 -257
  43. metadata.gz.sig +0 -0
  44. data/features/README.md +0 -75
  45. data/features/Scope.md +0 -17
  46. data/features/Upgrade.md +0 -22
  47. data/features/argument_matchers/README.md +0 -27
  48. data/features/argument_matchers/explicit.feature +0 -59
  49. data/features/argument_matchers/general_matchers.feature +0 -85
  50. data/features/argument_matchers/type_matchers.feature +0 -26
  51. data/features/message_expectations/README.md +0 -75
  52. data/features/message_expectations/allow_any_instance_of.feature +0 -26
  53. data/features/message_expectations/any_instance.feature +0 -43
  54. data/features/message_expectations/block_local_expectations.feature.pending +0 -55
  55. data/features/message_expectations/call_original.feature +0 -23
  56. data/features/message_expectations/expect_message_using_expect.feature +0 -107
  57. data/features/message_expectations/expect_message_using_should_receive.feature +0 -118
  58. data/features/message_expectations/message_chains_using_expect.feature +0 -49
  59. data/features/message_expectations/receive_counts.feature +0 -209
  60. data/features/message_expectations/warn_when_expectation_is_set_on_nil.feature +0 -50
  61. data/features/method_stubs/README.md +0 -77
  62. data/features/method_stubs/allow_any_instance_of.feature +0 -136
  63. data/features/method_stubs/as_null_object.feature +0 -40
  64. data/features/method_stubs/receive_message_chain.feature +0 -51
  65. data/features/method_stubs/simple_return_value_with_allow.feature +0 -44
  66. data/features/method_stubs/simple_return_value_with_stub.feature +0 -64
  67. data/features/method_stubs/stub_implementation.feature +0 -48
  68. data/features/method_stubs/to_ary.feature +0 -51
  69. data/features/mutating_constants/README.md +0 -82
  70. data/features/mutating_constants/hiding_defined_constant.feature +0 -64
  71. data/features/mutating_constants/stub_defined_constant.feature +0 -78
  72. data/features/mutating_constants/stub_undefined_constant.feature +0 -50
  73. data/features/outside_rspec/standalone.feature +0 -33
  74. data/features/spies/spy_partial_mock_method.feature +0 -34
  75. data/features/spies/spy_pure_mock_method.feature +0 -76
  76. data/features/spies/spy_unstubbed_method.feature +0 -18
  77. data/features/step_definitions/additional_cli_steps.rb +0 -11
  78. data/features/support/env.rb +0 -22
  79. data/features/support/rubinius.rb +0 -6
  80. data/features/test_frameworks/test_unit.feature +0 -54
  81. data/features/verifying_doubles/README.md +0 -17
  82. data/features/verifying_doubles/class_doubles.feature +0 -73
  83. data/features/verifying_doubles/dynamic_classes.feature +0 -71
  84. data/features/verifying_doubles/instance_doubles.feature +0 -103
  85. data/features/verifying_doubles/object_doubles.feature +0 -65
  86. data/features/verifying_doubles/partial_doubles.feature +0 -34
  87. data/lib/rspec/mocks/extensions/marshal.rb +0 -17
  88. data/lib/rspec/mocks/framework.rb +0 -35
  89. data/lib/rspec/mocks/method_signature_verifier.rb +0 -207
  90. data/lib/rspec/mocks/ruby_features.rb +0 -24
  91. data/spec/rspec/mocks/and_call_original_spec.rb +0 -268
  92. data/spec/rspec/mocks/and_return_spec.rb +0 -23
  93. data/spec/rspec/mocks/and_yield_spec.rb +0 -126
  94. data/spec/rspec/mocks/any_instance/message_chains_spec.rb +0 -41
  95. data/spec/rspec/mocks/any_instance_spec.rb +0 -1045
  96. data/spec/rspec/mocks/array_including_matcher_spec.rb +0 -41
  97. data/spec/rspec/mocks/at_least_spec.rb +0 -123
  98. data/spec/rspec/mocks/at_most_spec.rb +0 -90
  99. data/spec/rspec/mocks/before_all_spec.rb +0 -132
  100. data/spec/rspec/mocks/block_return_value_spec.rb +0 -70
  101. data/spec/rspec/mocks/combining_implementation_instructions_spec.rb +0 -204
  102. data/spec/rspec/mocks/configuration_spec.rb +0 -242
  103. data/spec/rspec/mocks/double_spec.rb +0 -874
  104. data/spec/rspec/mocks/example_methods_spec.rb +0 -13
  105. data/spec/rspec/mocks/extensions/marshal_spec.rb +0 -54
  106. data/spec/rspec/mocks/failing_argument_matchers_spec.rb +0 -184
  107. data/spec/rspec/mocks/hash_excluding_matcher_spec.rb +0 -67
  108. data/spec/rspec/mocks/hash_including_matcher_spec.rb +0 -94
  109. data/spec/rspec/mocks/instance_method_stasher_spec.rb +0 -74
  110. data/spec/rspec/mocks/matchers/have_received_spec.rb +0 -347
  111. data/spec/rspec/mocks/matchers/receive_message_chain_spec.rb +0 -198
  112. data/spec/rspec/mocks/matchers/receive_messages_spec.rb +0 -140
  113. data/spec/rspec/mocks/matchers/receive_spec.rb +0 -418
  114. data/spec/rspec/mocks/method_signature_verifier_spec.rb +0 -272
  115. data/spec/rspec/mocks/methods_spec.rb +0 -26
  116. data/spec/rspec/mocks/mock_expectation_error_spec.rb +0 -22
  117. data/spec/rspec/mocks/mock_ordering_spec.rb +0 -114
  118. data/spec/rspec/mocks/multiple_return_value_spec.rb +0 -132
  119. data/spec/rspec/mocks/mutate_const_spec.rb +0 -542
  120. data/spec/rspec/mocks/nil_expectation_warning_spec.rb +0 -52
  121. data/spec/rspec/mocks/null_object_mock_spec.rb +0 -133
  122. data/spec/rspec/mocks/once_counts_spec.rb +0 -52
  123. data/spec/rspec/mocks/options_hash_spec.rb +0 -35
  124. data/spec/rspec/mocks/order_group_spec.rb +0 -27
  125. data/spec/rspec/mocks/partial_double_spec.rb +0 -308
  126. data/spec/rspec/mocks/partial_double_using_mocks_directly_spec.rb +0 -95
  127. data/spec/rspec/mocks/passing_argument_matchers_spec.rb +0 -145
  128. data/spec/rspec/mocks/precise_counts_spec.rb +0 -68
  129. data/spec/rspec/mocks/record_messages_spec.rb +0 -26
  130. data/spec/rspec/mocks/serialization_spec.rb +0 -90
  131. data/spec/rspec/mocks/space_spec.rb +0 -244
  132. data/spec/rspec/mocks/stash_spec.rb +0 -46
  133. data/spec/rspec/mocks/stub_chain_spec.rb +0 -168
  134. data/spec/rspec/mocks/stub_implementation_spec.rb +0 -81
  135. data/spec/rspec/mocks/stub_spec.rb +0 -327
  136. data/spec/rspec/mocks/stubbed_message_expectations_spec.rb +0 -58
  137. data/spec/rspec/mocks/syntax_agnostic_message_matchers_spec.rb +0 -101
  138. data/spec/rspec/mocks/syntax_spec.rb +0 -19
  139. data/spec/rspec/mocks/test_double_spec.rb +0 -49
  140. data/spec/rspec/mocks/to_ary_spec.rb +0 -54
  141. data/spec/rspec/mocks/twice_counts_spec.rb +0 -66
  142. data/spec/rspec/mocks/verifying_double_spec.rb +0 -590
  143. data/spec/rspec/mocks/verifying_message_expecation_spec.rb +0 -69
  144. data/spec/rspec/mocks_spec.rb +0 -192
  145. data/spec/spec_helper.rb +0 -121
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a86bf7c23da1fbf0a99c66b3703b28db668c13a5
4
+ data.tar.gz: 497e3567be89dc6f1e1b537675c52cbdefdbfafb
5
+ SHA512:
6
+ metadata.gz: fd064398848570d18ea7156286a0c4374540580c9f71a8ea7cdbf8707cc9b5cdec680b9f48d1f3af29b02b72872f51a2f11f953bc0c5b9c670b132d874f2d4f7
7
+ data.tar.gz: ebf097e7564b3720fb716827266343e39a3f79c5a8b6ccc57d5f3253715623a09231439631a946f74b2a9705083dff8a6d2037dfe90d0d4f2e4329bde64b82d4
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,5 +1,56 @@
1
+ ### 3.0.0.rc1 / 2014-05-18
2
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.0.0.beta2...v3.0.0.rc1)
3
+
4
+ Breaking Changes for 3.0.0:
5
+
6
+ * Remove `RSpec::Mocks::TestDouble.extend_onto`. (Myron Marston)
7
+ * Remove `RSpec::Mocks::ConstantStubber`. (Jon Rowe)
8
+ * Make monkey-patch of Marshal to support dumping of stubbed objects opt-in.
9
+ (Xavier Shay)
10
+
11
+ Enhancements:
12
+
13
+ * Instead of crashing when cleaning up stub methods on a frozen object, it now
14
+ issues a warning explaining that it's impossible to clean up the stubs.
15
+ (Justin Coyne and Sam Phippen)
16
+ * Add meaningful descriptions to `anything`, `duck_type` and `instance_of` argument
17
+ matchers. (Jon Rowe)
18
+
19
+ Bug Fixes:
20
+
21
+ * Fix regression introduced in 3.0.0.beta2 that caused
22
+ `double.as_null_object.to_str` to return the double rather
23
+ than a string. (Myron Marston)
24
+ * Fix bug in `expect(dbl).to receive_message_chain(:foo, :bar)` where it was
25
+ not setting an expectation for the last message in the chain.
26
+ (Jonathan del Strother)
27
+ * Allow verifying partial doubles to have private methods stubbed. (Xavier Shay)
28
+ * Fix bug with allowing/expecting messages on Class objects which have had
29
+ their singleton class prepended to. (Jon Rowe)
30
+ * Fix an issue with 1.8.7 not running implementation blocks on partial doubles.
31
+ (Maurício Linhares)
32
+ * Prevent `StackLevelTooDeep` errors when stubbing an `any_instance` method that's
33
+ accessed in `inspect` by providing our own inspect output. (Jon Rowe)
34
+ * Fix bug in `any_instance` logic that did not allow you to mock or stub
35
+ private methods if `verify_partial_doubles` was configured. (Oren Dobzinski)
36
+ * Include useful error message when trying to observe an unimplemented method
37
+ on an any instance. (Xavier Shay)
38
+ * Fix `and_call_original` to work properly when multiple classes in an
39
+ inheritance hierarchy have been stubbed with the same method. (Myron Marston)
40
+ * Fix `any_instance` so that it updates existing instances that have
41
+ already been stubbed. (Myron Marston)
42
+ * Fix verified doubles so that their class name is included in failure
43
+ messages. (Myron Marston)
44
+ * Fix `expect_any_instance_of` so that when the message is received
45
+ on an individual instance that has been directly stubbed, it still
46
+ satisfies the expectation. (Sam Phippen, Myron Marston)
47
+ * Explicitly disallow using `any_instance` to mock or stub a method
48
+ that is defined on a module prepended onto the class. This triggered
49
+ `SystemStackError` before and is very hard to support so we are not
50
+ supporting it at this time. (Myron Marston)
51
+
1
52
  ### 3.0.0.beta2 / 2014-02-17
2
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v3.0.0.beta1...v3.0.0.beta2)
53
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.0.0.beta1...v3.0.0.beta2)
3
54
 
4
55
  Breaking Changes for 3.0.0:
5
56
 
@@ -66,7 +117,7 @@ Bug Fixes:
66
117
  behavior. (Maurício Linhares)
67
118
 
68
119
  ### 3.0.0.beta1 / 2013-11-07
69
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.beta1...v3.0.0.beta1)
120
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.rc1...v3.0.0.beta1)
70
121
 
71
122
  Breaking Changes for 3.0.0:
72
123
 
@@ -129,8 +180,17 @@ Bug Fixes:
129
180
  returns `nil` or `''` so that you still get a useful message.
130
181
  (Nick DeLuca)
131
182
 
183
+ ### 2.99.0.rc1 / 2014-05-18
184
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.beta2...v2.99.0.rc1)
185
+
186
+ Deprecations:
187
+
188
+ * Deprecate `RSpec::Mocks::TestDouble.extend_onto`. (Myron Marston)
189
+ * Deprecate `RSpec::Mocks::ConstantStubber`. (Jon Rowe)
190
+ * Deprecate `Marshal.dump` monkey-patch without opt-in. (Xavier Shay)
191
+
132
192
  ### 2.99.0.beta2 / 2014-02-17
133
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.beta1...v2.99.0.beta2)
193
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.99.0.beta1...v2.99.0.beta2)
134
194
 
135
195
  Deprecations:
136
196
 
@@ -145,7 +205,7 @@ Deprecations:
145
205
  * Deprecate `and_return { value }` and `and_return` without arguments. (Yuji Nakayama)
146
206
 
147
207
  ### 2.99.0.beta1 / 2013-11-07
148
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.4...v2.99.0.beta1)
208
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.4...v2.99.0.beta1)
149
209
 
150
210
  Deprecations
151
211
 
@@ -169,8 +229,16 @@ Enhancements:
169
229
  * Add a config option to yield the receiver to `any_instance` implementation
170
230
  blocks. (Sam Phippen)
171
231
 
232
+ ### 2.14.6 / 2014-02-20
233
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.5...v2.14.6)
234
+
235
+ Bug Fixes:
236
+
237
+ * Ensure `any_instance` method stubs and expectations are torn down regardless of
238
+ expectation failures. (Sam Phippen)
239
+
172
240
  ### 2.14.5 / 2014-02-01
173
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.4...v2.14.5)
241
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.4...v2.14.5)
174
242
 
175
243
  Bug Fixes:
176
244
 
@@ -180,7 +248,7 @@ Bug Fixes:
180
248
  receives a block, too. (Myron Marston)
181
249
 
182
250
  ### 2.14.4 / 2013-10-15
183
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.3...v2.14.4)
251
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.3...v2.14.4)
184
252
 
185
253
  Bug Fixes:
186
254
 
@@ -190,7 +258,7 @@ Bug Fixes:
190
258
  the usage of modifications (`and_return` etc) (Jon Rowe)
191
259
 
192
260
  ### 2.14.3 / 2013-08-08
193
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.2...v2.14.3)
261
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.2...v2.14.3)
194
262
 
195
263
  Bug Fixes:
196
264
 
@@ -198,7 +266,7 @@ Bug Fixes:
198
266
  a prepended Module (Bradley Schaefer)
199
267
 
200
268
  ### 2.14.2 / 2013-07-30
201
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.1...v2.14.2)
269
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.1...v2.14.2)
202
270
 
203
271
  Bug Fixes:
204
272
 
@@ -208,7 +276,7 @@ Bug Fixes:
208
276
  return a test double rather than stub a method (Myron Marston).
209
277
 
210
278
  ### 2.14.1 / 2013-07-07
211
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.0...v2.14.1)
279
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.0...v2.14.1)
212
280
 
213
281
  Bug Fixes:
214
282
 
@@ -220,7 +288,7 @@ Bug Fixes:
220
288
  in 3.0. (Myron Marston)
221
289
 
222
290
  ### 2.14.0 / 2013-07-06
223
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.0.rc1...v2.14.0)
291
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.0.rc1...v2.14.0)
224
292
 
225
293
  Enhancements:
226
294
 
@@ -244,7 +312,7 @@ Bug Fixes:
244
312
  similar preloading gems (Andy Lindeman).
245
313
 
246
314
  ### 2.14.0.rc1 / 2013-05-27
247
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.13.0...v2.14.0.rc1)
315
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.13.0...v2.14.0.rc1)
248
316
 
249
317
  Enhancements:
250
318
 
@@ -294,7 +362,7 @@ Deprecations
294
362
  * Deprecate `at_least(0).times` and `any_number_of_times` (Michi Huber).
295
363
 
296
364
  ### 2.13.1 / 2013-04-06
297
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.13.0...v2.13.1)
365
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.13.0...v2.13.1)
298
366
 
299
367
  Bug fixes
300
368
 
@@ -302,7 +370,7 @@ Bug fixes
302
370
  `and_yield`, `and_raise`, `and_return` or `and_throw` (Myron Marston).
303
371
 
304
372
  ### 2.13.0 / 2013-02-23
305
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.2...v2.13.0)
373
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.2...v2.13.0)
306
374
 
307
375
  Bug fixes
308
376
 
@@ -332,7 +400,7 @@ Bug fixes
332
400
  (Myron Marston).
333
401
 
334
402
  ### 2.12.2 / 2013-01-27
335
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.1...v.2.12.2)
403
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.1...v.2.12.2)
336
404
 
337
405
  Bug fixes
338
406
 
@@ -347,7 +415,7 @@ Bug fixes
347
415
  versions (Andy Lindeman).
348
416
 
349
417
  ### 2.12.1 / 2012-12-21
350
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.0...v2.12.1)
418
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.12.0...v2.12.1)
351
419
 
352
420
  Bug fixes
353
421
 
@@ -359,7 +427,7 @@ Bug fixes
359
427
  work properly with constant strings that are prefixed with `::` (Myron Marston).
360
428
 
361
429
  ### 2.12.0 / 2012-11-12
362
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.3...v2.12.0)
430
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.3...v2.12.0)
363
431
 
364
432
  Enhancements
365
433
 
@@ -375,7 +443,7 @@ Deprecations:
375
443
  (Neha Kumari)
376
444
 
377
445
  ### 2.11.3 / 2012-09-19
378
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.2...v2.11.3)
446
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.2...v2.11.3)
379
447
 
380
448
  Bug fixes
381
449
 
@@ -389,7 +457,7 @@ Bug fixes
389
457
  extra time with the wrong arguments (Myron Marston).
390
458
 
391
459
  ### 2.11.2 / 2012-08-11
392
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.1...v2.11.2)
460
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.1...v2.11.2)
393
461
 
394
462
  Bug fixes
395
463
 
@@ -401,7 +469,7 @@ Bug fixes
401
469
  Marston)
402
470
 
403
471
  ### 2.11.1 / 2012-07-09
404
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.0...v2.11.1)
472
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.11.0...v2.11.1)
405
473
 
406
474
  Bug fixes
407
475
 
@@ -411,7 +479,7 @@ Bug fixes
411
479
  overriden with the null object implementation--`return self`). (Myron Marston)
412
480
 
413
481
  ### 2.11.0 / 2012-07-07
414
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.10.1...v2.11.0)
482
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.10.1...v2.11.0)
415
483
 
416
484
  Enhancements
417
485
 
@@ -436,7 +504,7 @@ Bug fixes
436
504
  `Exception` by default, just like ruby does. (Andrew Marshall)
437
505
 
438
506
  ### 2.10.1 / 2012-05-05
439
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.10.0...v2.10.1)
507
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.10.0...v2.10.1)
440
508
 
441
509
  Bug fixes
442
510
 
@@ -446,14 +514,14 @@ Bug fixes
446
514
  * fixed failure of `object.should_not_receive(:message).and_return value`
447
515
 
448
516
  ### 2.10.0 / 2012-05-03
449
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.9.0...v2.10.0)
517
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.9.0...v2.10.0)
450
518
 
451
519
  Bug fixes
452
520
 
453
521
  * fail fast when an `exactly` or `at_most` expectation is exceeded
454
522
 
455
523
  ### 2.9.0 / 2012-03-17
456
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0...v2.9.0)
524
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0...v2.9.0)
457
525
 
458
526
  Enhancements
459
527
 
@@ -468,19 +536,19 @@ Bug fixes
468
536
 
469
537
  ### 2.8.0 / 2012-01-04
470
538
 
471
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0.rc2...v2.8.0)
539
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0.rc2...v2.8.0)
472
540
 
473
541
  No changes for this release. Just releasing with the other rspec gems.
474
542
 
475
543
  ### 2.8.0.rc2 / 2011-12-19
476
544
 
477
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0.rc1...v2.8.0.rc2)
545
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.8.0.rc1...v2.8.0.rc2)
478
546
 
479
547
  No changes for this release. Just releasing with the other rspec gems.
480
548
 
481
549
  ### 2.8.0.rc1 / 2011-11-06
482
550
 
483
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.7.0...v2.8.0.rc1)
551
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.7.0...v2.8.0.rc1)
484
552
 
485
553
  Enhancements
486
554
 
@@ -488,7 +556,7 @@ Enhancements
488
556
 
489
557
  ### 2.7.0 / 2011-10-16
490
558
 
491
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.6.0...v2.7.0)
559
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.6.0...v2.7.0)
492
560
 
493
561
  Enhancements
494
562
 
@@ -511,7 +579,7 @@ Bug fixes
511
579
 
512
580
  ### 2.6.0 / 2011-05-12
513
581
 
514
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.5.0...v2.6.0)
582
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.5.0...v2.6.0)
515
583
 
516
584
  Enhancements
517
585
 
@@ -525,7 +593,7 @@ Bug fixes
525
593
 
526
594
  ### 2.5.0 / 2011-02-05
527
595
 
528
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.4.0...v2.5.0)
596
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.4.0...v2.5.0)
529
597
 
530
598
  Bug fixes
531
599
 
@@ -536,14 +604,14 @@ Bug fixes
536
604
 
537
605
  ### 2.4.0 / 2011-01-02
538
606
 
539
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.3.0...v2.4.0)
607
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.3.0...v2.4.0)
540
608
 
541
609
  No functional changes in this release, which was made to align with the
542
610
  rspec-core-2.4.0 release.
543
611
 
544
612
  ### 2.3.0 / 2010-12-12
545
613
 
546
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.2.0...v2.3.0)
614
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.2.0...v2.3.0)
547
615
 
548
616
  Bug fixes
549
617
 
@@ -552,7 +620,7 @@ Bug fixes
552
620
 
553
621
  ### 2.2.0 / 2010-11-28
554
622
 
555
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.1.0...v2.2.0)
623
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.1.0...v2.2.0)
556
624
 
557
625
  Enhancements
558
626
 
@@ -566,7 +634,7 @@ Bug fix
566
634
 
567
635
  ### 2.1.0 / 2010-11-07
568
636
 
569
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.1...v2.1.0)
637
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.1...v2.1.0)
570
638
 
571
639
  Bug fixes
572
640
 
@@ -574,11 +642,11 @@ Bug fixes
574
642
 
575
643
  ### 2.0.0 / 2010-10-10
576
644
 
577
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.22...v2.0.0)
645
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.22...v2.0.0)
578
646
 
579
647
  ### 2.0.0.rc / 2010-10-05
580
648
 
581
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.22...v2.0.0.rc)
649
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.22...v2.0.0.rc)
582
650
 
583
651
  Enhancements
584
652
 
@@ -592,7 +660,7 @@ Bug fixes
592
660
 
593
661
  ### 2.0.0.beta.22 / 2010-09-12
594
662
 
595
- [full changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.20...v2.0.0.beta.22)
663
+ [Full Changelog](http://github.com/rspec/rspec-mocks/compare/v2.0.0.beta.20...v2.0.0.beta.22)
596
664
 
597
665
  Bug fixes
598
666
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # RSpec Mocks [![Build Status](https://secure.travis-ci.org/rspec/rspec-mocks.png?branch=master)](http://travis-ci.org/rspec/rspec-mocks) [![Code Climate](https://codeclimate.com/github/rspec/rspec-mocks.png)](https://codeclimate.com/github/rspec/rspec-mocks)
1
+ # RSpec Mocks [![Build Status](https://secure.travis-ci.org/rspec/rspec-mocks.png?branch=master)](http://travis-ci.org/rspec/rspec-mocks) [![Code Climate](https://codeclimate.com/github/rspec/rspec-mocks.png)](https://codeclimate.com/github/rspec/rspec-mocks) [![Inline docs](http://inch-pages.github.io/github/rspec/rspec-mocks.png)](http://inch-pages.github.io/github/rspec/rspec-mocks)
2
2
 
3
3
  rspec-mocks is a test-double framework for rspec with support for method stubs,
4
4
  fakes, and message expectations on generated test-doubles and real objects
@@ -324,11 +324,42 @@ See the [mutating constants
324
324
  README](https://github.com/rspec/rspec-mocks/blob/master/features/mutating_constants/README.md)
325
325
  for info on this feature.
326
326
 
327
- ## Use `before(:each)`, not `before(:all)`
327
+ ## Use `before(:example)`, not `before(:context)`
328
328
 
329
- Stubs in `before(:all)` are not supported. The reason is that all stubs and mocks get cleared out after each example, so any stub that is set in `before(:all)` would work in the first example that happens to run in that group, but not for any others.
329
+ Stubs in `before(:context)` are not supported. The reason is that all stubs and mocks get cleared out after each example, so any stub that is set in `before(:context)` would work in the first example that happens to run in that group, but not for any others.
330
+
331
+ Instead of `before(:context)`, use `before(:example)`.
332
+
333
+ ## Settings mocks or stubs on any instance of a class
334
+
335
+ rspec-mocks provides two methods, `allow_any_instance_of` and
336
+ `expect_any_instance_of`, that will allow you to stub or mock any instance
337
+ of a class. They are used in place for `allow` or `expect`:
338
+
339
+ ```ruby
340
+ allow_any_instance_of(Widget).to receive(:name).and_return("Wibble")
341
+ expect_any_instance_of(Widget).to receive(:name).and_return("Wobble")
342
+ ```
343
+
344
+ These methods add the appropriate stub or expectation to all instances of
345
+ `Widget`.
346
+
347
+ This feature is sometimes useful when working with legacy code, though in
348
+ general we discourage its use for a number of reasons:
349
+
350
+ * The `rspec-mocks` API is designed for individual object instances, but this
351
+ feature operates on entire classes of objects. As a result there are some
352
+ sematically confusing edge cases. For example in
353
+ `expect_any_instance_of(Widget).to receive(:name).twice` it isn't clear
354
+ whether each specific instance is allowed to receive `name` twice, or if two
355
+ receives total are allowed. (It's the former.)
356
+ * Using this feature is often a design smell. It may be
357
+ that your test is trying to do too much or that the object under test is too
358
+ complex.
359
+ * It is the most complicated feature of `rspec-mocks`, and has historically
360
+ received the most bug reports. (None of the core team actively use it,
361
+ which doesn't help.)
330
362
 
331
- Instead of `before(:all)`, use `before(:each)`.
332
363
 
333
364
  ## Further Reading
334
365
 
@@ -1,7 +1,32 @@
1
- require 'rspec/mocks/framework'
2
- require 'rspec/mocks/version'
3
1
  require 'rspec/support'
2
+ RSpec::Support.require_rspec_support 'caller_filter'
3
+ RSpec::Support.require_rspec_support 'warnings'
4
+ RSpec::Support.require_rspec_support 'ruby_features'
4
5
 
6
+ RSpec::Support.define_optimized_require_for_rspec(:mocks) { |f| require_relative f }
7
+
8
+ %w[
9
+ instance_method_stasher
10
+ method_double
11
+ argument_matchers
12
+ example_methods
13
+ proxy
14
+ test_double
15
+ argument_list_matcher
16
+ message_expectation
17
+ order_group
18
+ error_generator
19
+ space
20
+ mutate_const
21
+ targets
22
+ syntax
23
+ configuration
24
+ verifying_double
25
+ version
26
+ ].each { |name| RSpec::Support.require_rspec_mocks name }
27
+
28
+ # Share the top-level RSpec namespace, because we are a core supported
29
+ # extension.
5
30
  module RSpec
6
31
  # Contains top-level utility methods. While this contains a few
7
32
  # public methods, these are not generally meant to be called from
@@ -36,16 +61,13 @@ module RSpec
36
61
  # added.
37
62
  # @param opts a hash of options, :expected_from is used to set the
38
63
  # original call site
39
- # @param block an optional implementation for the allowance
64
+ # @yield an optional implementation for the allowance
40
65
  #
41
66
  # @example Defines the implementation of `foo` on `bar`, using the passed block
42
67
  # x = 0
43
68
  # RSpec::Mocks.allow_message(bar, :foo) { x += 1 }
44
69
  def self.allow_message(subject, message, opts={}, &block)
45
- orig_caller = opts.fetch(:expected_from) {
46
- CallerFilter.first_non_rspec_line
47
- }
48
- space.proxy_for(subject).add_stub(orig_caller, message, opts, &block)
70
+ space.proxy_for(subject).add_stub(message, opts, &block)
49
71
  end
50
72
 
51
73
  # Sets a message expectation on `subject`.
@@ -54,18 +76,17 @@ module RSpec
54
76
  # expected.
55
77
  # @param opts a hash of options, :expected_from is used to set the
56
78
  # original call site
57
- # @param block an optional implementation for the expectation
79
+ # @yield an optional implementation for the expectation
58
80
  #
59
81
  # @example Expect the message `foo` to receive `bar`, then call it
60
82
  # RSpec::Mocks.expect_message(bar, :foo)
61
83
  # bar.foo
62
84
  def self.expect_message(subject, message, opts={}, &block)
63
- orig_caller = opts.fetch(:expected_from) {
64
- CallerFilter.first_non_rspec_line
65
- }
66
- space.proxy_for(subject).add_message_expectation(orig_caller, message, opts, &block)
85
+ space.proxy_for(subject).add_message_expectation(message, opts, &block)
67
86
  end
68
87
 
88
+ # Call the passed block and verify mocks after it has executed. This allows
89
+ # mock usage in arbitrary places, such as a `before(:all)` hook.
69
90
  def self.with_temporary_scope
70
91
  setup
71
92
 
@@ -77,11 +98,29 @@ module RSpec
77
98
  end
78
99
  end
79
100
 
80
- class << self; attr_reader :space; end
101
+ class << self
102
+ # @private
103
+ attr_reader :space
104
+ end
81
105
  @space_stack = []
82
106
  @root_space = @space = RSpec::Mocks::RootSpace.new
83
107
 
84
108
  # @private
85
109
  IGNORED_BACKTRACE_LINE = 'this backtrace line is ignored'
110
+
111
+ # To speed up boot time a bit, delay loading optional or rarely
112
+ # used features until their first use.
113
+ autoload :AnyInstance, "rspec/mocks/any_instance"
114
+ autoload :ExpectChain, "rspec/mocks/message_chain"
115
+ autoload :StubChain, "rspec/mocks/message_chain"
116
+ autoload :MarshalExtension, "rspec/mocks/marshal_extension"
117
+
118
+ # Namespace for mock-related matchers.
119
+ module Matchers
120
+ autoload :HaveReceived, "rspec/mocks/matchers/have_received"
121
+ autoload :Receive, "rspec/mocks/matchers/receive"
122
+ autoload :ReceiveMessageChain, "rspec/mocks/matchers/receive_message_chain"
123
+ autoload :ReceiveMessages, "rspec/mocks/matchers/receive_messages"
124
+ end
86
125
  end
87
126
  end