mocha 1.8.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.rubocop.yml +3 -0
  4. data/.rubocop_todo.yml +7 -30
  5. data/.yardopts +1 -0
  6. data/README.md +40 -13
  7. data/RELEASE.md +97 -0
  8. data/Rakefile +10 -7
  9. data/bin/build-matrix +1 -2
  10. data/docs/CNAME +1 -1
  11. data/docs/Mocha.html +132 -5
  12. data/docs/Mocha/API.html +437 -206
  13. data/docs/Mocha/ClassMethods.html +13 -16
  14. data/docs/Mocha/Configuration.html +1126 -227
  15. data/docs/Mocha/Expectation.html +420 -267
  16. data/docs/Mocha/ExpectationError.html +5 -10
  17. data/docs/Mocha/ExpectationErrorFactory.html +9 -18
  18. data/docs/Mocha/Hooks.html +12 -27
  19. data/docs/Mocha/Integration.html +3 -3
  20. data/docs/Mocha/Integration/MiniTest.html +3 -3
  21. data/docs/Mocha/Integration/MiniTest/Adapter.html +5 -6
  22. data/docs/Mocha/Integration/TestUnit.html +3 -3
  23. data/docs/Mocha/Integration/TestUnit/Adapter.html +5 -6
  24. data/docs/Mocha/Mock.html +202 -162
  25. data/docs/Mocha/ObjectMethods.html +121 -68
  26. data/docs/Mocha/ParameterMatchers.html +21 -109
  27. data/docs/Mocha/ParameterMatchers/AllOf.html +4 -5
  28. data/docs/Mocha/ParameterMatchers/AnyOf.html +4 -5
  29. data/docs/Mocha/ParameterMatchers/AnyParameters.html +3 -3
  30. data/docs/Mocha/ParameterMatchers/Anything.html +3 -3
  31. data/docs/Mocha/ParameterMatchers/Base.html +8 -15
  32. data/docs/Mocha/ParameterMatchers/Equals.html +4 -5
  33. data/docs/Mocha/ParameterMatchers/EquivalentUri.html +3 -3
  34. data/docs/Mocha/ParameterMatchers/HasEntries.html +4 -5
  35. data/docs/Mocha/ParameterMatchers/HasEntry.html +4 -5
  36. data/docs/Mocha/ParameterMatchers/HasKey.html +4 -5
  37. data/docs/Mocha/ParameterMatchers/HasValue.html +4 -5
  38. data/docs/Mocha/ParameterMatchers/Includes.html +4 -5
  39. data/docs/Mocha/ParameterMatchers/InstanceOf.html +4 -5
  40. data/docs/Mocha/ParameterMatchers/IsA.html +3 -3
  41. data/docs/Mocha/ParameterMatchers/KindOf.html +4 -5
  42. data/docs/Mocha/ParameterMatchers/Not.html +4 -5
  43. data/docs/Mocha/ParameterMatchers/Optionally.html +3 -3
  44. data/docs/Mocha/ParameterMatchers/RegexpMatches.html +4 -5
  45. data/docs/Mocha/ParameterMatchers/RespondsWith.html +4 -5
  46. data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +4 -5
  47. data/docs/Mocha/Sequence.html +3 -3
  48. data/docs/Mocha/StateMachine.html +13 -25
  49. data/docs/Mocha/StateMachine/State.html +4 -5
  50. data/docs/Mocha/StateMachine/StatePredicate.html +4 -5
  51. data/docs/Mocha/StubbingError.html +3 -3
  52. data/docs/_index.html +4 -22
  53. data/docs/class_list.html +1 -1
  54. data/docs/file.COPYING.html +3 -3
  55. data/docs/file.MIT-LICENSE.html +3 -3
  56. data/docs/file.README.html +46 -16
  57. data/docs/file.RELEASE.html +130 -3
  58. data/docs/frames.html +1 -1
  59. data/docs/index.html +46 -16
  60. data/docs/js/app.js +11 -0
  61. data/docs/method_list.html +117 -37
  62. data/docs/top-level-namespace.html +3 -3
  63. data/gemfiles/Gemfile.minitest.5.11.3 +7 -0
  64. data/init.rb +1 -3
  65. data/lib/mocha.rb +8 -0
  66. data/lib/mocha/any_instance_method.rb +11 -53
  67. data/lib/mocha/api.rb +120 -56
  68. data/lib/mocha/block_matcher.rb +31 -0
  69. data/lib/mocha/cardinality.rb +26 -11
  70. data/lib/mocha/class_methods.rb +17 -15
  71. data/lib/mocha/configuration.rb +351 -67
  72. data/lib/mocha/deprecation.rb +2 -1
  73. data/lib/mocha/detection/test_unit.rb +1 -3
  74. data/lib/mocha/exception_raiser.rb +2 -1
  75. data/lib/mocha/expectation.rb +102 -63
  76. data/lib/mocha/expectation_error.rb +1 -3
  77. data/lib/mocha/expectation_list.rb +6 -6
  78. data/lib/mocha/inspect.rb +28 -26
  79. data/lib/mocha/instance_method.rb +19 -2
  80. data/lib/mocha/integration.rb +1 -3
  81. data/lib/mocha/integration/mini_test.rb +7 -0
  82. data/lib/mocha/integration/test_unit.rb +7 -0
  83. data/lib/mocha/invocation.rb +77 -0
  84. data/lib/mocha/macos_version.rb +5 -0
  85. data/lib/mocha/minitest.rb +6 -1
  86. data/lib/mocha/mock.rb +46 -31
  87. data/lib/mocha/mockery.rb +25 -61
  88. data/lib/mocha/names.rb +1 -1
  89. data/lib/mocha/object_methods.rb +13 -19
  90. data/lib/mocha/parameter_matchers.rb +1 -1
  91. data/lib/mocha/parameter_matchers/all_of.rb +1 -1
  92. data/lib/mocha/parameter_matchers/any_of.rb +1 -1
  93. data/lib/mocha/parameter_matchers/equivalent_uri.rb +0 -9
  94. data/lib/mocha/parameter_matchers/includes.rb +2 -0
  95. data/lib/mocha/parameter_matchers/instance_methods.rb +18 -0
  96. data/lib/mocha/raised_exception.rb +11 -0
  97. data/lib/mocha/return_values.rb +3 -3
  98. data/lib/mocha/setup.rb +5 -0
  99. data/lib/mocha/single_return_value.rb +2 -1
  100. data/lib/mocha/singleton_class.rb +9 -0
  101. data/lib/mocha/stubbed_method.rb +127 -0
  102. data/lib/mocha/test_unit.rb +6 -1
  103. data/lib/mocha/thrower.rb +2 -1
  104. data/lib/mocha/thrown_object.rb +12 -0
  105. data/lib/mocha/version.rb +1 -1
  106. data/lib/mocha/yield_parameters.rb +5 -11
  107. data/mocha.gemspec +1 -3
  108. data/test/acceptance/acceptance_test_helper.rb +7 -0
  109. data/test/acceptance/bug_18914_test.rb +0 -1
  110. data/test/acceptance/bug_21465_test.rb +0 -1
  111. data/test/acceptance/bug_21563_test.rb +0 -1
  112. data/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +69 -0
  113. data/test/acceptance/exception_rescue_test.rb +1 -2
  114. data/test/acceptance/expectations_on_multiple_methods_test.rb +0 -1
  115. data/test/acceptance/expected_invocation_count_test.rb +2 -3
  116. data/test/acceptance/failure_messages_test.rb +16 -1
  117. data/test/acceptance/issue_272_test.rb +1 -2
  118. data/test/acceptance/issue_65_test.rb +0 -1
  119. data/test/acceptance/issue_70_test.rb +0 -1
  120. data/test/acceptance/mocha_example_test.rb +0 -1
  121. data/test/acceptance/mocha_test_result_test.rb +0 -1
  122. data/test/acceptance/mock_built_with_first_argument_type_being_string_test.rb +99 -0
  123. data/test/acceptance/mock_test.rb +47 -6
  124. data/test/acceptance/mocked_methods_dispatch_test.rb +0 -1
  125. data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -1
  126. data/test/acceptance/multiple_yielding_test.rb +56 -0
  127. data/test/acceptance/optional_parameters_test.rb +0 -1
  128. data/test/acceptance/parameter_matcher_test.rb +0 -1
  129. data/test/acceptance/partial_mocks_test.rb +0 -1
  130. data/test/acceptance/prepend_test.rb +0 -1
  131. data/test/acceptance/prevent_use_of_mocha_outside_test_test.rb +0 -1
  132. data/test/acceptance/raise_exception_test.rb +0 -1
  133. data/test/acceptance/return_value_test.rb +0 -1
  134. data/test/acceptance/sequence_test.rb +0 -1
  135. data/test/acceptance/states_test.rb +0 -1
  136. data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +1 -2
  137. data/test/acceptance/stub_any_instance_method_test.rb +20 -1
  138. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +0 -1
  139. data/test/acceptance/stub_class_method_defined_on_class_test.rb +0 -1
  140. data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -1
  141. data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +1 -2
  142. data/test/acceptance/stub_everything_test.rb +0 -1
  143. data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +0 -1
  144. data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -1
  145. data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -1
  146. data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +0 -1
  147. data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -1
  148. data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +0 -1
  149. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -1
  150. data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -1
  151. data/test/acceptance/stub_method_defined_on_module_and_aliased_test.rb +0 -1
  152. data/test/acceptance/stub_module_method_test.rb +0 -1
  153. data/test/acceptance/stub_test.rb +0 -1
  154. data/test/acceptance/stubba_example_test.rb +0 -1
  155. data/test/acceptance/stubba_test_result_test.rb +0 -1
  156. data/test/acceptance/stubbing_error_backtrace_test.rb +4 -5
  157. data/test/acceptance/stubbing_frozen_object_test.rb +0 -1
  158. data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +0 -1
  159. data/test/acceptance/stubbing_method_unnecessarily_test.rb +5 -5
  160. data/test/acceptance/stubbing_nil_test.rb +5 -5
  161. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +27 -11
  162. data/test/acceptance/stubbing_non_existent_class_method_test.rb +11 -11
  163. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +11 -11
  164. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +8 -8
  165. data/test/acceptance/stubbing_non_public_class_method_test.rb +9 -9
  166. data/test/acceptance/stubbing_non_public_instance_method_test.rb +9 -9
  167. data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
  168. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +0 -1
  169. data/test/acceptance/throw_test.rb +0 -1
  170. data/test/acceptance/unexpected_invocation_test.rb +0 -1
  171. data/test/acceptance/unstubbing_test.rb +0 -1
  172. data/test/acceptance/yielding_test.rb +78 -0
  173. data/test/integration/shared_tests.rb +5 -3
  174. data/test/method_definer.rb +11 -17
  175. data/test/test_runner.rb +2 -0
  176. data/test/unit/any_instance_method_test.rb +60 -35
  177. data/test/unit/cardinality_test.rb +41 -23
  178. data/test/unit/central_test.rb +0 -1
  179. data/test/unit/class_methods_test.rb +1 -1
  180. data/test/unit/configuration_test.rb +12 -12
  181. data/test/unit/exception_raiser_test.rb +10 -5
  182. data/test/unit/expectation_list_test.rb +13 -11
  183. data/test/unit/expectation_test.rb +117 -103
  184. data/test/unit/instance_method_test.rb +282 -0
  185. data/test/unit/mock_test.rb +28 -19
  186. data/test/unit/mockery_test.rb +8 -11
  187. data/test/unit/module_methods_test.rb +2 -3
  188. data/test/unit/object_inspect_test.rb +6 -4
  189. data/test/unit/object_methods_test.rb +3 -2
  190. data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -9
  191. data/test/unit/parameter_matchers/has_entries_test.rb +1 -1
  192. data/test/unit/parameter_matchers/has_entry_test.rb +1 -1
  193. data/test/unit/parameter_matchers/has_key_test.rb +1 -1
  194. data/test/unit/parameter_matchers/has_value_test.rb +1 -1
  195. data/test/unit/parameter_matchers/includes_test.rb +1 -1
  196. data/test/unit/parameter_matchers/responds_with_test.rb +1 -1
  197. data/test/unit/return_values_test.rb +25 -20
  198. data/test/unit/single_return_value_test.rb +6 -1
  199. data/test/unit/thrower_test.rb +7 -2
  200. data/test/unit/yield_parameters_test.rb +35 -53
  201. metadata +18 -35
  202. data/docs/Mocha/UnexpectedInvocation.html +0 -140
  203. data/lib/mocha/class_method.rb +0 -113
  204. data/lib/mocha/mini_test.rb +0 -5
  205. data/lib/mocha/module_method.rb +0 -6
  206. data/lib/mocha/module_methods.rb +0 -10
  207. data/lib/mocha/multiple_yields.rb +0 -15
  208. data/lib/mocha/no_yields.rb +0 -5
  209. data/lib/mocha/parameter_matchers/object.rb +0 -15
  210. data/lib/mocha/single_yield.rb +0 -13
  211. data/lib/mocha/standalone.rb +0 -4
  212. data/lib/mocha/unexpected_invocation.rb +0 -24
  213. data/lib/mocha_standalone.rb +0 -4
  214. data/test/acceptance/mock_with_initializer_block_test.rb +0 -56
  215. data/test/unit/class_method_test.rb +0 -254
  216. data/test/unit/multiple_yields_test.rb +0 -16
  217. data/test/unit/no_yields_test.rb +0 -16
  218. data/test/unit/single_yield_test.rb +0 -16
