mocha 1.5.0 → 1.10.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +61 -0
  3. data/.rubocop_todo.yml +27 -0
  4. data/CONTRIBUTING.md +4 -9
  5. data/README.md +46 -97
  6. data/RELEASE.md +83 -0
  7. data/Rakefile +44 -38
  8. data/bin/build-matrix +32 -20
  9. data/docs/CNAME +1 -0
  10. data/docs/Mocha.html +254 -0
  11. data/docs/Mocha/API.html +1129 -0
  12. data/docs/Mocha/ClassMethods.html +339 -0
  13. data/docs/Mocha/Configuration.html +1383 -0
  14. data/docs/Mocha/Expectation.html +2654 -0
  15. data/docs/Mocha/ExpectationError.html +152 -0
  16. data/docs/Mocha/ExpectationErrorFactory.html +260 -0
  17. data/docs/Mocha/Hooks.html +370 -0
  18. data/docs/Mocha/Integration.html +125 -0
  19. data/docs/Mocha/Integration/MiniTest.html +123 -0
  20. data/docs/Mocha/Integration/MiniTest/Adapter.html +164 -0
  21. data/docs/Mocha/Integration/TestUnit.html +123 -0
  22. data/docs/Mocha/Integration/TestUnit/Adapter.html +164 -0
  23. data/docs/Mocha/Mock.html +1237 -0
  24. data/docs/Mocha/ObjectMethods.html +765 -0
  25. data/docs/Mocha/ParameterMatchers.html +2961 -0
  26. data/docs/Mocha/ParameterMatchers/AllOf.html +153 -0
  27. data/docs/Mocha/ParameterMatchers/AnyOf.html +153 -0
  28. data/docs/Mocha/ParameterMatchers/AnyParameters.html +153 -0
  29. data/docs/Mocha/ParameterMatchers/Anything.html +153 -0
  30. data/docs/Mocha/ParameterMatchers/Base.html +441 -0
  31. data/docs/Mocha/ParameterMatchers/Equals.html +153 -0
  32. data/docs/Mocha/ParameterMatchers/EquivalentUri.html +153 -0
  33. data/docs/Mocha/ParameterMatchers/HasEntries.html +153 -0
  34. data/docs/Mocha/ParameterMatchers/HasEntry.html +153 -0
  35. data/docs/Mocha/ParameterMatchers/HasKey.html +153 -0
  36. data/docs/Mocha/ParameterMatchers/HasValue.html +153 -0
  37. data/docs/Mocha/ParameterMatchers/Includes.html +153 -0
  38. data/docs/Mocha/ParameterMatchers/InstanceOf.html +153 -0
  39. data/docs/Mocha/ParameterMatchers/IsA.html +153 -0
  40. data/docs/Mocha/ParameterMatchers/KindOf.html +153 -0
  41. data/docs/Mocha/ParameterMatchers/Not.html +153 -0
  42. data/docs/Mocha/ParameterMatchers/Optionally.html +153 -0
  43. data/docs/Mocha/ParameterMatchers/RegexpMatches.html +153 -0
  44. data/docs/Mocha/ParameterMatchers/RespondsWith.html +153 -0
  45. data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +153 -0
  46. data/docs/Mocha/Sequence.html +149 -0
  47. data/docs/Mocha/StateMachine.html +527 -0
  48. data/docs/Mocha/StateMachine/State.html +140 -0
  49. data/docs/Mocha/StateMachine/StatePredicate.html +140 -0
  50. data/docs/Mocha/StubbingError.html +150 -0
  51. data/docs/_index.html +519 -0
  52. data/docs/class_list.html +51 -0
  53. data/docs/css/common.css +1 -0
  54. data/docs/css/full_list.css +58 -0
  55. data/docs/css/style.css +496 -0
  56. data/docs/file.COPYING.html +81 -0
  57. data/docs/file.MIT-LICENSE.html +85 -0
  58. data/docs/file.README.html +429 -0
  59. data/docs/file.RELEASE.html +942 -0
  60. data/docs/file_list.html +71 -0
  61. data/docs/frames.html +17 -0
  62. data/docs/index.html +429 -0
  63. data/docs/js/app.js +303 -0
  64. data/docs/js/full_list.js +216 -0
  65. data/docs/js/jquery.js +4 -0
  66. data/docs/method_list.html +635 -0
  67. data/docs/top-level-namespace.html +118 -0
  68. data/gemfiles/Gemfile.minitest.5.11.3 +7 -0
  69. data/init.rb +1 -3
  70. data/lib/mocha.rb +8 -0
  71. data/lib/mocha/any_instance_method.rb +11 -59
  72. data/lib/mocha/api.rb +62 -70
  73. data/lib/mocha/argument_iterator.rb +4 -8
  74. data/lib/mocha/backtrace_filter.rb +1 -5
  75. data/lib/mocha/cardinality.rb +43 -35
  76. data/lib/mocha/central.rb +7 -15
  77. data/lib/mocha/change_state_side_effect.rb +0 -4
  78. data/lib/mocha/class_methods.rb +18 -21
  79. data/lib/mocha/configuration.rb +305 -18
  80. data/lib/mocha/debug.rb +3 -2
  81. data/lib/mocha/deprecation.rb +4 -11
  82. data/lib/mocha/detection/mini_test.rb +0 -2
  83. data/lib/mocha/detection/test_unit.rb +3 -5
  84. data/lib/mocha/error_with_filtered_backtrace.rb +0 -4
  85. data/lib/mocha/exception_raiser.rb +4 -6
  86. data/lib/mocha/expectation.rb +62 -67
  87. data/lib/mocha/expectation_error.rb +1 -1
  88. data/lib/mocha/expectation_error_factory.rb +0 -1
  89. data/lib/mocha/expectation_list.rb +7 -11
  90. data/lib/mocha/hooks.rb +0 -1
  91. data/lib/mocha/in_state_ordering_constraint.rb +0 -4
  92. data/lib/mocha/inspect.rb +28 -28
  93. data/lib/mocha/instance_method.rb +18 -3
  94. data/lib/mocha/integration.rb +2 -5
  95. data/lib/mocha/integration/mini_test.rb +7 -0
  96. data/lib/mocha/integration/mini_test/adapter.rb +2 -4
  97. data/lib/mocha/integration/mini_test/exception_translation.rb +1 -1
  98. data/lib/mocha/integration/mini_test/nothing.rb +4 -4
  99. data/lib/mocha/integration/mini_test/version_13.rb +3 -1
  100. data/lib/mocha/integration/mini_test/version_140.rb +3 -1
  101. data/lib/mocha/integration/mini_test/version_141.rb +3 -1
  102. data/lib/mocha/integration/mini_test/version_142_to_172.rb +3 -1
  103. data/lib/mocha/integration/mini_test/version_200.rb +3 -1
  104. data/lib/mocha/integration/mini_test/version_201_to_222.rb +3 -1
  105. data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +3 -1
  106. data/lib/mocha/integration/mini_test/version_2112_to_320.rb +3 -1
  107. data/lib/mocha/integration/mini_test/version_230_to_2101.rb +3 -1
  108. data/lib/mocha/integration/monkey_patcher.rb +5 -7
  109. data/lib/mocha/integration/test_unit.rb +7 -0
  110. data/lib/mocha/integration/test_unit/adapter.rb +5 -6
  111. data/lib/mocha/integration/test_unit/gem_version_200.rb +4 -2
  112. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +4 -2
  113. data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +4 -2
  114. data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +4 -2
  115. data/lib/mocha/integration/test_unit/nothing.rb +4 -4
  116. data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +3 -1
  117. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +3 -1
  118. data/lib/mocha/invocation.rb +61 -0
  119. data/lib/mocha/is_a.rb +0 -2
  120. data/lib/mocha/logger.rb +0 -4
  121. data/lib/mocha/macos_version.rb +5 -0
  122. data/lib/mocha/method_matcher.rb +1 -5
  123. data/lib/mocha/minitest.rb +7 -2
  124. data/lib/mocha/mock.rb +57 -47
  125. data/lib/mocha/mockery.rb +41 -90
  126. data/lib/mocha/multiple_yields.rb +0 -5
  127. data/lib/mocha/names.rb +2 -12
  128. data/lib/mocha/no_yields.rb +1 -7
  129. data/lib/mocha/not_initialized_error.rb +0 -2
  130. data/lib/mocha/object_methods.rb +25 -31
  131. data/lib/mocha/parameter_matchers.rb +1 -3
  132. data/lib/mocha/parameter_matchers/all_of.rb +2 -8
  133. data/lib/mocha/parameter_matchers/any_of.rb +2 -8
  134. data/lib/mocha/parameter_matchers/any_parameters.rb +3 -9
  135. data/lib/mocha/parameter_matchers/anything.rb +2 -8
  136. data/lib/mocha/parameter_matchers/base.rb +6 -12
  137. data/lib/mocha/parameter_matchers/equals.rb +0 -6
  138. data/lib/mocha/parameter_matchers/equivalent_uri.rb +3 -12
  139. data/lib/mocha/parameter_matchers/has_entries.rb +2 -6
  140. data/lib/mocha/parameter_matchers/has_entry.rb +8 -11
  141. data/lib/mocha/parameter_matchers/has_key.rb +2 -6
  142. data/lib/mocha/parameter_matchers/has_value.rb +2 -6
  143. data/lib/mocha/parameter_matchers/includes.rb +4 -6
  144. data/lib/mocha/parameter_matchers/instance_methods.rb +18 -0
  145. data/lib/mocha/parameter_matchers/instance_of.rb +0 -6
  146. data/lib/mocha/parameter_matchers/is_a.rb +2 -6
  147. data/lib/mocha/parameter_matchers/kind_of.rb +2 -6
  148. data/lib/mocha/parameter_matchers/not.rb +2 -6
  149. data/lib/mocha/parameter_matchers/optionally.rb +4 -10
  150. data/lib/mocha/parameter_matchers/regexp_matches.rb +0 -6
  151. data/lib/mocha/parameter_matchers/responds_with.rb +3 -8
  152. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +2 -6
  153. data/lib/mocha/parameters_matcher.rb +6 -9
  154. data/lib/mocha/pretty_parameters.rb +0 -4
  155. data/lib/mocha/raised_exception.rb +11 -0
  156. data/lib/mocha/receivers.rb +10 -14
  157. data/lib/mocha/return_values.rb +4 -8
  158. data/lib/mocha/sequence.rb +4 -9
  159. data/lib/mocha/setup.rb +5 -0
  160. data/lib/mocha/single_return_value.rb +2 -5
  161. data/lib/mocha/single_yield.rb +0 -5
  162. data/lib/mocha/singleton_class.rb +9 -0
  163. data/lib/mocha/state_machine.rb +6 -10
  164. data/lib/mocha/stubbed_method.rb +127 -0
  165. data/lib/mocha/stubbing_error.rb +0 -2
  166. data/lib/mocha/test_unit.rb +7 -2
  167. data/lib/mocha/thrower.rb +4 -6
  168. data/lib/mocha/thrown_object.rb +12 -0
  169. data/lib/mocha/version.rb +1 -1
  170. data/lib/mocha/yield_parameters.rb +3 -7
  171. data/mocha.gemspec +33 -60
  172. data/test/acceptance/acceptance_test_helper.rb +6 -4
  173. data/test/acceptance/bug_18914_test.rb +7 -13
  174. data/test/acceptance/bug_21465_test.rb +0 -3
  175. data/test/acceptance/bug_21563_test.rb +0 -3
  176. data/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +69 -0
  177. data/test/acceptance/exception_rescue_test.rb +7 -9
  178. data/test/acceptance/expectations_on_multiple_methods_test.rb +2 -2
  179. data/test/acceptance/expected_invocation_count_test.rb +27 -30
  180. data/test/acceptance/failure_messages_test.rb +3 -6
  181. data/test/acceptance/issue_272_test.rb +1 -3
  182. data/test/acceptance/issue_65_test.rb +15 -14
  183. data/test/acceptance/issue_70_test.rb +0 -2
  184. data/test/acceptance/mocha_example_test.rb +5 -7
  185. data/test/acceptance/mocha_test_result_test.rb +7 -8
  186. data/test/acceptance/mock_test.rb +48 -9
  187. data/test/acceptance/mocked_methods_dispatch_test.rb +0 -3
  188. data/test/acceptance/multiple_expectations_failure_message_test.rb +16 -18
  189. data/test/acceptance/optional_parameters_test.rb +0 -3
  190. data/test/acceptance/parameter_matcher_test.rb +2 -4
  191. data/test/acceptance/partial_mocks_test.rb +4 -7
  192. data/test/acceptance/prepend_test.rb +14 -17
  193. data/test/acceptance/prevent_use_of_mocha_outside_test_test.rb +0 -3
  194. data/test/acceptance/raise_exception_test.rb +2 -5
  195. data/test/acceptance/return_value_test.rb +0 -3
  196. data/test/acceptance/sequence_test.rb +9 -12
  197. data/test/acceptance/states_test.rb +6 -5
  198. data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +33 -3
  199. data/test/acceptance/stub_any_instance_method_test.rb +39 -18
  200. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +8 -9
  201. data/test/acceptance/stub_class_method_defined_on_class_test.rb +2 -2
  202. data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -2
  203. data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +34 -2
  204. data/test/acceptance/stub_everything_test.rb +1 -4
  205. data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +6 -8
  206. data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -2
  207. data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -2
  208. data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +63 -2
  209. data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -2
  210. data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +2 -2
  211. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -3
  212. data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -2
  213. data/test/acceptance/stub_method_defined_on_module_and_aliased_test.rb +0 -1
  214. data/test/acceptance/stub_module_method_test.rb +13 -14
  215. data/test/acceptance/stub_test.rb +1 -4
  216. data/test/acceptance/stubba_example_test.rb +6 -15
  217. data/test/acceptance/stubba_test_result_test.rb +5 -9
  218. data/test/acceptance/stubbing_error_backtrace_test.rb +6 -7
  219. data/test/acceptance/stubbing_frozen_object_test.rb +2 -2
  220. data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +12 -8
  221. data/test/acceptance/stubbing_method_unnecessarily_test.rb +5 -7
  222. data/test/acceptance/stubbing_nil_test.rb +9 -10
  223. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +12 -14
  224. data/test/acceptance/stubbing_non_existent_class_method_test.rb +14 -14
  225. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +12 -14
  226. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +8 -10
  227. data/test/acceptance/stubbing_non_public_class_method_test.rb +12 -12
  228. data/test/acceptance/stubbing_non_public_instance_method_test.rb +10 -12
  229. data/test/acceptance/stubbing_on_non_mock_object_test.rb +9 -15
  230. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +3 -5
  231. data/test/acceptance/throw_test.rb +0 -3
  232. data/test/acceptance/unexpected_invocation_test.rb +2 -4
  233. data/test/acceptance/unstubbing_test.rb +41 -15
  234. data/test/deprecation_disabler.rb +0 -1
  235. data/test/execution_point.rb +2 -4
  236. data/test/integration/mini_test_test.rb +2 -2
  237. data/test/integration/shared_tests.rb +27 -23
  238. data/test/integration/test_unit_test.rb +2 -2
  239. data/test/method_definer.rb +11 -19
  240. data/test/mini_test_result.rb +17 -11
  241. data/test/minitest_result.rb +0 -1
  242. data/test/simple_counter.rb +0 -2
  243. data/test/test_helper.rb +13 -5
  244. data/test/test_runner.rb +4 -4
  245. data/test/test_unit_result.rb +4 -2
  246. data/test/unit/any_instance_method_test.rb +74 -35
  247. data/test/unit/array_inspect_test.rb +2 -4
  248. data/test/unit/backtrace_filter_test.rb +3 -5
  249. data/test/unit/cardinality_test.rb +41 -25
  250. data/test/unit/central_test.rb +26 -28
  251. data/test/unit/change_state_side_effect_test.rb +0 -4
  252. data/test/unit/class_methods_test.rb +35 -6
  253. data/test/unit/configuration_test.rb +13 -14
  254. data/test/unit/date_time_inspect_test.rb +1 -3
  255. data/test/unit/exception_raiser_test.rb +10 -7
  256. data/test/unit/expectation_list_test.rb +13 -13
  257. data/test/unit/expectation_test.rb +110 -130
  258. data/test/unit/hash_inspect_test.rb +3 -5
  259. data/test/unit/hooks_test.rb +9 -4
  260. data/test/unit/in_state_ordering_constraint_test.rb +0 -4
  261. data/test/unit/instance_method_test.rb +282 -0
  262. data/test/unit/method_matcher_test.rb +1 -3
  263. data/test/unit/mock_test.rb +47 -25
  264. data/test/unit/mockery_test.rb +32 -33
  265. data/test/unit/module_methods_test.rb +2 -5
  266. data/test/unit/multiple_yields_test.rb +0 -2
  267. data/test/unit/no_yields_test.rb +0 -2
  268. data/test/unit/object_inspect_test.rb +26 -5
  269. data/test/unit/object_methods_test.rb +19 -8
  270. data/test/unit/parameter_matchers/all_of_test.rb +0 -2
  271. data/test/unit/parameter_matchers/any_of_test.rb +0 -2
  272. data/test/unit/parameter_matchers/anything_test.rb +2 -4
  273. data/test/unit/parameter_matchers/equals_test.rb +1 -3
  274. data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -10
  275. data/test/unit/parameter_matchers/has_entries_test.rb +3 -3
  276. data/test/unit/parameter_matchers/has_entry_test.rb +14 -15
  277. data/test/unit/parameter_matchers/has_key_test.rb +1 -2
  278. data/test/unit/parameter_matchers/has_value_test.rb +1 -3
  279. data/test/unit/parameter_matchers/includes_test.rb +9 -10
  280. data/test/unit/parameter_matchers/instance_of_test.rb +1 -3
  281. data/test/unit/parameter_matchers/is_a_test.rb +1 -3
  282. data/test/unit/parameter_matchers/kind_of_test.rb +1 -3
  283. data/test/unit/parameter_matchers/not_test.rb +0 -2
  284. data/test/unit/parameter_matchers/regexp_matches_test.rb +1 -2
  285. data/test/unit/parameter_matchers/responds_with_test.rb +10 -4
  286. data/test/unit/parameter_matchers/stub_matcher.rb +0 -4
  287. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +1 -3
  288. data/test/unit/parameters_matcher_test.rb +2 -4
  289. data/test/unit/receivers_test.rb +35 -5
  290. data/test/unit/return_values_test.rb +28 -25
  291. data/test/unit/sequence_test.rb +1 -5
  292. data/test/unit/single_return_value_test.rb +6 -3
  293. data/test/unit/single_yield_test.rb +0 -2
  294. data/test/unit/state_machine_test.rb +1 -3
  295. data/test/unit/string_inspect_test.rb +2 -4
  296. data/test/unit/thrower_test.rb +7 -4
  297. data/test/unit/yield_parameters_test.rb +0 -2
  298. data/yard-templates/default/layout/html/google_analytics.erb +6 -9
  299. data/yard-templates/default/layout/html/setup.rb +2 -3
  300. metadata +83 -51
  301. data/lib/mocha/class_method.rb +0 -119
  302. data/lib/mocha/mini_test.rb +0 -5
  303. data/lib/mocha/module_method.rb +0 -16
  304. data/lib/mocha/module_methods.rb +0 -14
  305. data/lib/mocha/parameter_matchers/object.rb +0 -17
  306. data/lib/mocha/standalone.rb +0 -4
  307. data/lib/mocha/unexpected_invocation.rb +0 -26
  308. data/lib/mocha_standalone.rb +0 -4
  309. data/test/acceptance/mock_with_initializer_block_test.rb +0 -58
  310. data/test/unit/class_method_test.rb +0 -229
