mocha 1.10.1 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.yardopts +1 -0
  4. data/CONTRIBUTING.md +1 -1
  5. data/README.md +28 -30
  6. data/RELEASE.md +69 -0
  7. data/Rakefile +7 -5
  8. data/lib/mocha/api.rb +78 -19
  9. data/lib/mocha/block_matcher.rb +31 -0
  10. data/lib/mocha/cardinality.rb +30 -27
  11. data/lib/mocha/configuration.rb +57 -1
  12. data/lib/mocha/deprecation.rb +2 -1
  13. data/lib/mocha/expectation.rb +72 -31
  14. data/lib/mocha/invocation.rb +20 -4
  15. data/lib/mocha/mock.rb +43 -17
  16. data/lib/mocha/mockery.rb +17 -27
  17. data/lib/mocha/parameter_matchers/has_entries.rb +2 -3
  18. data/lib/mocha/parameter_matchers/has_entry.rb +2 -3
  19. data/lib/mocha/parameter_matchers/has_key.rb +2 -3
  20. data/lib/mocha/parameter_matchers/has_value.rb +2 -3
  21. data/lib/mocha/parameter_matchers/is_a.rb +2 -3
  22. data/lib/mocha/parameter_matchers/not.rb +2 -3
  23. data/lib/mocha/state_machine.rb +31 -40
  24. data/lib/mocha/stubbed_method.rb +4 -6
  25. data/lib/mocha/version.rb +1 -1
  26. data/lib/mocha/yield_parameters.rb +5 -11
  27. data/mocha.gemspec +3 -1
  28. metadata +7 -195
  29. data/docs/CNAME +0 -1
  30. data/docs/Mocha.html +0 -254
  31. data/docs/Mocha/API.html +0 -1153
  32. data/docs/Mocha/ClassMethods.html +0 -264
  33. data/docs/Mocha/Configuration.html +0 -1383
  34. data/docs/Mocha/Expectation.html +0 -2654
  35. data/docs/Mocha/ExpectationError.html +0 -152
  36. data/docs/Mocha/ExpectationErrorFactory.html +0 -260
  37. data/docs/Mocha/Hooks.html +0 -370
  38. data/docs/Mocha/Integration.html +0 -125
  39. data/docs/Mocha/Integration/MiniTest.html +0 -123
  40. data/docs/Mocha/Integration/MiniTest/Adapter.html +0 -164
  41. data/docs/Mocha/Integration/TestUnit.html +0 -123
  42. data/docs/Mocha/Integration/TestUnit/Adapter.html +0 -164
  43. data/docs/Mocha/Mock.html +0 -1237
  44. data/docs/Mocha/ObjectMethods.html +0 -765
  45. data/docs/Mocha/ParameterMatchers.html +0 -2961
  46. data/docs/Mocha/ParameterMatchers/AllOf.html +0 -153
  47. data/docs/Mocha/ParameterMatchers/AnyOf.html +0 -153
  48. data/docs/Mocha/ParameterMatchers/AnyParameters.html +0 -153
  49. data/docs/Mocha/ParameterMatchers/Anything.html +0 -153
  50. data/docs/Mocha/ParameterMatchers/Base.html +0 -441
  51. data/docs/Mocha/ParameterMatchers/Equals.html +0 -153
  52. data/docs/Mocha/ParameterMatchers/EquivalentUri.html +0 -153
  53. data/docs/Mocha/ParameterMatchers/HasEntries.html +0 -153
  54. data/docs/Mocha/ParameterMatchers/HasEntry.html +0 -153
  55. data/docs/Mocha/ParameterMatchers/HasKey.html +0 -153
  56. data/docs/Mocha/ParameterMatchers/HasValue.html +0 -153
  57. data/docs/Mocha/ParameterMatchers/Includes.html +0 -153
  58. data/docs/Mocha/ParameterMatchers/InstanceOf.html +0 -153
  59. data/docs/Mocha/ParameterMatchers/IsA.html +0 -153
  60. data/docs/Mocha/ParameterMatchers/KindOf.html +0 -153
  61. data/docs/Mocha/ParameterMatchers/Not.html +0 -153
  62. data/docs/Mocha/ParameterMatchers/Optionally.html +0 -153
  63. data/docs/Mocha/ParameterMatchers/RegexpMatches.html +0 -153
  64. data/docs/Mocha/ParameterMatchers/RespondsWith.html +0 -153
  65. data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +0 -153
  66. data/docs/Mocha/Sequence.html +0 -149
  67. data/docs/Mocha/StateMachine.html +0 -527
  68. data/docs/Mocha/StateMachine/State.html +0 -140
  69. data/docs/Mocha/StateMachine/StatePredicate.html +0 -140
  70. data/docs/Mocha/StubbingError.html +0 -150
  71. data/docs/_index.html +0 -519
  72. data/docs/class_list.html +0 -51
  73. data/docs/css/common.css +0 -1
  74. data/docs/css/full_list.css +0 -58
  75. data/docs/css/style.css +0 -496
  76. data/docs/file.COPYING.html +0 -81
  77. data/docs/file.MIT-LICENSE.html +0 -85
  78. data/docs/file.README.html +0 -448
  79. data/docs/file.RELEASE.html +0 -963
  80. data/docs/file_list.html +0 -71
  81. data/docs/frames.html +0 -17
  82. data/docs/index.html +0 -448
  83. data/docs/js/app.js +0 -303
  84. data/docs/js/full_list.js +0 -216
  85. data/docs/js/jquery.js +0 -4
  86. data/docs/method_list.html +0 -627
  87. data/docs/top-level-namespace.html +0 -118
  88. data/lib/mocha/multiple_yields.rb +0 -15
  89. data/lib/mocha/no_yields.rb +0 -5
  90. data/lib/mocha/pretty_parameters.rb +0 -24
  91. data/lib/mocha/single_yield.rb +0 -13
  92. data/test/acceptance/acceptance_test_helper.rb +0 -41
  93. data/test/acceptance/bug_18914_test.rb +0 -37
  94. data/test/acceptance/bug_21465_test.rb +0 -31
  95. data/test/acceptance/bug_21563_test.rb +0 -22
  96. data/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +0 -69
  97. data/test/acceptance/exception_rescue_test.rb +0 -53
  98. data/test/acceptance/expectations_on_multiple_methods_test.rb +0 -55
  99. data/test/acceptance/expected_invocation_count_test.rb +0 -229
  100. data/test/acceptance/failure_messages_test.rb +0 -61
  101. data/test/acceptance/issue_272_test.rb +0 -50
  102. data/test/acceptance/issue_65_test.rb +0 -64
  103. data/test/acceptance/issue_70_test.rb +0 -53
  104. data/test/acceptance/mocha_example_test.rb +0 -96
  105. data/test/acceptance/mocha_test_result_test.rb +0 -83
  106. data/test/acceptance/mock_test.rb +0 -139
  107. data/test/acceptance/mocked_methods_dispatch_test.rb +0 -75
  108. data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -66
  109. data/test/acceptance/optional_parameters_test.rb +0 -67
  110. data/test/acceptance/parameter_matcher_test.rb +0 -299
  111. data/test/acceptance/partial_mocks_test.rb +0 -44
  112. data/test/acceptance/prepend_test.rb +0 -86
  113. data/test/acceptance/prevent_use_of_mocha_outside_test_test.rb +0 -76
  114. data/test/acceptance/raise_exception_test.rb +0 -36
  115. data/test/acceptance/return_value_test.rb +0 -49
  116. data/test/acceptance/sequence_test.rb +0 -189
  117. data/test/acceptance/states_test.rb +0 -71
  118. data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +0 -64
  119. data/test/acceptance/stub_any_instance_method_test.rb +0 -301
  120. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +0 -105
  121. data/test/acceptance/stub_class_method_defined_on_class_test.rb +0 -78
  122. data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -73
  123. data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +0 -144
  124. data/test/acceptance/stub_everything_test.rb +0 -53
  125. data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +0 -91
  126. data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -67
  127. data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -67
  128. data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +0 -136
  129. data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -76
  130. data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +0 -75
  131. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -67
  132. data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -70
  133. data/test/acceptance/stub_method_defined_on_module_and_aliased_test.rb +0 -38
  134. data/test/acceptance/stub_module_method_test.rb +0 -200
  135. data/test/acceptance/stub_test.rb +0 -49
  136. data/test/acceptance/stubba_example_test.rb +0 -93
  137. data/test/acceptance/stubba_test_result_test.rb +0 -71
  138. data/test/acceptance/stubbing_error_backtrace_test.rb +0 -63
  139. data/test/acceptance/stubbing_frozen_object_test.rb +0 -88
  140. data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +0 -52
  141. data/test/acceptance/stubbing_method_unnecessarily_test.rb +0 -63
  142. data/test/acceptance/stubbing_nil_test.rb +0 -60
  143. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +0 -157
  144. data/test/acceptance/stubbing_non_existent_class_method_test.rb +0 -157
  145. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +0 -145
  146. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +0 -128
  147. data/test/acceptance/stubbing_non_public_class_method_test.rb +0 -163
  148. data/test/acceptance/stubbing_non_public_instance_method_test.rb +0 -141
  149. data/test/acceptance/stubbing_on_non_mock_object_test.rb +0 -70
  150. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +0 -33
  151. data/test/acceptance/throw_test.rb +0 -42
  152. data/test/acceptance/unexpected_invocation_test.rb +0 -23
  153. data/test/acceptance/unstubbing_test.rb +0 -194
  154. data/test/assertions.rb +0 -8
  155. data/test/deprecation_disabler.rb +0 -15
  156. data/test/execution_point.rb +0 -36
  157. data/test/integration/mini_test_test.rb +0 -8
  158. data/test/integration/shared_tests.rb +0 -178
  159. data/test/integration/test_unit_test.rb +0 -8
  160. data/test/method_definer.rb +0 -16
  161. data/test/mini_test_result.rb +0 -96
  162. data/test/minitest_result.rb +0 -48
  163. data/test/simple_counter.rb +0 -11
  164. data/test/test_helper.rb +0 -58
  165. data/test/test_runner.rb +0 -58
  166. data/test/test_unit_result.rb +0 -22
  167. data/test/unit/any_instance_method_test.rb +0 -175
  168. data/test/unit/array_inspect_test.rb +0 -14
  169. data/test/unit/backtrace_filter_test.rb +0 -17
  170. data/test/unit/cardinality_test.rb +0 -72
  171. data/test/unit/central_test.rb +0 -98
  172. data/test/unit/change_state_side_effect_test.rb +0 -37
  173. data/test/unit/class_methods_test.rb +0 -69
  174. data/test/unit/configuration_test.rb +0 -37
  175. data/test/unit/date_time_inspect_test.rb +0 -19
  176. data/test/unit/exception_raiser_test.rb +0 -45
  177. data/test/unit/expectation_list_test.rb +0 -82
  178. data/test/unit/expectation_test.rb +0 -477
  179. data/test/unit/hash_inspect_test.rb +0 -14
  180. data/test/unit/hooks_test.rb +0 -35
  181. data/test/unit/in_state_ordering_constraint_test.rb +0 -39
  182. data/test/unit/instance_method_test.rb +0 -282
  183. data/test/unit/method_matcher_test.rb +0 -26
  184. data/test/unit/mock_test.rb +0 -372
  185. data/test/unit/mockery_test.rb +0 -171
  186. data/test/unit/module_methods_test.rb +0 -16
  187. data/test/unit/multiple_yields_test.rb +0 -16
  188. data/test/unit/no_yields_test.rb +0 -16
  189. data/test/unit/object_inspect_test.rb +0 -60
  190. data/test/unit/object_methods_test.rb +0 -63
  191. data/test/unit/parameter_matchers/all_of_test.rb +0 -24
  192. data/test/unit/parameter_matchers/any_of_test.rb +0 -24
  193. data/test/unit/parameter_matchers/anything_test.rb +0 -19
  194. data/test/unit/parameter_matchers/equals_test.rb +0 -23
  195. data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -41
  196. data/test/unit/parameter_matchers/has_entries_test.rb +0 -51
  197. data/test/unit/parameter_matchers/has_entry_test.rb +0 -128
  198. data/test/unit/parameter_matchers/has_key_test.rb +0 -54
  199. data/test/unit/parameter_matchers/has_value_test.rb +0 -55
  200. data/test/unit/parameter_matchers/includes_test.rb +0 -106
  201. data/test/unit/parameter_matchers/instance_of_test.rb +0 -23
  202. data/test/unit/parameter_matchers/is_a_test.rb +0 -23
  203. data/test/unit/parameter_matchers/kind_of_test.rb +0 -23
  204. data/test/unit/parameter_matchers/not_test.rb +0 -24
  205. data/test/unit/parameter_matchers/regexp_matches_test.rb +0 -45
  206. data/test/unit/parameter_matchers/responds_with_test.rb +0 -38
  207. data/test/unit/parameter_matchers/stub_matcher.rb +0 -23
  208. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +0 -23
  209. data/test/unit/parameters_matcher_test.rb +0 -119
  210. data/test/unit/receivers_test.rb +0 -96
  211. data/test/unit/return_values_test.rb +0 -66
  212. data/test/unit/sequence_test.rb +0 -100
  213. data/test/unit/single_return_value_test.rb +0 -17
  214. data/test/unit/single_yield_test.rb +0 -16
  215. data/test/unit/state_machine_test.rb +0 -96
  216. data/test/unit/string_inspect_test.rb +0 -9
  217. data/test/unit/thrower_test.rb +0 -23
  218. data/test/unit/yield_parameters_test.rb +0 -91