@@ -68,7 +68,7 @@
68
68
  </li>
69
69
 
70
70
 
71
- <li class="even ">
71
+ <li class="even deprecated">
72
72
  <div class="item">
73
73
  <span class='object_link'><a href="Mocha/Configuration.html#allow-class_method" title="Mocha::Configuration.allow (method)">allow</a></span>
74
74
  <small>Mocha::Configuration</small>
@@ -148,6 +148,22 @@
148
148
  </li>
149
149
 
150
150
 
151
+ <li class="even ">
152
+ <div class="item">
153
+ <span class='object_link'><a href="Mocha.html#configure-class_method" title="Mocha.configure (method)">configure</a></span>
154
+ <small>Mocha</small>
155
+ </div>
156
+ </li>
157
+
158
+
159
+ <li class="odd ">
160
+ <div class="item">
161
+ <span class='object_link'><a href="Mocha/Configuration.html#display_matching_invocations_on_failure=-instance_method" title="Mocha::Configuration#display_matching_invocations_on_failure= (method)">#display_matching_invocations_on_failure=</a></span>
162
+ <small>Mocha::Configuration</small>
163
+ </div>
164
+ </li>
165
+
166
+
151
167
  <li class="even ">
152
168
  <div class="item">
153
169
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#equals-instance_method" title="Mocha::ParameterMatchers#equals (method)">#equals</a></span>
@@ -204,15 +220,7 @@
204
220
  </li>