@@ -0,0 +1,164 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: Mocha::Integration::TestUnit::Adapter
8
+
9
+ &mdash; Mocha 1.10.0.alpha
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "Mocha::Integration::TestUnit::Adapter";
19
+ relpath = '../../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../../_index.html">Index (A)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../../Mocha.html" title="Mocha (module)">Mocha</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Integration.html" title="Mocha::Integration (module)">Integration</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../TestUnit.html" title="Mocha::Integration::TestUnit (module)">TestUnit</a></span></span>
41
+ &raquo;
42
+ <span class="title">Adapter</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: Mocha::Integration::TestUnit::Adapter
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+ <dl>
75
+ <dt>Includes:</dt>
76
+ <dd><span class='object_link'><a href="../../API.html" title="Mocha::API (module)">API</a></span></dd>
77
+ </dl>
78
+
79
+
80
+
81
+
82
+
83
+
84
+ <dl>
85
+ <dt>Defined in:</dt>
86
+ <dd>lib/mocha/integration/test_unit/adapter.rb</dd>
87
+ </dl>
88
+
89
+ </div>
90
+
91
+ <h2>Overview</h2><div class="docstring">
92
+ <div class="discussion">
93
+
94
+ <p>Integrates Mocha into recent versions of Test::Unit.</p>
95
+
96
+ <p>See the source code for an example of how to integrate Mocha into a test library.</p>
97
+
98
+
99
+ </div>
100
+ </div>
101
+ <div class="tags">
102
+
103
+
104
+ </div>
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ <h2>Method Summary</h2>
119
+
120
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="../../API.html" title="Mocha::API (module)">API</a></span></h3>
121
+ <p class="inherited"><span class='object_link'><a href="../../API.html#mock-instance_method" title="Mocha::API#mock (method)">#mock</a></span>, <span class='object_link'><a href="../../API.html#sequence-instance_method" title="Mocha::API#sequence (method)">#sequence</a></span>, <span class='object_link'><a href="../../API.html#states-instance_method" title="Mocha::API#states (method)">#states</a></span>, <span class='object_link'><a href="../../API.html#stub-instance_method" title="Mocha::API#stub (method)">#stub</a></span>, <span class='object_link'><a href="../../API.html#stub_everything-instance_method" title="Mocha::API#stub_everything (method)">#stub_everything</a></span></p>
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="../../Hooks.html" title="Mocha::Hooks (module)">Hooks</a></span></h3>
132
+ <p class="inherited"><span class='object_link'><a href="../../Hooks.html#mocha_setup-instance_method" title="Mocha::Hooks#mocha_setup (method)">#mocha_setup</a></span>, <span class='object_link'><a href="../../Hooks.html#mocha_teardown-instance_method" title="Mocha::Hooks#mocha_teardown (method)">#mocha_teardown</a></span>, <span class='object_link'><a href="../../Hooks.html#mocha_verify-instance_method" title="Mocha::Hooks#mocha_verify (method)">#mocha_verify</a></span></p>
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="../../ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span></h3>
143
+ <p class="inherited"><span class='object_link'><a href="../../ParameterMatchers.html#Not-instance_method" title="Mocha::ParameterMatchers#Not (method)">#Not</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#all_of-instance_method" title="Mocha::ParameterMatchers#all_of (method)">#all_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#any_of-instance_method" title="Mocha::ParameterMatchers#any_of (method)">#any_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#any_parameters-instance_method" title="Mocha::ParameterMatchers#any_parameters (method)">#any_parameters</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#anything-instance_method" title="Mocha::ParameterMatchers#anything (method)">#anything</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#equals-instance_method" title="Mocha::ParameterMatchers#equals (method)">#equals</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#equivalent_uri-instance_method" title="Mocha::ParameterMatchers#equivalent_uri (method)">#equivalent_uri</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_entries-instance_method" title="Mocha::ParameterMatchers#has_entries (method)">#has_entries</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_entry-instance_method" title="Mocha::ParameterMatchers#has_entry (method)">#has_entry</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_key-instance_method" title="Mocha::ParameterMatchers#has_key (method)">#has_key</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_value-instance_method" title="Mocha::ParameterMatchers#has_value (method)">#has_value</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#includes-instance_method" title="Mocha::ParameterMatchers#includes (method)">#includes</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#instance_of-instance_method" title="Mocha::ParameterMatchers#instance_of (method)">#instance_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#is_a-instance_method" title="Mocha::ParameterMatchers#is_a (method)">#is_a</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#kind_of-instance_method" title="Mocha::ParameterMatchers#kind_of (method)">#kind_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#optionally-instance_method" title="Mocha::ParameterMatchers#optionally (method)">#optionally</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#regexp_matches-instance_method" title="Mocha::ParameterMatchers#regexp_matches (method)">#regexp_matches</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#responds_with-instance_method" title="Mocha::ParameterMatchers#responds_with (method)">#responds_with</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#yaml_equivalent-instance_method" title="Mocha::ParameterMatchers#yaml_equivalent (method)">#yaml_equivalent</a></span></p>
144
+
145
+
146
+ <script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
147
+ <script>
148
+ window.dataLayer = window.dataLayer || [];
149
+ function gtag(){dataLayer.push(arguments);}
150
+ gtag('js', new Date());
151
+
152
+ gtag('config', 'UA-625523-7');
153
+ </script>
154
+ </div>
155
+
156
+ <div id="footer">
157
+ Generated on Sun Nov 24 15:26:49 2019 by
158
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
159
+ 0.9.20 (ruby-2.6.5).
160
+ </div>
161
+
162
+ </div>
163
+ </body>
164
+ </html>
@@ -0,0 +1,1237 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: Mocha::Mock
8
+
9
+ &mdash; Mocha 1.10.0.alpha
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "Mocha::Mock";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (M)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span>
41
+ &raquo;
42
+ <span class="title">Mock</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Mocha::Mock
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName"><span class='object_link'>Object</span></span>
73
+
74
+ <ul class="fullTree">
75
+ <li><span class='object_link'>Object</span></li>
76
+
77
+ <li class="next">Mocha::Mock</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/mocha/mock.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>Traditional mock object.</p>
106
+
107
+ <p><span class='object_link'><a href="#expects-instance_method" title="Mocha::Mock#expects (method)">#expects</a></span> and <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span> return an <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span> which can be further modified by methods on <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</p>
108
+
109
+ <p><span class='object_link'><a href="#responds_like-instance_method" title="Mocha::Mock#responds_like (method)">#responds_like</a></span> and <span class='object_link'><a href="#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">#responds_like_instance_of</a></span> both return a <span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span>, and can therefore, be chained to the original creation methods in <span class='object_link'><a href="API.html" title="Mocha::API (module)">API</a></span>. They force the mock to indicate what it is supposed to be mocking, thus making it a safer verifying mock. They check that the underlying <code>responder</code> will actually respond to the methods being stubbed, throwing a <code>NoMethodError</code> upon invocation otherwise.</p>
110
+
111
+ <p>Stubs and expectations are basically the same thing. A stub is just an expectation of zero or more invocations. The <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span> method is syntactic sugar to make the intent of the test more explicit.</p>
112
+
113
+ <p>When a method is invoked on a mock object, the mock object searches through its expectations from newest to oldest to find one that matches the invocation. After the invocation, the matching expectation might stop matching further invocations. For example, an <tt>expects(:foo).once</tt> expectation only matches once and will be ignored on future invocations while an <tt>expects(:foo).at_least_once</tt> expectation will always be matched against invocations.</p>
114
+
115
+ <p>This scheme allows you to:</p>
116
+ <ul><li>
117
+ <p>Set up default stubs in your the <code>setup</code> method of your test class and override some of those stubs in individual tests.</p>
118
+ </li><li>
119
+ <p>Set up different <code>once</code> expectations for the same method with different action per invocation. However, it&#39;s better to use the <span class='object_link'><a href="Expectation.html#returns-instance_method" title="Mocha::Expectation#returns (method)">Expectation#returns</a></span> method with multiple arguments to do this, as described below.</p>
120
+ </li></ul>
121
+
122
+ <p>However, there are some possible “gotchas” caused by this scheme:</p>
123
+ <ul><li>
124
+ <p>if you create an expectation and then a stub for the same method, the stub will always override the expectation and the expectation will never be met.</p>
125
+ </li><li>
126
+ <p>if you create a stub and then an expectation for the same method, the expectation will match, and when it stops matching the stub will be used instead, possibly masking test failures.</p>
127
+ </li><li>
128
+ <p>if you create different expectations for the same method, they will be invoked in the opposite order than that in which they were specified, rather than the same order.</p>
129
+ </li></ul>
130
+
131
+ <p>The best thing to do is not set up multiple expectations and stubs for the same method with exactly the same matchers. Instead, use the <span class='object_link'><a href="Expectation.html#returns-instance_method" title="Mocha::Expectation#returns (method)">Expectation#returns</a></span> method with multiple arguments to create multiple actions for a method. You can also chain multiple calls to <span class='object_link'><a href="Expectation.html#returns-instance_method" title="Mocha::Expectation#returns (method)">Expectation#returns</a></span> and <span class='object_link'><a href="Expectation.html#raises-instance_method" title="Mocha::Expectation#raises (method)">Expectation#raises</a></span> (along with syntactic sugar <span class='object_link'><a href="Expectation.html#then-instance_method" title="Mocha::Expectation#then (method)">Expectation#then</a></span> if desired).</p>
132
+
133
+ <p>If you want to specify more complex ordering or order invocations across different mock objects, use the <span class='object_link'><a href="Expectation.html#in_sequence-instance_method" title="Mocha::Expectation#in_sequence (method)">Expectation#in_sequence</a></span> method to explicitly define a total or partial ordering of invocations.</p>
134
+
135
+
136
+ </div>
137
+ </div>
138
+ <div class="tags">
139
+
140
+ <div class="examples">
141
+ <p class="tag_title">Examples:</p>
142
+
143
+
144
+ <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
145
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:expected_method</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>2</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_then'>then</span><span class='period'>.</span><span class='id identifier rubyid_raises'>raises</span><span class='lparen'>(</span><span class='const'>Exception</span><span class='rparen'>)</span>
146
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expected_method'>expected_method</span> <span class='comment'># =&gt; 1
147
+ </span><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expected_method'>expected_method</span> <span class='comment'># =&gt; 2
148
+ </span><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expected_method'>expected_method</span> <span class='comment'># =&gt; raises exception of class Exception1</span></code></pre>
149
+
150
+ </div>
151
+
152
+
153
+ </div>
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+ <h2>
162
+ Instance Method Summary
163
+ <small><a href="#" class="summary_toggle">collapse</a></small>
164
+ </h2>
165
+
166
+ <ul class="summary">
167
+
168
+ <li class="public ">
169
+ <span class="summary_signature">
170
+
171
+ <a href="#expects-instance_method" title="#expects (instance method)">#<strong>expects</strong>(method_name_or_hash, backtrace = nil) &#x21d2; Expectation </a>
172
+
173
+
174
+
175
+ (also: #__expects__)
176
+
177
+ </span>
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+ <span class="summary_desc"><div class='inline'>
188
+ <p>Adds an expectation that the specified method must be called exactly once with any parameters.</p>
189
+ </div></span>
190
+
191
+ </li>
192
+
193
+
194
+ <li class="public ">
195
+ <span class="summary_signature">
196
+
197
+ <a href="#respond_to%3F-instance_method" title="#respond_to? (instance method)">#<strong>respond_to?</strong>(symbol, include_private = false) &#x21d2; Boolean </a>
198
+
199
+
200
+
201
+ </span>
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+ <span class="summary_desc"><div class='inline'></div></span>
212
+
213
+ </li>
214
+
215
+
216
+ <li class="public ">
217
+ <span class="summary_signature">
218
+
219
+ <a href="#responds_like-instance_method" title="#responds_like (instance method)">#<strong>responds_like</strong>(responder) &#x21d2; Mock </a>
220
+
221
+
222
+
223
+ (also: #quacks_like)
224
+
225
+ </span>
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+ <span class="summary_desc"><div class='inline'>
236
+ <p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span> instance so that it can only expect or stub methods to which <code>responder</code> responds.</p>
237
+ </div></span>
238
+
239
+ </li>
240
+
241
+
242
+ <li class="public ">
243
+ <span class="summary_signature">
244
+
245
+ <a href="#responds_like_instance_of-instance_method" title="#responds_like_instance_of (instance method)">#<strong>responds_like_instance_of</strong>(responder_class) &#x21d2; Mock </a>
246
+
247
+
248
+
249
+ (also: #quacks_like_instance_of)
250
+
251
+ </span>
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+ <span class="summary_desc"><div class='inline'>
262
+ <p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span> instance so that it can only expect or stub methods to which an instance of the <code>responder_class</code> responds.</p>
263
+ </div></span>
264
+
265
+ </li>
266
+
267
+
268
+ <li class="public ">
269
+ <span class="summary_signature">
270
+
271
+ <a href="#stubs-instance_method" title="#stubs (instance method)">#<strong>stubs</strong>(method_name_or_hash, backtrace = nil) &#x21d2; Expectation </a>
272
+
273
+
274
+
275
+ (also: #__stubs__)
276
+
277
+ </span>
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+ <span class="summary_desc"><div class='inline'>
288
+ <p>Adds an expectation that the specified method may be called any number of times with any parameters.</p>
289
+ </div></span>
290
+
291
+ </li>
292
+
293
+
294
+ <li class="public ">
295
+ <span class="summary_signature">
296
+
297
+ <a href="#unstub-instance_method" title="#unstub (instance method)">#<strong>unstub</strong>(*method_names) &#x21d2; Object </a>
298
+
299
+
300
+
301
+ </span>
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+ <span class="summary_desc"><div class='inline'>
312
+ <p>Removes the specified stubbed methods (added by calls to <span class='object_link'><a href="#expects-instance_method" title="Mocha::Mock#expects (method)">#expects</a></span> or <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span>) and all expectations associated with them.</p>
313
+ </div></span>
314
+
315
+ </li>
316
+
317
+
318
+ </ul>
319
+
320
+
321
+ <div id="method_missing_details" class="method_details_list">
322
+ <h2>Dynamic Method Handling</h2>
323
+ <p class="notice this">
324
+ This class handles dynamic methods through the <tt>method_missing</tt> method
325
+
326
+ </p>
327
+
328
+ <div class="method_details first">
329
+ <h3 class="signature first" id="method_missing-instance_method">
330
+
331
+ #<strong>method_missing</strong>(symbol, *arguments, &amp;block) &#x21d2; <tt><span class='object_link'>Object</span></tt>
332
+
333
+
334
+
335
+
336
+
337
+ </h3><div class="docstring">
338
+ <div class="discussion">
339
+
340
+ <p>rubocop:disable Style/MethodMissingSuper,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity</p>
341
+
342
+
343
+ </div>
344
+ </div>
345
+ <div class="tags">
346
+
347
+
348
+ </div><table class="source_code">
349
+ <tr>
350
+ <td>
351
+ <pre class="lines">
352
+
353
+
354
+ 309
355
+ 310
356
+ 311
357
+ 312
358
+ 313
359
+ 314
360
+ 315
361
+ 316
362
+ 317
363
+ 318
364
+ 319
365
+ 320
366
+ 321
367
+ 322
368
+ 323
369
+ 324
370
+ 325
371
+ 326</pre>
372
+ </td>
373
+ <td>
374
+ <pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 309</span>
375
+
376
+ <span class='kw'>def</span> <span class='id identifier rubyid_method_missing'>method_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
377
+ <span class='kw'>if</span> <span class='ivar'>@responder</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='ivar'>@responder</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='rparen'>)</span>
378
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>NoMethodError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>undefined method `</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_symbol'>symbol</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; for </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_mocha_inspect'>mocha_inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> which responds like </span><span class='embexpr_beg'>#{</span><span class='ivar'>@responder</span><span class='period'>.</span><span class='id identifier rubyid_mocha_inspect'>mocha_inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
379
+ <span class='kw'>end</span>
380
+ <span class='id identifier rubyid_invocation'>invocation</span> <span class='op'>=</span> <span class='const'>Invocation</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_symbol'>symbol</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span>
381
+ <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_matching_expectation_allowing_invocation'>matching_expectation_allowing_invocation</span> <span class='op'>=</span> <span class='id identifier rubyid_all_expectations'>all_expectations</span><span class='period'>.</span><span class='id identifier rubyid_match_allowing_invocation'>match_allowing_invocation</span><span class='lparen'>(</span><span class='id identifier rubyid_invocation'>invocation</span><span class='rparen'>)</span><span class='rparen'>)</span>
382
+ <span class='id identifier rubyid_matching_expectation_allowing_invocation'>matching_expectation_allowing_invocation</span><span class='period'>.</span><span class='id identifier rubyid_invoke'>invoke</span><span class='lparen'>(</span><span class='id identifier rubyid_invocation'>invocation</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
383
+ <span class='kw'>elsif</span> <span class='lparen'>(</span><span class='id identifier rubyid_matching_expectation'>matching_expectation</span> <span class='op'>=</span> <span class='id identifier rubyid_all_expectations'>all_expectations</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_invocation'>invocation</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_matching_expectation'>matching_expectation</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='ivar'>@everything_stubbed</span><span class='rparen'>)</span>
384
+ <span class='kw'>if</span> <span class='ivar'>@unexpected_invocation</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
385
+ <span class='ivar'>@unexpected_invocation</span> <span class='op'>=</span> <span class='id identifier rubyid_invocation'>invocation</span>
386
+ <span class='id identifier rubyid_matching_expectation'>matching_expectation</span><span class='period'>.</span><span class='id identifier rubyid_invoke'>invoke</span><span class='lparen'>(</span><span class='id identifier rubyid_invocation'>invocation</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_matching_expectation'>matching_expectation</span>
387
+ <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@unexpected_invocation</span><span class='period'>.</span><span class='id identifier rubyid_call_description'>call_description</span><span class='embexpr_end'>}</span><span class='tstring_content'>\n</span><span class='embexpr_beg'>#{</span><span class='ivar'>@mockery</span><span class='period'>.</span><span class='id identifier rubyid_mocha_inspect'>mocha_inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
388
+ <span class='kw'>else</span>
389
+ <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='ivar'>@unexpected_invocation</span><span class='period'>.</span><span class='id identifier rubyid_short_call_description'>short_call_description</span>
390
+ <span class='kw'>end</span>
391
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ExpectationErrorFactory.html" title="Mocha::ExpectationErrorFactory (class)">ExpectationErrorFactory</a></span></span><span class='period'>.</span><span class='id identifier rubyid_build'>build</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>unexpected invocation: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span><span class='rparen'>)</span>
392
+ <span class='kw'>end</span>
393
+ <span class='kw'>end</span></pre>
394
+ </td>
395
+ </tr>
396
+ </table>
397
+ </div>
398
+
399
+ </div>
400
+
401
+
402
+ <div id="instance_method_details" class="method_details_list">
403
+ <h2>Instance Method Details</h2>
404
+
405
+
406
+ <div class="method_details first">
407
+ <h3 class="signature first" id="expects-instance_method">
408
+
409
+
410
+ <span class="overload">#<strong>expects</strong>(method_name) &#x21d2; <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
411
+
412
+ <span class="overload">#<strong>expects</strong>(expected_methods_vs_return_values) &#x21d2; <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
413
+
414
+
415
+
416
+
417
+ <span class="aliases">Also known as:
418
+ <span class="names"><span id='__expects__-instance_method'>__expects__</span></span>
419
+ </span>
420
+
421
+
422
+
423
+ </h3><div class="docstring">
424
+ <div class="discussion">
425
+
426
+ <p>Adds an expectation that the specified method must be called exactly once with any parameters.</p>
427
+
428
+
429
+ </div>
430
+ </div>
431
+ <div class="tags">
432
+
433
+ <div class="examples">
434
+ <p class="tag_title">Examples:</p>
435
+
436
+
437
+ <p class="example_title"><div class='inline'>
438
+ <p>Expected method invoked once so no error raised</p>
439
+ </div></p>
440
+
441
+ <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
442
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:expected_method</span><span class='rparen'>)</span>
443
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expected_method'>expected_method</span></code></pre>
444
+
445
+
446
+ <p class="example_title"><div class='inline'>
447
+ <p>Expected method not invoked so error raised</p>
448
+ </div></p>
449
+
450
+ <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
451
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:expected_method</span><span class='rparen'>)</span>
452
+ <span class='comment'># error raised when test completes, because expected_method not called exactly once</span></code></pre>
453
+
454
+
455
+ <p class="example_title"><div class='inline'>
456
+ <p>Expected method invoked twice so error raised</p>
457
+ </div></p>
458
+
459
+ <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
460
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:expected_method</span><span class='rparen'>)</span>
461
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expected_method'>expected_method</span>
462
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expected_method'>expected_method</span> <span class='comment'># =&gt; error raised when expected method invoked second time</span></code></pre>
463
+
464
+
465
+ <p class="example_title"><div class='inline'>
466
+ <p>Setup multiple expectations using <code>expected_methods_vs_return_values</code>.</p>
467
+ </div></p>
468
+
469
+ <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
470
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:expected_method_one</span> <span class='op'>=&gt;</span> <span class='symbol'>:result_one</span><span class='comma'>,</span> <span class='symbol'>:expected_method_two</span> <span class='op'>=&gt;</span> <span class='symbol'>:result_two</span><span class='rparen'>)</span>
471
+
472
+ <span class='comment'># is exactly equivalent to
473
+ </span>
474
+ <span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
475
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:expected_method_one</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='symbol'>:result_one</span><span class='rparen'>)</span>
476
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:expected_method_two</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='symbol'>:result_two</span><span class='rparen'>)</span></code></pre>
477
+
478
+ </div>
479
+
480
+ <p class="tag_title">Overloads:</p>
481
+ <ul class="overload">
482
+
483
+
484
+ <li class="overload_item">
485
+ <span class="signature">#<strong>expects</strong>(method_name) &#x21d2; <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
486
+ <div class="docstring">
487
+ <div class="discussion">
488
+
489
+
490
+ </div>
491
+ </div>
492
+ <div class="tags">
493
+ <p class="tag_title">Parameters:</p>
494
+ <ul class="param">
495
+
496
+ <li>
497
+
498
+ <span class='name'>method_name</span>
499
+
500
+
501
+ <span class='type'>(<tt>Symbol</tt>, <tt>String</tt>)</span>
502
+
503
+
504
+
505
+ &mdash;
506
+ <div class='inline'>
507
+ <p>name of expected method</p>
508
+ </div>
509
+
510
+ </li>
511
+
512
+ </ul>
513
+
514
+
515
+ </div>
516
+ </li>
517
+
518
+
519
+ <li class="overload_item">
520
+ <span class="signature">#<strong>expects</strong>(expected_methods_vs_return_values) &#x21d2; <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
521
+ <div class="docstring">
522
+ <div class="discussion">
523
+
524
+
525
+ </div>
526
+ </div>
527
+ <div class="tags">
528
+ <p class="tag_title">Parameters:</p>
529
+ <ul class="param">
530
+
531
+ <li>
532
+
533
+ <span class='name'>expected_methods_vs_return_values</span>
534
+
535
+
536
+ <span class='type'>(<tt>Hash</tt>)</span>
537
+
538
+
539
+
540
+ &mdash;
541
+ <div class='inline'>
542
+ <p>expected method name symbols as keys and corresponding return values as values - these expectations are setup as if <span class='object_link'><a href="#expects-instance_method" title="Mocha::Mock#expects (method)">#expects</a></span> were called multiple times.</p>
543
+ </div>
544
+
545
+ </li>
546
+
547
+ </ul>
548
+
549
+
550
+ </div>
551
+ </li>
552
+
553
+ </ul>
554
+
555
+ <p class="tag_title">Returns:</p>
556
+ <ul class="return">
557
+
558
+ <li>
559
+
560
+
561
+ <span class='type'>(<tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt>)</span>
562
+
563
+
564
+
565
+ &mdash;
566
+ <div class='inline'>
567
+ <p>last-built expectation which can be further modified by methods on <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</p>
568
+ </div>
569
+
570
+ </li>
571
+
572
+ </ul>
573
+
574
+ </div><table class="source_code">
575
+ <tr>
576
+ <td>
577
+ <pre class="lines">
578
+
579
+
580
+ 111
581
+ 112
582
+ 113
583
+ 114
584
+ 115
585
+ 116
586
+ 117
587
+ 118
588
+ 119
589
+ 120</pre>
590
+ </td>
591
+ <td>
592
+ <pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 111</span>
593
+
594
+ <span class='kw'>def</span> <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name_or_hash'>method_name_or_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_backtrace'>backtrace</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
595
+ <span class='id identifier rubyid_iterator'>iterator</span> <span class='op'>=</span> <span class='const'>ArgumentIterator</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name_or_hash'>method_name_or_hash</span><span class='rparen'>)</span>
596
+ <span class='id identifier rubyid_iterator'>iterator</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='op'>|</span>
597
+ <span class='id identifier rubyid_method_name'>method_name</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
598
+ <span class='id identifier rubyid_ensure_method_not_already_defined'>ensure_method_not_already_defined</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name'>method_name</span><span class='rparen'>)</span>
599
+ <span class='id identifier rubyid_expectation'>expectation</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_method_name'>method_name</span><span class='comma'>,</span> <span class='id identifier rubyid_backtrace'>backtrace</span><span class='rparen'>)</span>
600
+ <span class='id identifier rubyid_expectation'>expectation</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
601
+ <span class='ivar'>@expectations</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_expectation'>expectation</span><span class='rparen'>)</span>
602
+ <span class='kw'>end</span>
603
+ <span class='kw'>end</span></pre>
604
+ </td>
605
+ </tr>
606
+ </table>
607
+ </div>
608
+
609
+ <div class="method_details ">
610
+ <h3 class="signature " id="respond_to?-instance_method">
611
+
612
+ #<strong>respond_to?</strong>(symbol, include_private = false) &#x21d2; <tt>Boolean</tt>
613
+
614
+
615
+
616
+
617
+
618
+ </h3><div class="docstring">
619
+ <div class="discussion">
620
+
621
+
622
+ </div>
623
+ </div>
624
+ <div class="tags">
625
+
626
+ <p class="tag_title">Returns:</p>
627
+ <ul class="return">
628
+
629
+ <li>
630
+
631
+
632
+ <span class='type'>(<tt>Boolean</tt>)</span>
633
+
634
+
635
+
636
+ </li>
637
+
638
+ </ul>
639
+
640
+ </div><table class="source_code">
641
+ <tr>
642
+ <td>
643
+ <pre class="lines">
644
+
645
+
646
+ 344
647
+ 345
648
+ 346</pre>
649
+ </td>
650
+ <td>
651
+ <pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 344</span>
652
+
653
+ <span class='kw'>def</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='comma'>,</span> <span class='id identifier rubyid_include_private'>include_private</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
654
+ <span class='id identifier rubyid_respond_to_missing?'>respond_to_missing?</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='comma'>,</span> <span class='id identifier rubyid_include_private'>include_private</span><span class='rparen'>)</span>
655
+ <span class='kw'>end</span></pre>
656
+ </td>
657
+ </tr>
658
+ </table>
659
+ </div>
660
+
661
+ <div class="method_details ">
662
+ <h3 class="signature " id="responds_like-instance_method">
663
+
664
+ #<strong>responds_like</strong>(responder) &#x21d2; <tt><span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span></tt>
665
+
666
+
667
+
668
+ <span class="aliases">Also known as:
669
+ <span class="names"><span id='quacks_like-instance_method'>quacks_like</span></span>
670
+ </span>
671
+
672
+
673
+
674
+ </h3><div class="docstring">
675
+ <div class="discussion">
676
+
677
+ <p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance so that it can only expect or stub methods to which <code>responder</code> responds. The constraint is only applied at method invocation time.</p>
678
+
679
+ <p>A <code>NoMethodError</code> will be raised if the <code>responder</code> does not <code>#respond_to?</code> a method invocation (even if the method has been expected or stubbed).</p>
680
+
681
+ <p>The <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance will delegate its <code>#respond_to?</code> method to the <code>responder</code>.</p>
682
+
683
+ <p>Note that the methods on <code>responder</code> are never actually invoked.</p>
684
+
685
+
686
+ </div>
687
+ </div>
688
+ <div class="tags">
689
+
690
+ <div class="examples">
691
+ <p class="tag_title">Examples:</p>
692
+
693
+
694
+ <p class="example_title"><div class='inline'>
695
+ <p>Normal mocking</p>
696
+ </div></p>
697
+
698
+ <pre class="example code"><code><span class='id identifier rubyid_sheep'>sheep</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sheep</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
699
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:chew</span><span class='rparen'>)</span>
700
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span>
701
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:chew</span><span class='rparen'>)</span> <span class='comment'># =&gt; true
702
+ </span><span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span> <span class='comment'># =&gt; true
703
+ </span><span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_chew'>chew</span>
704
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_foo'>foo</span>
705
+ <span class='comment'># no error raised</span></code></pre>
706
+
707
+
708
+ <p class="example_title"><div class='inline'>
709
+ <p>Using <span class='object_link'><a href="#responds_like-instance_method" title="Mocha::Mock#responds_like (method)">#responds_like</a></span> with an instance method</p>
710
+ </div></p>
711
+
712
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>Sheep</span>
713
+ <span class='kw'>def</span> <span class='id identifier rubyid_chew'>chew</span><span class='lparen'>(</span><span class='id identifier rubyid_grass'>grass</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>end</span>
714
+ <span class='kw'>end</span>
715
+
716
+ <span class='id identifier rubyid_sheep'>sheep</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sheep</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
717
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_responds_like'>responds_like</span><span class='lparen'>(</span><span class='const'>Sheep</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span>
718
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:chew</span><span class='rparen'>)</span>
719
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span>
720
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:chew</span><span class='rparen'>)</span> <span class='comment'># =&gt; true
721
+ </span><span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span> <span class='comment'># =&gt; false
722
+ </span><span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_chew'>chew</span>
723
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_foo'>foo</span> <span class='comment'># =&gt; raises NoMethodError exception</span></code></pre>
724
+
725
+
726
+ <p class="example_title"><div class='inline'>
727
+ <p>Using <span class='object_link'><a href="#responds_like-instance_method" title="Mocha::Mock#responds_like (method)">#responds_like</a></span> with a class method</p>
728
+ </div></p>
729
+
730
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>Sheep</span>
731
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_number_of_legs'>number_of_legs</span><span class='semicolon'>;</span> <span class='kw'>end</span>
732
+ <span class='kw'>end</span>
733
+
734
+ <span class='id identifier rubyid_sheep_class'>sheep_class</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sheep_class</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
735
+ <span class='id identifier rubyid_sheep_class'>sheep_class</span><span class='period'>.</span><span class='id identifier rubyid_responds_like'>responds_like</span><span class='lparen'>(</span><span class='const'>Sheep</span><span class='rparen'>)</span>
736
+ <span class='id identifier rubyid_sheep_class'>sheep_class</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:number_of_legs</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='int'>4</span><span class='rparen'>)</span>
737
+ <span class='id identifier rubyid_sheep_class'>sheep_class</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span>
738
+ <span class='id identifier rubyid_sheep_class'>sheep_class</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:number_of_legs</span><span class='rparen'>)</span> <span class='comment'># =&gt; true
739
+ </span><span class='id identifier rubyid_sheep_class'>sheep_class</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span> <span class='comment'># =&gt; false
740
+ </span><span class='id identifier rubyid_sheep_class'>sheep_class</span><span class='period'>.</span><span class='id identifier rubyid_number_of_legs'>number_of_legs</span> <span class='comment'># =&gt; 4
741
+ </span><span class='id identifier rubyid_sheep_class'>sheep_class</span><span class='period'>.</span><span class='id identifier rubyid_foo'>foo</span> <span class='comment'># =&gt; raises NoMethodError exception</span></code></pre>
742
+
743
+ </div>
744
+ <p class="tag_title">Parameters:</p>
745
+ <ul class="param">
746
+
747
+ <li>
748
+
749
+ <span class='name'>responder</span>
750
+
751
+
752
+ <span class='type'>(<tt><span class='object_link'>Object</span></tt>, <tt>#respond_to?</tt>)</span>
753
+
754
+
755
+
756
+ &mdash;
757
+ <div class='inline'>
758
+ <p>an object used to determine whether <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance should <code>#respond_to?</code> to an invocation.</p>
759
+ </div>
760
+
761
+ </li>
762
+
763
+ </ul>
764
+
765
+ <p class="tag_title">Returns:</p>
766
+ <ul class="return">
767
+
768
+ <li>
769
+
770
+
771
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
772
+
773
+
774
+
775
+ &mdash;
776
+ <div class='inline'>
777
+ <p>the same <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> methods to be chained.</p>
778
+ </div>
779
+
780
+ </li>
781
+
782
+ </ul>
783
+
784
+ <p class="tag_title">See Also:</p>
785
+ <ul class="see">
786
+
787
+ <li><span class='object_link'><a href="#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">#responds_like_instance_of</a></span></li>
788
+
789
+ </ul>
790
+
791
+ </div><table class="source_code">
792
+ <tr>
793
+ <td>
794
+ <pre class="lines">
795
+
796
+
797
+ 232
798
+ 233
799
+ 234
800
+ 235</pre>
801
+ </td>
802
+ <td>
803
+ <pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 232</span>
804
+
805
+ <span class='kw'>def</span> <span class='id identifier rubyid_responds_like'>responds_like</span><span class='lparen'>(</span><span class='id identifier rubyid_responder'>responder</span><span class='rparen'>)</span>
806
+ <span class='ivar'>@responder</span> <span class='op'>=</span> <span class='id identifier rubyid_responder'>responder</span>
807
+ <span class='kw'>self</span>
808
+ <span class='kw'>end</span></pre>
809
+ </td>
810
+ </tr>
811
+ </table>
812
+ </div>
813
+
814
+ <div class="method_details ">
815
+ <h3 class="signature " id="responds_like_instance_of-instance_method">
816
+
817
+ #<strong>responds_like_instance_of</strong>(responder_class) &#x21d2; <tt><span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span></tt>
818
+
819
+
820
+
821
+ <span class="aliases">Also known as:
822
+ <span class="names"><span id='quacks_like_instance_of-instance_method'>quacks_like_instance_of</span></span>
823
+ </span>
824
+
825
+
826
+
827
+ </h3><div class="docstring">
828
+ <div class="discussion">
829
+
830
+ <p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance so that it can only expect or stub methods to which an instance of the <code>responder_class</code> responds. The constraint is only applied at method invocation time. Note that the responder instance is instantiated using <tt>Class#allocate</tt>.</p>
831
+
832
+ <p>A <code>NoMethodError</code> will be raised if the responder instance does not <code>#respond_to?</code> a method invocation (even if the method has been expected or stubbed).</p>
833
+
834
+ <p>The <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance will delegate its <code>#respond_to?</code> method to the responder instance.</p>
835
+
836
+ <p>Note that the methods on the responder instance are never actually invoked.</p>
837
+
838
+
839
+ </div>
840
+ </div>
841
+ <div class="tags">
842
+
843
+ <div class="examples">
844
+ <p class="tag_title">Examples:</p>
845
+
846
+
847
+ <p class="example_title"><div class='inline'>
848
+ <p>Using <span class='object_link'><a href="#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">#responds_like_instance_of</a></span></p>
849
+ </div></p>
850
+
851
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>Sheep</span>
852
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
853
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>some awkward code we don&#39;t want to call</span><span class='tstring_end'>&quot;</span></span>
854
+ <span class='kw'>end</span>
855
+ <span class='kw'>def</span> <span class='id identifier rubyid_chew'>chew</span><span class='lparen'>(</span><span class='id identifier rubyid_grass'>grass</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>end</span>
856
+ <span class='kw'>end</span>
857
+
858
+ <span class='id identifier rubyid_sheep'>sheep</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sheep</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
859
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_responds_like_instance_of'>responds_like_instance_of</span><span class='lparen'>(</span><span class='const'>Sheep</span><span class='rparen'>)</span>
860
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:chew</span><span class='rparen'>)</span>
861
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span>
862
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:chew</span><span class='rparen'>)</span> <span class='comment'># =&gt; true
863
+ </span><span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span> <span class='comment'># =&gt; false
864
+ </span><span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_chew'>chew</span>
865
+ <span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_foo'>foo</span> <span class='comment'># =&gt; raises NoMethodError exception</span></code></pre>
866
+
867
+ </div>
868
+ <p class="tag_title">Parameters:</p>
869
+ <ul class="param">
870
+
871
+ <li>
872
+
873
+ <span class='name'>responder_class</span>
874
+
875
+
876
+ <span class='type'>(<tt>Class</tt>)</span>
877
+
878
+
879
+
880
+ &mdash;
881
+ <div class='inline'>
882
+ <p>a class used to determine whether <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance should <code>#respond_to?</code> to an invocation.</p>
883
+ </div>
884
+
885
+ </li>
886
+
887
+ </ul>
888
+
889
+ <p class="tag_title">Returns:</p>
890
+ <ul class="return">
891
+
892
+ <li>
893
+
894
+
895
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
896
+
897
+
898
+
899
+ &mdash;
900
+ <div class='inline'>
901
+ <p>the same <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> methods to be chained.</p>
902
+ </div>
903
+
904
+ </li>
905
+
906
+ </ul>
907
+
908
+ <p class="tag_title">See Also:</p>
909
+ <ul class="see">
910
+
911
+ <li><span class='object_link'><a href="#responds_like-instance_method" title="Mocha::Mock#responds_like (method)">#responds_like</a></span></li>
912
+
913
+ </ul>
914
+
915
+ </div><table class="source_code">
916
+ <tr>
917
+ <td>
918
+ <pre class="lines">
919
+
920
+
921
+ 265
922
+ 266
923
+ 267</pre>
924
+ </td>
925
+ <td>
926
+ <pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 265</span>
927
+
928
+ <span class='kw'>def</span> <span class='id identifier rubyid_responds_like_instance_of'>responds_like_instance_of</span><span class='lparen'>(</span><span class='id identifier rubyid_responder_class'>responder_class</span><span class='rparen'>)</span>
929
+ <span class='id identifier rubyid_responds_like'>responds_like</span><span class='lparen'>(</span><span class='id identifier rubyid_responder_class'>responder_class</span><span class='period'>.</span><span class='id identifier rubyid_allocate'>allocate</span><span class='rparen'>)</span>
930
+ <span class='kw'>end</span></pre>
931
+ </td>
932
+ </tr>
933
+ </table>
934
+ </div>
935
+
936
+ <div class="method_details ">
937
+ <h3 class="signature " id="stubs-instance_method">
938
+
939
+
940
+ <span class="overload">#<strong>stubs</strong>(method_name) &#x21d2; <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
941
+
942
+ <span class="overload">#<strong>stubs</strong>(stubbed_methods_vs_return_values) &#x21d2; <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
943
+
944
+
945
+
946
+
947
+ <span class="aliases">Also known as:
948
+ <span class="names"><span id='__stubs__-instance_method'>__stubs__</span></span>
949
+ </span>
950
+
951
+
952
+
953
+ </h3><div class="docstring">
954
+ <div class="discussion">
955
+
956
+ <p>Adds an expectation that the specified method may be called any number of times with any parameters.</p>
957
+
958
+
959
+ </div>
960
+ </div>
961
+ <div class="tags">
962
+
963
+ <div class="examples">
964
+ <p class="tag_title">Examples:</p>
965
+
966
+
967
+ <p class="example_title"><div class='inline'>
968
+ <p>No error raised however many times stubbed method is invoked</p>
969
+ </div></p>
970
+
971
+ <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
972
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:stubbed_method</span><span class='rparen'>)</span>
973
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_stubbed_method'>stubbed_method</span>
974
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_stubbed_method'>stubbed_method</span>
975
+ <span class='comment'># no error raised</span></code></pre>
976
+
977
+
978
+ <p class="example_title"><div class='inline'>
979
+ <p>Setup multiple expectations using <code>stubbed_methods_vs_return_values</code>.</p>
980
+ </div></p>
981
+
982
+ <pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
983
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:stubbed_method_one</span> <span class='op'>=&gt;</span> <span class='symbol'>:result_one</span><span class='comma'>,</span> <span class='symbol'>:stubbed_method_two</span> <span class='op'>=&gt;</span> <span class='symbol'>:result_two</span><span class='rparen'>)</span>
984
+
985
+ <span class='comment'># is exactly equivalent to
986
+ </span>
987
+ <span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
988
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:stubbed_method_one</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='symbol'>:result_one</span><span class='rparen'>)</span>
989
+ <span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:stubbed_method_two</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='symbol'>:result_two</span><span class='rparen'>)</span></code></pre>
990
+
991
+ </div>
992
+
993
+ <p class="tag_title">Overloads:</p>
994
+ <ul class="overload">
995
+
996
+
997
+ <li class="overload_item">
998
+ <span class="signature">#<strong>stubs</strong>(method_name) &#x21d2; <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
999
+ <div class="docstring">
1000
+ <div class="discussion">
1001
+
1002
+
1003
+ </div>
1004
+ </div>
1005
+ <div class="tags">
1006
+ <p class="tag_title">Parameters:</p>
1007
+ <ul class="param">
1008
+
1009
+ <li>
1010
+
1011
+ <span class='name'>method_name</span>
1012
+
1013
+
1014
+ <span class='type'>(<tt>Symbol</tt>, <tt>String</tt>)</span>
1015
+
1016
+
1017
+
1018
+ &mdash;
1019
+ <div class='inline'>
1020
+ <p>name of stubbed method</p>
1021
+ </div>
1022
+
1023
+ </li>
1024
+
1025
+ </ul>
1026
+
1027
+
1028
+ </div>
1029
+ </li>
1030
+
1031
+
1032
+ <li class="overload_item">
1033
+ <span class="signature">#<strong>stubs</strong>(stubbed_methods_vs_return_values) &#x21d2; <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
1034
+ <div class="docstring">
1035
+ <div class="discussion">
1036
+
1037
+
1038
+ </div>
1039
+ </div>
1040
+ <div class="tags">
1041
+ <p class="tag_title">Parameters:</p>
1042
+ <ul class="param">
1043
+
1044
+ <li>
1045
+
1046
+ <span class='name'>stubbed_methods_vs_return_values</span>
1047
+
1048
+
1049
+ <span class='type'>(<tt>Hash</tt>)</span>
1050
+
1051
+
1052
+
1053
+ &mdash;
1054
+ <div class='inline'>
1055
+ <p>stubbed method name symbols as keys and corresponding return values as values - these stubbed methods are setup as if <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span> were called multiple times.</p>
1056
+ </div>
1057
+
1058
+ </li>
1059
+
1060
+ </ul>
1061
+
1062
+
1063
+ </div>
1064
+ </li>
1065
+
1066
+ </ul>
1067
+
1068
+ <p class="tag_title">Returns:</p>
1069
+ <ul class="return">
1070
+
1071
+ <li>
1072
+
1073
+
1074
+ <span class='type'>(<tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt>)</span>
1075
+
1076
+
1077
+
1078
+ &mdash;
1079
+ <div class='inline'>
1080
+ <p>last-built expectation which can be further modified by methods on <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</p>
1081
+ </div>
1082
+
1083
+ </li>
1084
+
1085
+ </ul>
1086
+
1087
+ </div><table class="source_code">
1088
+ <tr>
1089
+ <td>
1090
+ <pre class="lines">
1091
+
1092
+
1093
+ 147
1094
+ 148
1095
+ 149
1096
+ 150
1097
+ 151
1098
+ 152
1099
+ 153
1100
+ 154
1101
+ 155
1102
+ 156
1103
+ 157</pre>
1104
+ </td>
1105
+ <td>
1106
+ <pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 147</span>
1107
+
1108
+ <span class='kw'>def</span> <span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name_or_hash'>method_name_or_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_backtrace'>backtrace</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1109
+ <span class='id identifier rubyid_iterator'>iterator</span> <span class='op'>=</span> <span class='const'>ArgumentIterator</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name_or_hash'>method_name_or_hash</span><span class='rparen'>)</span>
1110
+ <span class='id identifier rubyid_iterator'>iterator</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='op'>|</span>
1111
+ <span class='id identifier rubyid_method_name'>method_name</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
1112
+ <span class='id identifier rubyid_ensure_method_not_already_defined'>ensure_method_not_already_defined</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name'>method_name</span><span class='rparen'>)</span>
1113
+ <span class='id identifier rubyid_expectation'>expectation</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_method_name'>method_name</span><span class='comma'>,</span> <span class='id identifier rubyid_backtrace'>backtrace</span><span class='rparen'>)</span>
1114
+ <span class='id identifier rubyid_expectation'>expectation</span><span class='period'>.</span><span class='id identifier rubyid_at_least'>at_least</span><span class='lparen'>(</span><span class='int'>0</span><span class='rparen'>)</span>
1115
+ <span class='id identifier rubyid_expectation'>expectation</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
1116
+ <span class='ivar'>@expectations</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_expectation'>expectation</span><span class='rparen'>)</span>
1117
+ <span class='kw'>end</span>
1118
+ <span class='kw'>end</span></pre>
1119
+ </td>
1120
+ </tr>
1121
+ </table>
1122
+ </div>
1123
+
1124
+ <div class="method_details ">
1125
+ <h3 class="signature " id="unstub-instance_method">
1126
+
1127
+ #<strong>unstub</strong>(*method_names) &#x21d2; <tt><span class='object_link'>Object</span></tt>
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+ </h3><div class="docstring">
1134
+ <div class="discussion">
1135
+
1136
+ <p>Removes the specified stubbed methods (added by calls to <span class='object_link'><a href="#expects-instance_method" title="Mocha::Mock#expects (method)">#expects</a></span> or <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span>) and all expectations associated with them.</p>
1137
+
1138
+
1139
+ </div>
1140
+ </div>
1141
+ <div class="tags">
1142
+
1143
+ <div class="examples">
1144
+ <p class="tag_title">Examples:</p>
1145
+
1146
+
1147
+ <p class="example_title"><div class='inline'>
1148
+ <p>Invoking an unstubbed method causes error to be raised</p>
1149
+ </div></p>
1150
+
1151
+ <pre class="example code"><code>object = mock(&#39;mock&#39;) do
1152
+ object.stubs(:stubbed_method).returns(:result_one)
1153
+ object.stubbed_method # =&gt; :result_one
1154
+ object.unstub(:stubbed_method)
1155
+ object.stubbed_method # =&gt; unexpected invocation: #&lt;Mock:mock&gt;.stubbed_method()</code></pre>
1156
+
1157
+
1158
+ <p class="example_title"><div class='inline'>
1159
+ <p>Unstubbing multiple methods.</p>
1160
+ </div></p>
1161
+
1162
+ <pre class="example code"><code><span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='symbol'>:double</span><span class='comma'>,</span> <span class='symbol'>:triple</span><span class='rparen'>)</span>
1163
+
1164
+ <span class='comment'># exactly equivalent to
1165
+ </span>
1166
+ <span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='symbol'>:double</span><span class='rparen'>)</span>
1167
+ <span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='symbol'>:triple</span><span class='rparen'>)</span></code></pre>
1168
+
1169
+ </div>
1170
+ <p class="tag_title">Parameters:</p>
1171
+ <ul class="param">
1172
+
1173
+ <li>
1174
+
1175
+ <span class='name'>method_names</span>
1176
+
1177
+
1178
+ <span class='type'>(<tt>Array&lt;Symbol&gt;</tt>)</span>
1179
+
1180
+
1181
+
1182
+ &mdash;
1183
+ <div class='inline'>
1184
+ <p>names of methods to unstub.</p>
1185
+ </div>
1186
+
1187
+ </li>
1188
+
1189
+ </ul>
1190
+
1191
+
1192
+ </div><table class="source_code">
1193
+ <tr>
1194
+ <td>
1195
+ <pre class="lines">
1196
+
1197
+
1198
+ 177
1199
+ 178
1200
+ 179
1201
+ 180
1202
+ 181</pre>
1203
+ </td>
1204
+ <td>
1205
+ <pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 177</span>
1206
+
1207
+ <span class='kw'>def</span> <span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_method_names'>method_names</span><span class='rparen'>)</span>
1208
+ <span class='id identifier rubyid_method_names'>method_names</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_method_name'>method_name</span><span class='op'>|</span>
1209
+ <span class='ivar'>@expectations</span><span class='period'>.</span><span class='id identifier rubyid_remove_all_matching_method'>remove_all_matching_method</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name'>method_name</span><span class='rparen'>)</span>
1210
+ <span class='kw'>end</span>
1211
+ <span class='kw'>end</span></pre>
1212
+ </td>
1213
+ </tr>
1214
+ </table>
1215
+ </div>
1216
+
1217
+ </div>
1218
+
1219
+ <script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
1220
+ <script>
1221
+ window.dataLayer = window.dataLayer || [];
1222
+ function gtag(){dataLayer.push(arguments);}
1223
+ gtag('js', new Date());
1224
+
1225
+ gtag('config', 'UA-625523-7');
1226
+ </script>
1227
+ </div>
1228
+
1229
+ <div id="footer">
1230
+ Generated on Sun Nov 24 15:26:49 2019 by
1231
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1232
+ 0.9.20 (ruby-2.6.5).
1233
+ </div>
1234
+
1235
+ </div>
1236
+ </body>
1237
+ </html>