data/docs/CNAME DELETED
@@ -1 +0,0 @@
1
- mocha.jamesmead.org
@@ -1,254 +0,0 @@
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
8
-
9
- &mdash; Mocha 1.10.1
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";
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
-
41
-
42
- <span class="title">Mocha</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
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
- <dl>
80
- <dt>Defined in:</dt>
81
- <dd>lib/mocha/api.rb<span class="defines">,<br />
82
- lib/mocha/hooks.rb,<br /> lib/mocha/mock.rb,<br /> lib/mocha/expectation.rb,<br /> lib/mocha/object_methods.rb,<br /> lib/mocha/class_methods.rb,<br /> lib/mocha/parameter_matchers.rb,<br /> lib/mocha/parameter_matchers/not.rb,<br /> lib/mocha/parameter_matchers/base.rb,<br /> lib/mocha/parameter_matchers/is_a.rb,<br /> lib/mocha/parameter_matchers/all_of.rb,<br /> lib/mocha/parameter_matchers/any_of.rb,<br /> lib/mocha/parameter_matchers/equals.rb,<br /> lib/mocha/parameter_matchers/has_key.rb,<br /> lib/mocha/parameter_matchers/kind_of.rb,<br /> lib/mocha/parameter_matchers/anything.rb,<br /> lib/mocha/parameter_matchers/includes.rb,<br /> lib/mocha/parameter_matchers/has_entry.rb,<br /> lib/mocha/parameter_matchers/has_value.rb,<br /> lib/mocha/parameter_matchers/optionally.rb,<br /> lib/mocha/parameter_matchers/has_entries.rb,<br /> lib/mocha/parameter_matchers/instance_of.rb,<br /> lib/mocha/parameter_matchers/responds_with.rb,<br /> lib/mocha/parameter_matchers/any_parameters.rb,<br /> lib/mocha/parameter_matchers/equivalent_uri.rb,<br /> lib/mocha/parameter_matchers/regexp_matches.rb,<br /> lib/mocha/parameter_matchers/yaml_equivalent.rb,<br /> lib/mocha/parameter_matchers/instance_methods.rb,<br /> lib/mocha/state_machine.rb,<br /> lib/mocha/sequence.rb,<br /> lib/mocha/configuration.rb,<br /> lib/mocha/expectation_error_factory.rb,<br /> lib/mocha/expectation_error.rb,<br /> lib/mocha/stubbing_error.rb,<br /> lib/mocha/integration/test_unit/adapter.rb,<br /> lib/mocha/integration/mini_test/adapter.rb</span>
83
- </dd>
84
- </dl>
85
-
86
- </div>
87
-
88
- <h2>Defined Under Namespace</h2>
89
- <p class="children">
90
-
91
-
92
- <strong class="modules">Modules:</strong> <span class='object_link'><a href="Mocha/API.html" title="Mocha::API (module)">API</a></span>, <span class='object_link'><a href="Mocha/ClassMethods.html" title="Mocha::ClassMethods (module)">ClassMethods</a></span>, <span class='object_link'><a href="Mocha/Hooks.html" title="Mocha::Hooks (module)">Hooks</a></span>, <span class='object_link'><a href="Mocha/Integration.html" title="Mocha::Integration (module)">Integration</a></span>, <span class='object_link'><a href="Mocha/ObjectMethods.html" title="Mocha::ObjectMethods (module)">ObjectMethods</a></span>, <span class='object_link'><a href="Mocha/ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span>
93
-
94
-
95
-
96
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span>, <span class='object_link'><a href="Mocha/Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>, <span class='object_link'><a href="Mocha/ExpectationError.html" title="Mocha::ExpectationError (class)">ExpectationError</a></span>, <span class='object_link'><a href="Mocha/ExpectationErrorFactory.html" title="Mocha::ExpectationErrorFactory (class)">ExpectationErrorFactory</a></span>, <span class='object_link'><a href="Mocha/Mock.html" title="Mocha::Mock (class)">Mock</a></span>, <span class='object_link'><a href="Mocha/Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span>, <span class='object_link'><a href="Mocha/StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span>, <span class='object_link'><a href="Mocha/StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span>
97
-
98
-
99
- </p>
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
- <h2>
109
- Class Method Summary
110
- <small><a href="#" class="summary_toggle">collapse</a></small>
111
- </h2>
112
-
113
- <ul class="summary">
114
-
115
- <li class="public ">
116
- <span class="summary_signature">
117
-
118
- <a href="#configure-class_method" title="configure (class method)">.<strong>configure</strong> {|configuration| ... } &#x21d2; Object </a>
119
-
120
-
121
-
122
- </span>
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
- <span class="summary_desc"><div class='inline'>
133
- <p>Allows setting of configuration options.</p>
134
- </div></span>
135
-
136
- </li>
137
-
138
-
139
- </ul>
140
-
141
-
142
-
143
-
144
- <div id="class_method_details" class="method_details_list">
145
- <h2>Class Method Details</h2>
146
-
147
-
148
- <div class="method_details first">
149
- <h3 class="signature first" id="configure-class_method">
150
-
151
- .<strong>configure</strong> {|configuration| ... } &#x21d2; <tt><span class='object_link'>Object</span></tt>
152
-
153
-
154
-
155
-
156
-
157
- </h3><div class="docstring">
158
- <div class="discussion">
159
-
160
- <p>Allows setting of configuration options. See <span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span> for the available options.</p>
161
-
162
- <p>Typically the configuration is set globally in a <code>test_helper.rb</code> or <code>spec_helper.rb</code> file.</p>
163
-
164
-
165
- </div>
166
- </div>
167
- <div class="tags">
168
-
169
- <div class="examples">
170
- <p class="tag_title">Examples:</p>
171
-
172
-
173
- <p class="example_title"><div class='inline'>
174
- <p>Setting multiple configuration options</p>
175
- </div></p>
176
-
177
- <pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="Mocha (module)">Mocha</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'>configure</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span>
178
- <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_method_unnecessarily'>stubbing_method_unnecessarily</span> <span class='op'>=</span> <span class='symbol'>:prevent</span>
179
- <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_method_on_non_mock_object'>stubbing_method_on_non_mock_object</span> <span class='op'>=</span> <span class='symbol'>:warn</span>
180
- <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_method_on_nil'>stubbing_method_on_nil</span> <span class='op'>=</span> <span class='symbol'>:allow</span>
181
- <span class='kw'>end</span></code></pre>
182
-
183
- </div>
184
-
185
- <p class="tag_title">Yield Parameters:</p>
186
- <ul class="yieldparam">
187
-
188
- <li>
189
-
190
- <span class='name'>configuration</span>
191
-
192
-
193
- <span class='type'>(<tt><span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span></tt>)</span>
194
-
195
-
196
-
197
- &mdash;
198
- <div class='inline'>
199
- <p>the configuration for modification</p>
200
- </div>
201
-
202
- </li>
203
-
204
- </ul>
205
-
206
- <p class="tag_title">See Also:</p>
207
- <ul class="see">
208
-
209
- <li><span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span></li>
210
-
211
- </ul>
212
-
213
- </div><table class="source_code">
214
- <tr>
215
- <td>
216
- <pre class="lines">
217
-
218
-
219
- 17
220
- 18
221
- 19</pre>
222
- </td>
223
- <td>
224
- <pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 17</span>
225
-
226
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_configure'>configure</span>
227
- <span class='kw'>yield</span> <span class='id identifier rubyid_configuration'>configuration</span>
228
- <span class='kw'>end</span></pre>
229
- </td>
230
- </tr>
231
- </table>
232
- </div>
233
-
234
- </div>
235
-
236
- <script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
237
- <script>
238
- window.dataLayer = window.dataLayer || [];
239
- function gtag(){dataLayer.push(arguments);}
240
- gtag('js', new Date());
241
-
242
- gtag('config', 'UA-625523-7');
243
- </script>
244
- </div>
245
-
246
- <div id="footer">
247
- Generated on Wed Dec 4 09:20:47 2019 by
248
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
249
- 0.9.20 (ruby-2.6.5).
250
- </div>
251
-
252
- </div>
253
- </body>
254
- </html>
@@ -1,1153 +0,0 @@
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::API
8
-
9
- &mdash; Mocha 1.10.1
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::API";
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>
41
- &raquo;
42
- <span class="title">API</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::API
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="Hooks.html" title="Mocha::Hooks (module)">Hooks</a></span>, <span class='object_link'><a href="ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span></dd>
77
- </dl>
78
-
79
-
80
-
81
-
82
- <dl>
83
- <dt>Included in:</dt>
84
- <dd><span class='object_link'><a href="Integration/MiniTest/Adapter.html" title="Mocha::Integration::MiniTest::Adapter (module)">Integration::MiniTest::Adapter</a></span>, <span class='object_link'><a href="Integration/TestUnit/Adapter.html" title="Mocha::Integration::TestUnit::Adapter (module)">Integration::TestUnit::Adapter</a></span></dd>
85
- </dl>
86
-
87
-
88
-
89
- <dl>
90
- <dt>Defined in:</dt>
91
- <dd>lib/mocha/api.rb</dd>
92
- </dl>
93
-
94
- </div>
95
-
96
- <h2>Overview</h2><div class="docstring">
97
- <div class="discussion">
98
-
99
- <p>Methods added to <code>Test::Unit::TestCase</code>, <code>MiniTest::Unit::TestCase</code> or equivalent. The mock creation methods are <span class='object_link'><a href="#mock-instance_method" title="Mocha::API#mock (method)">#mock</a></span>, <span class='object_link'><a href="#stub-instance_method" title="Mocha::API#stub (method)">#stub</a></span> and <span class='object_link'><a href="#stub_everything-instance_method" title="Mocha::API#stub_everything (method)">#stub_everything</a></span>, all of which return a #<span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span> which can be further modified by <span class='object_link'><a href="Mock.html#responds_like-instance_method" title="Mocha::Mock#responds_like (method)">Mock#responds_like</a></span> and <span class='object_link'><a href="Mock.html#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">Mock#responds_like_instance_of</a></span> methods, both of which return a <span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span>, too, and can therefore, be chained to the original creation methods.</p>
100
-
101
- <p><span class='object_link'><a href="Mock.html#responds_like-instance_method" title="Mocha::Mock#responds_like (method)">Mock#responds_like</a></span> and <span class='object_link'><a href="Mock.html#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">Mock#responds_like_instance_of</a></span> 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>
102
-
103
-
104
- </div>
105
- </div>
106
- <div class="tags">
107
-
108
- <div class="examples">
109
- <p class="tag_title">Examples:</p>
110
-
111
-
112
- <p class="example_title"><div class='inline'>
113
- <p>Verifying mock using <span class='object_link'><a href="Mock.html#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">Mock#responds_like_instance_of</a></span></p>
114
- </div></p>
115
-
116
- <pre class="example code"><code><span class='kw'>class</span> <span class='const'>Sheep</span>
117
- <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
118
- <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>
119
- <span class='kw'>end</span>
120
- <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>
121
- <span class='kw'>end</span>
122
-
123
- <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><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>
124
- <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>
125
- <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>
126
- <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
127
- </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
128
- </span><span class='id identifier rubyid_sheep'>sheep</span><span class='period'>.</span><span class='id identifier rubyid_chew'>chew</span>
129
- <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>
130
-
131
- </div>
132
-
133
-
134
- </div>
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
- <h2>
143
- Instance Method Summary
144
- <small><a href="#" class="summary_toggle">collapse</a></small>
145
- </h2>
146
-
147
- <ul class="summary">
148
-
149
- <li class="public ">
150
- <span class="summary_signature">
151
-
152
- <a href="#mock-instance_method" title="#mock (instance method)">#<strong>mock</strong>(*arguments) &#x21d2; Mock </a>
153
-
154
-
155
-
156
- </span>
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
- <span class="summary_desc"><div class='inline'>
167
- <p>Builds a new mock object.</p>
168
- </div></span>
169
-
170
- </li>
171
-
172
-
173
- <li class="public ">
174
- <span class="summary_signature">
175
-
176
- <a href="#sequence-instance_method" title="#sequence (instance method)">#<strong>sequence</strong>(name) &#x21d2; Sequence </a>
177
-
178
-
179
-
180
- </span>
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
- <span class="summary_desc"><div class='inline'>
191
- <p>Builds a new sequence which can be used to constrain the order in which expectations can occur.</p>
192
- </div></span>
193
-
194
- </li>
195
-
196
-
197
- <li class="public ">
198
- <span class="summary_signature">
199
-
200
- <a href="#states-instance_method" title="#states (instance method)">#<strong>states</strong>(name) &#x21d2; StateMachine </a>
201
-
202
-
203
-
204
- </span>
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
-
213
-
214
- <span class="summary_desc"><div class='inline'>
215
- <p>Builds a new state machine which can be used to constrain the order in which expectations can occur.</p>
216
- </div></span>
217
-
218
- </li>
219
-
220
-
221
- <li class="public ">
222
- <span class="summary_signature">
223
-
224
- <a href="#stub-instance_method" title="#stub (instance method)">#<strong>stub</strong>(*arguments) &#x21d2; Mock </a>
225
-
226
-
227
-
228
- </span>
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
- <span class="summary_desc"><div class='inline'>
239
- <p>Builds a new mock object.</p>
240
- </div></span>
241
-
242
- </li>
243
-
244
-
245
- <li class="public ">
246
- <span class="summary_signature">
247
-
248
- <a href="#stub_everything-instance_method" title="#stub_everything (instance method)">#<strong>stub_everything</strong>(*arguments) &#x21d2; Mock </a>
249
-
250
-
251
-
252
- </span>
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
- <span class="summary_desc"><div class='inline'>
263
- <p>Builds a mock object that accepts calls to any method.</p>
264
- </div></span>
265
-
266
- </li>
267
-
268
-
269
- </ul>
270
-
271
-
272
-
273
-
274
-
275
-
276
-
277
-
278
-
279
-
280
-
281
- <h3 class="inherited">Methods included from <span class='object_link'><a href="Hooks.html" title="Mocha::Hooks (module)">Hooks</a></span></h3>
282
- <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>
283
-
284
-
285
-
286
-
287
-
288
-
289
-
290
-
291
-
292
- <h3 class="inherited">Methods included from <span class='object_link'><a href="ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span></h3>
293
- <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>
294
-
295
-
296
- <div id="instance_method_details" class="method_details_list">
297
- <h2>Instance Method Details</h2>
298
-
299
-
300
- <div class="method_details first">
301
- <h3 class="signature first" id="mock-instance_method">
302
-
303
-
304
- <span class="overload">#<strong>mock</strong>(name) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
305
-
306
- <span class="overload">#<strong>mock</strong>(expected_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
307
-
308
- <span class="overload">#<strong>mock</strong>(name, expected_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
309
-
310
-
311
-
312
-
313
-
314
-
315
- </h3><div class="docstring">
316
- <div class="discussion">
317
-
318
- <p>Builds a new mock object</p>
319
-
320
-
321
- </div>
322
- </div>
323
- <div class="tags">
324
-
325
- <div class="examples">
326
- <p class="tag_title">Examples:</p>
327
-
328
-
329
- <p class="example_title"><div class='inline'>
330
- <p>Using expected_methods_vs_return_values Hash to setup expectations.</p>
331
- </div></p>
332
-
333
- <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_test_motor_starts_and_stops'>test_motor_starts_and_stops</span>
334
- <span class='id identifier rubyid_motor'>motor</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'>motor</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='symbol'>:start</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='rparen'>)</span>
335
- <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span>
336
- <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
337
- <span class='comment'># an error will be raised unless both Motor#start and Motor#stop have been called
338
- </span><span class='kw'>end</span></code></pre>
339
-
340
- </div>
341
-
342
- <p class="tag_title">Overloads:</p>
343
- <ul class="overload">
344
-
345
-
346
- <li class="overload_item">
347
- <span class="signature">#<strong>mock</strong>(name) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
348
- <div class="docstring">
349
- <div class="discussion">
350
-
351
- <div class="note notetag">
352
- <strong>Note:</strong>
353
- <div class='inline'>
354
- <p>Prior to v1.10.0 when <code>name</code> was a <code>Symbol</code>, this method returned an unnamed <code>Mock</code> that stubbed the method identified by <code>name</code>. This was undocumented behaviour and it no longer exists.</p>
355
- </div>
356
- </div>
357
-
358
-
359
-
360
- </div>
361
- </div>
362
- <div class="tags">
363
- <p class="tag_title">Parameters:</p>
364
- <ul class="param">
365
-
366
- <li>
367
-
368
- <span class='name'>name</span>
369
-
370
-
371
- <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
372
-
373
-
374
-
375
- &mdash;
376
- <div class='inline'>
377
- <p>identifies mock object in error messages.</p>
378
- </div>
379
-
380
- </li>
381
-
382
- </ul>
383
-
384
-
385
- </div>
386
- </li>
387
-
388
-
389
- <li class="overload_item">
390
- <span class="signature">#<strong>mock</strong>(expected_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
391
- <div class="docstring">
392
- <div class="discussion">
393
-
394
-
395
- </div>
396
- </div>
397
- <div class="tags">
398
- <p class="tag_title">Parameters:</p>
399
- <ul class="param">
400
-
401
- <li>
402
-
403
- <span class='name'>expected_methods_vs_return_values</span>
404
-
405
-
406
- <span class='type'>(<tt>Hash</tt>)</span>
407
-
408
-
409
- <em class="default">(defaults to: <tt>{}</tt>)</em>
410
-
411
-
412
- &mdash;
413
- <div class='inline'>
414
- <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="Mock.html#expects-instance_method" title="Mocha::Mock#expects (method)">Mock#expects</a></span> were called multiple times.</p>
415
- </div>
416
-
417
- </li>
418
-
419
- </ul>
420
-
421
-
422
- </div>
423
- </li>
424
-
425
-
426
- <li class="overload_item">
427
- <span class="signature">#<strong>mock</strong>(name, expected_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
428
- <div class="docstring">
429
- <div class="discussion">
430
-
431
-
432
- </div>
433
- </div>
434
- <div class="tags">
435
- <p class="tag_title">Parameters:</p>
436
- <ul class="param">
437
-
438
- <li>
439
-
440
- <span class='name'>name</span>
441
-
442
-
443
- <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
444
-
445
-
446
-
447
- &mdash;
448
- <div class='inline'>
449
- <p>identifies mock object in error messages.</p>
450
- </div>
451
-
452
- </li>
453
-
454
- <li>
455
-
456
- <span class='name'>expected_methods_vs_return_values</span>
457
-
458
-
459
- <span class='type'>(<tt>Hash</tt>)</span>
460
-
461
-
462
- <em class="default">(defaults to: <tt>{}</tt>)</em>
463
-
464
-
465
- &mdash;
466
- <div class='inline'>
467
- <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="Mock.html#expects-instance_method" title="Mocha::Mock#expects (method)">Mock#expects</a></span> were called multiple times.</p>
468
- </div>
469
-
470
- </li>
471
-
472
- </ul>
473
-
474
-
475
- </div>
476
- </li>
477
-
478
- </ul>
479
-
480
- <p class="tag_title">Returns:</p>
481
- <ul class="return">
482
-
483
- <li>
484
-
485
-
486
- <span class='type'>(<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
487
-
488
-
489
-
490
- &mdash;
491
- <div class='inline'>
492
- <p>a new mock object</p>
493
- </div>
494
-
495
- </li>
496
-
497
- </ul>
498
-
499
- </div><table class="source_code">
500
- <tr>
501
- <td>
502
- <pre class="lines">
503
-
504
-
505
- 68
506
- 69
507
- 70</pre>
508
- </td>
509
- <td>
510
- <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 68</span>
511
-
512
- <span class='kw'>def</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span>
513
- <span class='id identifier rubyid_create_mock'>create_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_mock'>mock</span><span class='comma'>,</span> <span class='id identifier rubyid_expectations'>expectations</span><span class='op'>|</span> <span class='id identifier rubyid_mock'>mock</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
514
- <span class='kw'>end</span></pre>
515
- </td>
516
- </tr>
517
- </table>
518
- </div>
519
-
520
- <div class="method_details ">
521
- <h3 class="signature " id="sequence-instance_method">
522
-
523
- #<strong>sequence</strong>(name) &#x21d2; <tt><span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span></tt>
524
-
525
-
526
-
527
-
528
-
529
- </h3><div class="docstring">
530
- <div class="discussion">
531
-
532
- <p>Builds a new sequence which can be used to constrain the order in which expectations can occur.</p>
533
-
534
- <p>Specify that an expected invocation must occur within a named <span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span> by using <span class='object_link'><a href="Expectation.html#in_sequence-instance_method" title="Mocha::Expectation#in_sequence (method)">Expectation#in_sequence</a></span>.</p>
535
-
536
-
537
- </div>
538
- </div>
539
- <div class="tags">
540
-
541
- <div class="examples">
542
- <p class="tag_title">Examples:</p>
543
-
544
-
545
- <p class="example_title"><div class='inline'>
546
- <p>Ensure methods on egg are invoked in correct order.</p>
547
- </div></p>
548
-
549
- <pre class="example code"><code><span class='id identifier rubyid_breakfast'>breakfast</span> <span class='op'>=</span> <span class='id identifier rubyid_sequence'>sequence</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>breakfast</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
550
-
551
- <span class='id identifier rubyid_egg'>egg</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'>egg</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
552
- <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:crack</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_in_sequence'>in_sequence</span><span class='lparen'>(</span><span class='id identifier rubyid_breakfast'>breakfast</span><span class='rparen'>)</span>
553
- <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:fry</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_in_sequence'>in_sequence</span><span class='lparen'>(</span><span class='id identifier rubyid_breakfast'>breakfast</span><span class='rparen'>)</span>
554
- <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:eat</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_in_sequence'>in_sequence</span><span class='lparen'>(</span><span class='id identifier rubyid_breakfast'>breakfast</span><span class='rparen'>)</span>
555
- <span class='kw'>end</span></code></pre>
556
-
557
- </div>
558
-
559
- <p class="tag_title">Returns:</p>
560
- <ul class="return">
561
-
562
- <li>
563
-
564
-
565
- <span class='type'>(<tt><span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span></tt>)</span>
566
-
567
-
568
-
569
- &mdash;
570
- <div class='inline'>
571
- <p>a new sequence</p>
572
- </div>
573
-
574
- </li>
575
-
576
- </ul>
577
-
578
- <p class="tag_title">See Also:</p>
579
- <ul class="see">
580
-
581
- <li><span class='object_link'><a href="Expectation.html#in_sequence-instance_method" title="Mocha::Expectation#in_sequence (method)">Expectation#in_sequence</a></span></li>
582
-
583
- </ul>
584
-
585
- </div><table class="source_code">
586
- <tr>
587
- <td>
588
- <pre class="lines">
589
-
590
-
591
- 138
592
- 139
593
- 140</pre>
594
- </td>
595
- <td>
596
- <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 138</span>
597
-
598
- <span class='kw'>def</span> <span class='id identifier rubyid_sequence'>sequence</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
599
- <span class='const'><span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
600
- <span class='kw'>end</span></pre>
601
- </td>
602
- </tr>
603
- </table>
604
- </div>
605
-
606
- <div class="method_details ">
607
- <h3 class="signature " id="states-instance_method">
608
-
609
- #<strong>states</strong>(name) &#x21d2; <tt><span class='object_link'><a href="StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span></tt>
610
-
611
-
612
-
613
-
614
-
615
- </h3><div class="docstring">
616
- <div class="discussion">
617
-
618
- <p>Builds a new state machine which can be used to constrain the order in which expectations can occur.</p>
619
-
620
- <p>Specify the initial state of the state machine by using <span class='object_link'><a href="StateMachine.html#starts_as-instance_method" title="Mocha::StateMachine#starts_as (method)">StateMachine#starts_as</a></span>.</p>
621
-
622
- <p>Specify that an expected invocation should change the state of the state machine by using <span class='object_link'><a href="Expectation.html#then-instance_method" title="Mocha::Expectation#then (method)">Expectation#then</a></span>.</p>
623
-
624
- <p>Specify that an expected invocation should be constrained to occur within a particular <code>state</code> by using <span class='object_link'><a href="Expectation.html#when-instance_method" title="Mocha::Expectation#when (method)">Expectation#when</a></span>.</p>
625
-
626
- <p>A test can contain multiple state machines.</p>
627
-
628
-
629
- </div>
630
- </div>
631
- <div class="tags">
632
-
633
- <div class="examples">
634
- <p class="tag_title">Examples:</p>
635
-
636
-
637
- <p class="example_title"><div class='inline'>
638
- <p>Constrain expected invocations to occur in particular states.</p>
639
- </div></p>
640
-
641
- <pre class="example code"><code><span class='id identifier rubyid_power'>power</span> <span class='op'>=</span> <span class='id identifier rubyid_states'>states</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>power</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_starts_as'>starts_as</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>off</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
642
-
643
- <span class='id identifier rubyid_radio'>radio</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'>radio</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
644
- <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:switch_on</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_then'>then</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>on</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
645
- <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:select_channel</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>BBC Radio 4</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_when'>when</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>on</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
646
- <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:adjust_volume</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='int'>+5</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_when'>when</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>on</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
647
- <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:select_channel</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>BBC World Service</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_when'>when</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>on</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
648
- <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:adjust_volume</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='op'>-</span><span class='int'>5</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_when'>when</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>on</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
649
- <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:switch_off</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_then'>then</span><span class='lparen'>(</span><span class='id identifier rubyid_power'>power</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>off</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
650
- <span class='kw'>end</span></code></pre>
651
-
652
- </div>
653
-
654
- <p class="tag_title">Returns:</p>
655
- <ul class="return">
656
-
657
- <li>
658
-
659
-
660
- <span class='type'>(<tt><span class='object_link'><a href="StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span></tt>)</span>
661
-
662
-
663
-
664
- &mdash;
665
- <div class='inline'>
666
- <p>a new state machine</p>
667
- </div>
668
-
669
- </li>
670
-
671
- </ul>
672
-
673
- <p class="tag_title">See Also:</p>
674
- <ul class="see">
675
-
676
- <li><span class='object_link'><a href="Expectation.html#then-instance_method" title="Mocha::Expectation#then (method)">Expectation#then</a></span></li>
677
-
678
- <li><span class='object_link'><a href="Expectation.html#when-instance_method" title="Mocha::Expectation#when (method)">Expectation#when</a></span></li>
679
-
680
- <li><span class='object_link'><a href="StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span></li>
681
-
682
- </ul>
683
-
684
- </div><table class="source_code">
685
- <tr>
686
- <td>
687
- <pre class="lines">
688
-
689
-
690
- 168
691
- 169
692
- 170</pre>
693
- </td>
694
- <td>
695
- <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 168</span>
696
-
697
- <span class='kw'>def</span> <span class='id identifier rubyid_states'>states</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
698
- <span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_new_state_machine'>new_state_machine</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
699
- <span class='kw'>end</span></pre>
700
- </td>
701
- </tr>
702
- </table>
703
- </div>
704
-
705
- <div class="method_details ">
706
- <h3 class="signature " id="stub-instance_method">
707
-
708
-
709
- <span class="overload">#<strong>stub</strong>(name) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
710
-
711
- <span class="overload">#<strong>stub</strong>(stubbed_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
712
-
713
- <span class="overload">#<strong>stub</strong>(name, stubbed_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
714
-
715
-
716
-
717
-
718
-
719
-
720
- </h3><div class="docstring">
721
- <div class="discussion">
722
-
723
- <p>Builds a new mock object</p>
724
-
725
-
726
- </div>
727
- </div>
728
- <div class="tags">
729
-
730
- <div class="examples">
731
- <p class="tag_title">Examples:</p>
732
-
733
-
734
- <p class="example_title"><div class='inline'>
735
- <p>Using stubbed_methods_vs_return_values Hash to setup stubbed methods.</p>
736
- </div></p>
737
-
738
- <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_test_motor_starts_and_stops'>test_motor_starts_and_stops</span>
739
- <span class='id identifier rubyid_motor'>motor</span> <span class='op'>=</span> <span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>motor</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='symbol'>:start</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='rparen'>)</span>
740
- <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span>
741
- <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
742
- <span class='comment'># an error will not be raised even if either Motor#start or Motor#stop has not been called
743
- </span><span class='kw'>end</span></code></pre>
744
-
745
- </div>
746
-
747
- <p class="tag_title">Overloads:</p>
748
- <ul class="overload">
749
-
750
-
751
- <li class="overload_item">
752
- <span class="signature">#<strong>stub</strong>(name) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
753
- <div class="docstring">
754
- <div class="discussion">
755
-
756
- <div class="note notetag">
757
- <strong>Note:</strong>
758
- <div class='inline'>
759
- <p>Prior to v1.10.0 when <code>name</code> was a <code>Symbol</code>, this method returned an unnamed <code>Mock</code> that stubbed the method identified by <code>name</code>. This was undocumented behaviour and it no longer exists.</p>
760
- </div>
761
- </div>
762
-
763
-
764
-
765
- </div>
766
- </div>
767
- <div class="tags">
768
- <p class="tag_title">Parameters:</p>
769
- <ul class="param">
770
-
771
- <li>
772
-
773
- <span class='name'>name</span>
774
-
775
-
776
- <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
777
-
778
-
779
-
780
- &mdash;
781
- <div class='inline'>
782
- <p>identifies mock object in error messages.</p>
783
- </div>
784
-
785
- </li>
786
-
787
- </ul>
788
-
789
-
790
- </div>
791
- </li>
792
-
793
-
794
- <li class="overload_item">
795
- <span class="signature">#<strong>stub</strong>(stubbed_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
796
- <div class="docstring">
797
- <div class="discussion">
798
-
799
-
800
- </div>
801
- </div>
802
- <div class="tags">
803
- <p class="tag_title">Parameters:</p>
804
- <ul class="param">
805
-
806
- <li>
807
-
808
- <span class='name'>stubbed_methods_vs_return_values</span>
809
-
810
-
811
- <span class='type'>(<tt>Hash</tt>)</span>
812
-
813
-
814
- <em class="default">(defaults to: <tt>{}</tt>)</em>
815
-
816
-
817
- &mdash;
818
- <div class='inline'>
819
- <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="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span> were called multiple times.</p>
820
- </div>
821
-
822
- </li>
823
-
824
- </ul>
825
-
826
-
827
- </div>
828
- </li>
829
-
830
-
831
- <li class="overload_item">
832
- <span class="signature">#<strong>stub</strong>(name, stubbed_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
833
- <div class="docstring">
834
- <div class="discussion">
835
-
836
-
837
- </div>
838
- </div>
839
- <div class="tags">
840
- <p class="tag_title">Parameters:</p>
841
- <ul class="param">
842
-
843
- <li>
844
-
845
- <span class='name'>name</span>
846
-
847
-
848
- <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
849
-
850
-
851
-
852
- &mdash;
853
- <div class='inline'>
854
- <p>identifies mock object in error messages.</p>
855
- </div>
856
-
857
- </li>
858
-
859
- </ul>
860
-
861
-
862
- </div>
863
- </li>
864
-
865
- </ul>
866
-
867
- <p class="tag_title">Returns:</p>
868
- <ul class="return">
869
-
870
- <li>
871
-
872
-
873
- <span class='type'>(<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
874
-
875
-
876
-
877
- &mdash;
878
- <div class='inline'>
879
- <p>a new mock object</p>
880
- </div>
881
-
882
- </li>
883
-
884
- </ul>
885
-
886
- </div><table class="source_code">
887
- <tr>
888
- <td>
889
- <pre class="lines">
890
-
891
-
892
- 91
893
- 92
894
- 93</pre>
895
- </td>
896
- <td>
897
- <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 91</span>
898
-
899
- <span class='kw'>def</span> <span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span>
900
- <span class='id identifier rubyid_create_mock'>create_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_stub'>stub</span><span class='comma'>,</span> <span class='id identifier rubyid_expectations'>expectations</span><span class='op'>|</span> <span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
901
- <span class='kw'>end</span></pre>
902
- </td>
903
- </tr>
904
- </table>
905
- </div>
906
-
907
- <div class="method_details ">
908
- <h3 class="signature " id="stub_everything-instance_method">
909
-
910
-
911
- <span class="overload">#<strong>stub_everything</strong>(name) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
912
-
913
- <span class="overload">#<strong>stub_everything</strong>(stubbed_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
914
-
915
- <span class="overload">#<strong>stub_everything</strong>(name, stubbed_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
916
-
917
-
918
-
919
-
920
-
921
-
922
- </h3><div class="docstring">
923
- <div class="discussion">
924
-
925
- <p>Builds a mock object that accepts calls to any method. By default it will return <code>nil</code> for any method call.</p>
926
-
927
-
928
- </div>
929
- </div>
930
- <div class="tags">
931
-
932
- <div class="examples">
933
- <p class="tag_title">Examples:</p>
934
-
935
-
936
- <p class="example_title"><div class='inline'>
937
- <p>Ignore invocations of irrelevant methods.</p>
938
- </div></p>
939
-
940
- <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_test_motor_stops'>test_motor_stops</span>
941
- <span class='id identifier rubyid_motor'>motor</span> <span class='op'>=</span> <span class='id identifier rubyid_stub_everything'>stub_everything</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>motor</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='rparen'>)</span>
942
- <span class='id identifier rubyid_assert_nil'>assert_nil</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_irrelevant_method_1'>irrelevant_method_1</span> <span class='comment'># =&gt; no error raised
943
- </span> <span class='id identifier rubyid_assert_nil'>assert_nil</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_irrelevant_method_2'>irrelevant_method_2</span> <span class='comment'># =&gt; no error raised
944
- </span> <span class='id identifier rubyid_assert'>assert</span> <span class='id identifier rubyid_motor'>motor</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
945
- <span class='kw'>end</span></code></pre>
946
-
947
- </div>
948
-
949
- <p class="tag_title">Overloads:</p>
950
- <ul class="overload">
951
-
952
-
953
- <li class="overload_item">
954
- <span class="signature">#<strong>stub_everything</strong>(name) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
955
- <div class="docstring">
956
- <div class="discussion">
957
-
958
- <div class="note notetag">
959
- <strong>Note:</strong>
960
- <div class='inline'>
961
- <p>Prior to v1.10.0 when <code>name</code> was a <code>Symbol</code>, this method returned an unnamed <code>Mock</code> that stubbed everything. This was undocumented behaviour and it no longer exists.</p>
962
- </div>
963
- </div>
964
-
965
-
966
-
967
- </div>
968
- </div>
969
- <div class="tags">
970
- <p class="tag_title">Parameters:</p>
971
- <ul class="param">
972
-
973
- <li>
974
-
975
- <span class='name'>name</span>
976
-
977
-
978
- <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
979
-
980
-
981
-
982
- &mdash;
983
- <div class='inline'>
984
- <p>identifies mock object in error messages.</p>
985
- </div>
986
-
987
- </li>
988
-
989
- </ul>
990
-
991
-
992
- </div>
993
- </li>
994
-
995
-
996
- <li class="overload_item">
997
- <span class="signature">#<strong>stub_everything</strong>(stubbed_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
998
- <div class="docstring">
999
- <div class="discussion">
1000
-
1001
-
1002
- </div>
1003
- </div>
1004
- <div class="tags">
1005
- <p class="tag_title">Parameters:</p>
1006
- <ul class="param">
1007
-
1008
- <li>
1009
-
1010
- <span class='name'>stubbed_methods_vs_return_values</span>
1011
-
1012
-
1013
- <span class='type'>(<tt>Hash</tt>)</span>
1014
-
1015
-
1016
- <em class="default">(defaults to: <tt>{}</tt>)</em>
1017
-
1018
-
1019
- &mdash;
1020
- <div class='inline'>
1021
- <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="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span> were called multiple times.</p>
1022
- </div>
1023
-
1024
- </li>
1025
-
1026
- </ul>
1027
-
1028
-
1029
- </div>
1030
- </li>
1031
-
1032
-
1033
- <li class="overload_item">
1034
- <span class="signature">#<strong>stub_everything</strong>(name, stubbed_methods_vs_return_values = {}) &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt> </span>
1035
- <div class="docstring">
1036
- <div class="discussion">
1037
-
1038
-
1039
- </div>
1040
- </div>
1041
- <div class="tags">
1042
- <p class="tag_title">Parameters:</p>
1043
- <ul class="param">
1044
-
1045
- <li>
1046
-
1047
- <span class='name'>name</span>
1048
-
1049
-
1050
- <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
1051
-
1052
-
1053
-
1054
- &mdash;
1055
- <div class='inline'>
1056
- <p>identifies mock object in error messages.</p>
1057
- </div>
1058
-
1059
- </li>
1060
-
1061
- <li>
1062
-
1063
- <span class='name'>stubbed_methods_vs_return_values</span>
1064
-
1065
-
1066
- <span class='type'>(<tt>Hash</tt>)</span>
1067
-
1068
-
1069
- <em class="default">(defaults to: <tt>{}</tt>)</em>
1070
-
1071
-
1072
- &mdash;
1073
- <div class='inline'>
1074
- <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="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span> were called multiple times.</p>
1075
- </div>
1076
-
1077
- </li>
1078
-
1079
- </ul>
1080
-
1081
-
1082
- </div>
1083
- </li>
1084
-
1085
- </ul>
1086
-
1087
- <p class="tag_title">Returns:</p>
1088
- <ul class="return">
1089
-
1090
- <li>
1091
-
1092
-
1093
- <span class='type'>(<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
1094
-
1095
-
1096
-
1097
- &mdash;
1098
- <div class='inline'>
1099
- <p>a new mock object</p>
1100
- </div>
1101
-
1102
- </li>
1103
-
1104
- </ul>
1105
-
1106
- </div><table class="source_code">
1107
- <tr>
1108
- <td>
1109
- <pre class="lines">
1110
-
1111
-
1112
- 115
1113
- 116
1114
- 117
1115
- 118
1116
- 119
1117
- 120</pre>
1118
- </td>
1119
- <td>
1120
- <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 115</span>
1121
-
1122
- <span class='kw'>def</span> <span class='id identifier rubyid_stub_everything'>stub_everything</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span>
1123
- <span class='id identifier rubyid_create_mock'>create_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_stub'>stub</span><span class='comma'>,</span> <span class='id identifier rubyid_expectations'>expectations</span><span class='op'>|</span>
1124
- <span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stub_everything'>stub_everything</span>
1125
- <span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_expectations'>expectations</span><span class='rparen'>)</span>
1126
- <span class='kw'>end</span>
1127
- <span class='kw'>end</span></pre>
1128
- </td>
1129
- </tr>
1130
- </table>
1131
- </div>
1132
-
1133
- </div>
1134
-
1135
- <script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
1136
- <script>
1137
- window.dataLayer = window.dataLayer || [];
1138
- function gtag(){dataLayer.push(arguments);}
1139
- gtag('js', new Date());
1140
-
1141
- gtag('config', 'UA-625523-7');
1142
- </script>
1143
- </div>
1144
-
1145
- <div id="footer">
1146
- Generated on Wed Dec 4 09:20:47 2019 by
1147
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1148
- 0.9.20 (ruby-2.6.5).
1149
- </div>
1150
-
1151
- </div>
1152
- </body>
1153
- </html>