205
221
 
206
222
 
207
- <li class="odd deprecated">
208
- <div class="item">
209
- <span class='object_link'><a href="Mocha/ParameterMatchers.html#has_equivalent_query_string-instance_method" title="Mocha::ParameterMatchers#has_equivalent_query_string (method)">#has_equivalent_query_string</a></span>
210
- <small>Mocha::ParameterMatchers</small>
211
- </div>
212
- </li>
213
-
214
-
215
- <li class="even ">
223
+ <li class="odd ">
216
224
  <div class="item">
217
225
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#has_key-instance_method" title="Mocha::ParameterMatchers#has_key (method)">#has_key</a></span>
218
226
  <small>Mocha::ParameterMatchers</small>
@@ -220,7 +228,7 @@
220
228
  </li>
221
229
 
222
230
 
223
- <li class="odd ">
231
+ <li class="even ">
224
232
  <div class="item">
225
233
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#has_value-instance_method" title="Mocha::ParameterMatchers#has_value (method)">#has_value</a></span>
226
234
  <small>Mocha::ParameterMatchers</small>
@@ -228,7 +236,7 @@
228
236
  </li>
229
237
 
230
238
 
231
- <li class="even ">
239
+ <li class="odd ">
232
240
  <div class="item">
233
241
  <span class='object_link'><a href="Mocha/Expectation.html#in_sequence-instance_method" title="Mocha::Expectation#in_sequence (method)">#in_sequence</a></span>
234
242
  <small>Mocha::Expectation</small>
@@ -236,7 +244,7 @@
236
244
  </li>
237
245
 
238
246
 
239
- <li class="odd ">
247
+ <li class="even ">
240
248
  <div class="item">
241
249
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#includes-instance_method" title="Mocha::ParameterMatchers#includes (method)">#includes</a></span>
242
250
  <small>Mocha::ParameterMatchers</small>
@@ -244,7 +252,7 @@
244
252
  </li>
245
253
 
246
254
 
247
- <li class="even ">
255
+ <li class="odd ">
248
256
  <div class="item">
249
257
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#instance_of-instance_method" title="Mocha::ParameterMatchers#instance_of (method)">#instance_of</a></span>
250
258
  <small>Mocha::ParameterMatchers</small>
@@ -252,7 +260,7 @@
252
260
  </li>
253
261
 
254
262
 
255
- <li class="odd ">
263
+ <li class="even ">
256
264
  <div class="item">
257
265
  <span class='object_link'><a href="Mocha/StateMachine.html#is-instance_method" title="Mocha::StateMachine#is (method)">#is</a></span>
258
266
  <small>Mocha::StateMachine</small>
@@ -260,7 +268,7 @@
260
268
  </li>
261
269
 
262
270
 
263
- <li class="even ">
271
+ <li class="odd ">
264
272
  <div class="item">
265
273
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#is_a-instance_method" title="Mocha::ParameterMatchers#is_a (method)">#is_a</a></span>
266
274
  <small>Mocha::ParameterMatchers</small>
@@ -268,7 +276,7 @@
268
276
  </li>
269
277
 
270
278
 
271
- <li class="odd ">
279
+ <li class="even ">
272
280
  <div class="item">
273
281
  <span class='object_link'><a href="Mocha/StateMachine.html#is_not-instance_method" title="Mocha::StateMachine#is_not (method)">#is_not</a></span>
274
282
  <small>Mocha::StateMachine</small>
@@ -276,7 +284,7 @@
276
284
  </li>
277
285
 
278
286
 
279
- <li class="even ">
287
+ <li class="odd ">
280
288
  <div class="item">
281
289
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#kind_of-instance_method" title="Mocha::ParameterMatchers#kind_of (method)">#kind_of</a></span>
282
290
  <small>Mocha::ParameterMatchers</small>
@@ -284,7 +292,7 @@
284
292
  </li>
285
293
 
286
294
 
287
- <li class="odd ">
295
+ <li class="even ">
288
296
  <div class="item">
289
297
  <span class='object_link'><a href="Mocha/Hooks.html#mocha_setup-instance_method" title="Mocha::Hooks#mocha_setup (method)">#mocha_setup</a></span>
290
298
  <small>Mocha::Hooks</small>
@@ -292,7 +300,7 @@
292
300
  </li>
293
301
 
294
302
 
295
- <li class="even ">
303
+ <li class="odd ">
296
304
  <div class="item">
297
305
  <span class='object_link'><a href="Mocha/Hooks.html#mocha_teardown-instance_method" title="Mocha::Hooks#mocha_teardown (method)">#mocha_teardown</a></span>
298
306
  <small>Mocha::Hooks</small>
@@ -300,7 +308,7 @@
300
308
  </li>
301
309
 
302
310
 
303
- <li class="odd ">
311
+ <li class="even ">
304
312
  <div class="item">
305
313
  <span class='object_link'><a href="Mocha/Hooks.html#mocha_verify-instance_method" title="Mocha::Hooks#mocha_verify (method)">#mocha_verify</a></span>
306
314
  <small>Mocha::Hooks</small>
@@ -308,7 +316,7 @@
308
316
  </li>
309
317
 
310
318
 
311
- <li class="even ">
319
+ <li class="odd ">
312
320
  <div class="item">
313
321
  <span class='object_link'><a href="Mocha/API.html#mock-instance_method" title="Mocha::API#mock (method)">#mock</a></span>
314
322
  <small>Mocha::API</small>
@@ -316,7 +324,7 @@
316
324
  </li>
317
325
 
318
326
 
319
- <li class="odd ">
327
+ <li class="even ">
320
328
  <div class="item">
321
329
  <span class='object_link'><a href="Mocha/Expectation.html#multiple_yields-instance_method" title="Mocha::Expectation#multiple_yields (method)">#multiple_yields</a></span>
322
330
  <small>Mocha::Expectation</small>
@@ -324,7 +332,7 @@
324
332
  </li>
325
333
 
326
334
 
327
- <li class="even ">
335
+ <li class="odd ">
328
336
  <div class="item">
329
337
  <span class='object_link'><a href="Mocha/Expectation.html#never-instance_method" title="Mocha::Expectation#never (method)">#never</a></span>
330
338
  <small>Mocha::Expectation</small>
@@ -332,7 +340,7 @@
332
340
  </li>
333
341
 
334
342
 
335
- <li class="odd ">
343
+ <li class="even ">
336
344
  <div class="item">
337
345
  <span class='object_link'><a href="Mocha/Expectation.html#once-instance_method" title="Mocha::Expectation#once (method)">#once</a></span>
338
346
  <small>Mocha::Expectation</small>
@@ -340,7 +348,7 @@
340
348
  </li>
341
349
 
342
350
 
343
- <li class="even ">
351
+ <li class="odd ">
344
352
  <div class="item">
345
353
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#optionally-instance_method" title="Mocha::ParameterMatchers#optionally (method)">#optionally</a></span>
346
354
  <small>Mocha::ParameterMatchers</small>
@@ -348,7 +356,15 @@
348
356
  </li>
349
357
 
350
358
 
351
- <li class="odd ">
359
+ <li class="even ">
360
+ <div class="item">
361
+ <span class='object_link'><a href="Mocha/Configuration.html#override-class_method" title="Mocha::Configuration.override (method)">override</a></span>
362
+ <small>Mocha::Configuration</small>
363
+ </div>
364
+ </li>
365
+
366
+
367
+ <li class="odd deprecated">
352
368
  <div class="item">
353
369
  <span class='object_link'><a href="Mocha/Configuration.html#prevent-class_method" title="Mocha::Configuration.prevent (method)">prevent</a></span>
354
370
  <small>Mocha::Configuration</small>
@@ -373,6 +389,14 @@
373
389
 
374
390
 
375
391
  <li class="even ">
392
+ <div class="item">
393
+ <span class='object_link'><a href="Mocha/Configuration.html#reinstate_undocumented_behaviour_from_v1_9=-instance_method" title="Mocha::Configuration#reinstate_undocumented_behaviour_from_v1_9= (method)">#reinstate_undocumented_behaviour_from_v1_9=</a></span>
394
+ <small>Mocha::Configuration</small>
395
+ </div>
396
+ </li>
397
+
398
+
399
+ <li class="odd ">
376
400
  <div class="item">
377
401
  <span class='object_link'><a href="Mocha/Mock.html#respond_to%3F-instance_method" title="Mocha::Mock#respond_to? (method)">#respond_to?</a></span>
378
402
  <small>Mocha::Mock</small>
@@ -380,7 +404,7 @@
380
404
  </li>
381
405
 
382
406
 
383
- <li class="odd ">
407
+ <li class="even ">
384
408
  <div class="item">
385
409
  <span class='object_link'><a href="Mocha/Mock.html#responds_like-instance_method" title="Mocha::Mock#responds_like (method)">#responds_like</a></span>
386
410
  <small>Mocha::Mock</small>
@@ -388,7 +412,7 @@
388
412
  </li>
389
413
 
390
414
 
391
- <li class="even ">
415
+ <li class="odd ">
392
416
  <div class="item">
393
417
  <span class='object_link'><a href="Mocha/Mock.html#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">#responds_like_instance_of</a></span>
394
418
  <small>Mocha::Mock</small>
@@ -396,7 +420,7 @@
396
420
  </li>
397
421
 
398
422
 
399
- <li class="odd ">
423
+ <li class="even ">
400
424
  <div class="item">
401
425
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#responds_with-instance_method" title="Mocha::ParameterMatchers#responds_with (method)">#responds_with</a></span>
402
426
  <small>Mocha::ParameterMatchers</small>
@@ -404,7 +428,7 @@
404
428
  </li>
405
429
 
406
430
 
407
- <li class="even ">
431
+ <li class="odd ">
408
432
  <div class="item">
409
433
  <span class='object_link'><a href="Mocha/Expectation.html#returns-instance_method" title="Mocha::Expectation#returns (method)">#returns</a></span>
410
434
  <small>Mocha::Expectation</small>
@@ -412,7 +436,7 @@
412
436
  </li>
413
437
 
414
438
 
415
- <li class="odd ">
439
+ <li class="even ">
416
440
  <div class="item">
417
441
  <span class='object_link'><a href="Mocha/API.html#sequence-instance_method" title="Mocha::API#sequence (method)">#sequence</a></span>
418
442
  <small>Mocha::API</small>
@@ -420,7 +444,7 @@
420
444
  </li>
421
445
 
422
446
 
423
- <li class="even ">
447
+ <li class="odd ">
424
448
  <div class="item">
425
449
  <span class='object_link'><a href="Mocha/StateMachine.html#starts_as-instance_method" title="Mocha::StateMachine#starts_as (method)">#starts_as</a></span>
426
450
  <small>Mocha::StateMachine</small>
@@ -428,7 +452,7 @@
428
452
  </li>
429
453
 
430
454
 
431
- <li class="odd ">
455
+ <li class="even ">
432
456
  <div class="item">
433
457
  <span class='object_link'><a href="Mocha/API.html#states-instance_method" title="Mocha::API#states (method)">#states</a></span>
434
458
  <small>Mocha::API</small>
@@ -436,7 +460,7 @@
436
460
  </li>
437
461
 
438
462
 
439
- <li class="even ">
463
+ <li class="odd ">
440
464
  <div class="item">
441
465
  <span class='object_link'><a href="Mocha/API.html#stub-instance_method" title="Mocha::API#stub (method)">#stub</a></span>
442
466
  <small>Mocha::API</small>
@@ -444,7 +468,7 @@
444
468
  </li>
445
469
 
446
470
 
447
- <li class="odd ">
471
+ <li class="even ">
448
472
  <div class="item">
449
473
  <span class='object_link'><a href="Mocha/API.html#stub_everything-instance_method" title="Mocha::API#stub_everything (method)">#stub_everything</a></span>
450
474
  <small>Mocha::API</small>
@@ -452,6 +476,46 @@
452
476
  </li>
453
477
 
454
478
 
479
+ <li class="odd ">
480
+ <div class="item">
481
+ <span class='object_link'><a href="Mocha/Configuration.html#stubbing_method_on_nil=-instance_method" title="Mocha::Configuration#stubbing_method_on_nil= (method)">#stubbing_method_on_nil=</a></span>
482
+ <small>Mocha::Configuration</small>
483
+ </div>
484
+ </li>
485
+
486
+
487
+ <li class="even ">
488
+ <div class="item">
489
+ <span class='object_link'><a href="Mocha/Configuration.html#stubbing_method_on_non_mock_object=-instance_method" title="Mocha::Configuration#stubbing_method_on_non_mock_object= (method)">#stubbing_method_on_non_mock_object=</a></span>
490
+ <small>Mocha::Configuration</small>
491
+ </div>
492
+ </li>
493
+
494
+
495
+ <li class="odd ">
496
+ <div class="item">
497
+ <span class='object_link'><a href="Mocha/Configuration.html#stubbing_method_unnecessarily=-instance_method" title="Mocha::Configuration#stubbing_method_unnecessarily= (method)">#stubbing_method_unnecessarily=</a></span>
498
+ <small>Mocha::Configuration</small>
499
+ </div>
500
+ </li>
501
+
502
+
503
+ <li class="even ">
504
+ <div class="item">
505
+ <span class='object_link'><a href="Mocha/Configuration.html#stubbing_non_existent_method=-instance_method" title="Mocha::Configuration#stubbing_non_existent_method= (method)">#stubbing_non_existent_method=</a></span>
506
+ <small>Mocha::Configuration</small>
507
+ </div>
508
+ </li>
509
+
510
+
511
+ <li class="odd ">
512
+ <div class="item">
513
+ <span class='object_link'><a href="Mocha/Configuration.html#stubbing_non_public_method=-instance_method" title="Mocha::Configuration#stubbing_non_public_method= (method)">#stubbing_non_public_method=</a></span>
514
+ <small>Mocha::Configuration</small>
515
+ </div>
516
+ </li>
517
+
518
+
455
519
  <li class="even ">
456
520
  <div class="item">
457
521
  <span class='object_link'><a href="Mocha/ObjectMethods.html#stubs-instance_method" title="Mocha::ObjectMethods#stubs (method)">#stubs</a></span>
@@ -516,7 +580,7 @@
516
580
  </li>
517
581
 
518
582
 
519
- <li class="even ">
583
+ <li class="even deprecated">
520
584
  <div class="item">
521
585
  <span class='object_link'><a href="Mocha/Configuration.html#warn_when-class_method" title="Mocha::Configuration.warn_when (method)">warn_when</a></span>
522
586
  <small>Mocha::Configuration</small>
@@ -540,6 +604,22 @@
540
604
  </li>
541
605
 
542
606
 
607
+ <li class="odd ">
608
+ <div class="item">
609
+ <span class='object_link'><a href="Mocha/Expectation.html#with_block_given-instance_method" title="Mocha::Expectation#with_block_given (method)">#with_block_given</a></span>
610
+ <small>Mocha::Expectation</small>
611
+ </div>
612
+ </li>
613
+
614
+
615
+ <li class="even ">
616
+ <div class="item">
617
+ <span class='object_link'><a href="Mocha/Expectation.html#with_no_block_given-instance_method" title="Mocha::Expectation#with_no_block_given (method)">#with_no_block_given</a></span>
618
+ <small>Mocha::Expectation</small>
619
+ </div>
620
+ </li>
621
+
622
+
543
623
  <li class="odd ">
544
624
  <div class="item">
545
625
  <span class='object_link'><a href="Mocha/ParameterMatchers.html#yaml_equivalent-instance_method" title="Mocha::ParameterMatchers#yaml_equivalent (method)">#yaml_equivalent</a></span>
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Mocha 1.8.0
9
+ &mdash; Mocha 1.11.0
10
10
 
11
11
  </title>
12
12
 
@@ -108,9 +108,9 @@
108
108
  </div>
109
109
 
110
110
  <div id="footer">
111
- Generated on Tue Jan 15 17:13:05 2019 by
111
+ Generated on Mon Dec 16 18:49:50 2019 by
112
112
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
113
- 0.9.16 (ruby-2.5.3).
113
+ 0.9.20 (ruby-2.6.5).
114
114
  </div>
115
115
 
116
116
  </div>
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path=>"../"
4
+
5
+ group :development do
6
+ gem "minitest", "5.11.3"
7
+ end
data/init.rb CHANGED
@@ -1,3 +1 @@
1
- # Mocha should no longer be loaded at plugin load time
2
- # You should explicitly load Mocha *after* Test::Unit or MiniTest have been loaded
3
- # e.g. by adding "require 'mocha'" at the bottom of test/test_helper.rb
1
+ warn 'Mocha deprecation warning: The old-style Rails plugin will not be supported in future versions of Mocha.'
@@ -1 +1,9 @@
1
1
  require 'mocha/version'
2
+ require 'mocha/ruby_version'
3
+ require 'mocha/deprecation'
4
+
5
+ if Mocha::PRE_RUBY_V19
6
+ Mocha::Deprecation.warning(
7
+ 'Versions of Ruby earlier than v1.9 will not be supported in future versions of Mocha.'
8
+ )
9
+ end
@@ -1,66 +1,24 @@
1
1
  require 'mocha/ruby_version'
2
- require 'mocha/class_method'
2
+ require 'mocha/stubbed_method'
3
3
 
4
4
  module Mocha
5
- class AnyInstanceMethod < ClassMethod
6
- def mock
7
- stubbee.any_instance.mocha
8
- end
9
-
10
- def reset_mocha
11
- stubbee.any_instance.reset_mocha
12
- end
13
-
14
- def hide_original_method
15
- return unless (@original_visibility = method_visibility(method))
16
- begin
17
- if RUBY_V2_PLUS
18
- @definition_target = PrependedModule.new
19
- stubbee.__send__ :prepend, @definition_target
20
- else
21
- @original_method = stubbee.instance_method(method)
22
- if @original_method && @original_method.owner == stubbee
23
- stubbee.send(:remove_method, method)
24
- end
25
- end
26
- # rubocop:disable Lint/HandleExceptions
27
- rescue NameError
28
- # deal with nasties like ActiveRecord::Associations::AssociationProxy
29
- end
30
- # rubocop:enable Lint/HandleExceptions
31
- end
32
-
33
- def define_new_method
34
- definition_target.class_eval(<<-CODE, __FILE__, __LINE__ + 1)
35
- def #{method}(*args, &block)
36
- self.class.any_instance.mocha.method_missing(:#{method}, *args, &block)
37
- end
38
- CODE
39
- return unless @original_visibility
40
- Module.instance_method(@original_visibility).bind(definition_target).call(method)
41
- end
5
+ class AnyInstanceMethod < StubbedMethod
6
+ private
42
7
 
43
- def remove_new_method
44
- definition_target.send(:remove_method, method)
8
+ def mock_owner
9
+ stubbee.any_instance
45
10
  end
46
11
 
47
- def restore_original_method
48
- return if RUBY_V2_PLUS
49
- return unless @original_method && @original_method.owner == stubbee
50
- stubbee.send(:define_method, method, @original_method)
51
- Module.instance_method(@original_visibility).bind(stubbee).call(method)
12
+ def method_body(method)
13
+ method
52
14
  end
53
15
 
54
- def method_visibility(method)
55
- (stubbee.public_instance_methods(true).include?(method) && :public) ||
56
- (stubbee.protected_instance_methods(true).include?(method) && :protected) ||
57
- (stubbee.private_instance_methods(true).include?(method) && :private)
16
+ def stubbee_method(method_name)
17
+ stubbee.instance_method(method_name)
58
18
  end
59
19
 
60
- private
61
-
62
- def definition_target
63
- @definition_target ||= stubbee
20
+ def original_method_owner
21
+ stubbee
64
22
  end
65
23
  end
66
24
  end