mocha 1.11.2 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +1 -1
  3. data/README.md +28 -30
  4. data/RELEASE.md +25 -0
  5. data/Rakefile +6 -1
  6. data/lib/mocha/cardinality.rb +30 -27
  7. data/lib/mocha/expectation.rb +24 -24
  8. data/lib/mocha/mock.rb +1 -1
  9. data/lib/mocha/mockery.rb +9 -22
  10. data/lib/mocha/state_machine.rb +30 -38
  11. data/lib/mocha/version.rb +1 -1
  12. data/mocha.gemspec +3 -1
  13. metadata +5 -192
  14. data/docs/CNAME +0 -1
  15. data/docs/Mocha.html +0 -254
  16. data/docs/Mocha/API.html +0 -1285
  17. data/docs/Mocha/ClassMethods.html +0 -264
  18. data/docs/Mocha/Configuration.html +0 -1525
  19. data/docs/Mocha/Expectation.html +0 -2862
  20. data/docs/Mocha/ExpectationError.html +0 -152
  21. data/docs/Mocha/ExpectationErrorFactory.html +0 -260
  22. data/docs/Mocha/Hooks.html +0 -370
  23. data/docs/Mocha/Integration.html +0 -125
  24. data/docs/Mocha/Integration/MiniTest.html +0 -123
  25. data/docs/Mocha/Integration/MiniTest/Adapter.html +0 -164
  26. data/docs/Mocha/Integration/TestUnit.html +0 -123
  27. data/docs/Mocha/Integration/TestUnit/Adapter.html +0 -164
  28. data/docs/Mocha/Mock.html +0 -1210
  29. data/docs/Mocha/ObjectMethods.html +0 -765
  30. data/docs/Mocha/ParameterMatchers.html +0 -2949
  31. data/docs/Mocha/ParameterMatchers/AllOf.html +0 -153
  32. data/docs/Mocha/ParameterMatchers/AnyOf.html +0 -153
  33. data/docs/Mocha/ParameterMatchers/AnyParameters.html +0 -153
  34. data/docs/Mocha/ParameterMatchers/Anything.html +0 -153
  35. data/docs/Mocha/ParameterMatchers/Base.html +0 -441
  36. data/docs/Mocha/ParameterMatchers/Equals.html +0 -153
  37. data/docs/Mocha/ParameterMatchers/EquivalentUri.html +0 -153
  38. data/docs/Mocha/ParameterMatchers/HasEntries.html +0 -153
  39. data/docs/Mocha/ParameterMatchers/HasEntry.html +0 -153
  40. data/docs/Mocha/ParameterMatchers/HasKey.html +0 -153
  41. data/docs/Mocha/ParameterMatchers/HasValue.html +0 -153
  42. data/docs/Mocha/ParameterMatchers/Includes.html +0 -153
  43. data/docs/Mocha/ParameterMatchers/InstanceOf.html +0 -153
  44. data/docs/Mocha/ParameterMatchers/IsA.html +0 -153
  45. data/docs/Mocha/ParameterMatchers/KindOf.html +0 -153
  46. data/docs/Mocha/ParameterMatchers/Not.html +0 -153
  47. data/docs/Mocha/ParameterMatchers/Optionally.html +0 -153
  48. data/docs/Mocha/ParameterMatchers/RegexpMatches.html +0 -153
  49. data/docs/Mocha/ParameterMatchers/RespondsWith.html +0 -153
  50. data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +0 -153
  51. data/docs/Mocha/Sequence.html +0 -149
  52. data/docs/Mocha/StateMachine.html +0 -527
  53. data/docs/Mocha/StateMachine/State.html +0 -140
  54. data/docs/Mocha/StateMachine/StatePredicate.html +0 -140
  55. data/docs/Mocha/StubbingError.html +0 -150
  56. data/docs/_index.html +0 -519
  57. data/docs/class_list.html +0 -51
  58. data/docs/css/common.css +0 -1
  59. data/docs/css/full_list.css +0 -58
  60. data/docs/css/style.css +0 -496
  61. data/docs/file.COPYING.html +0 -81
  62. data/docs/file.MIT-LICENSE.html +0 -85
  63. data/docs/file.README.html +0 -448
  64. data/docs/file.RELEASE.html +0 -1028
  65. data/docs/file_list.html +0 -71
  66. data/docs/frames.html +0 -17
  67. data/docs/index.html +0 -448
  68. data/docs/js/app.js +0 -303
  69. data/docs/js/full_list.js +0 -216
  70. data/docs/js/jquery.js +0 -4
  71. data/docs/method_list.html +0 -651
  72. data/docs/top-level-namespace.html +0 -118
  73. data/test/acceptance/acceptance_test_helper.rb +0 -42
  74. data/test/acceptance/bug_18914_test.rb +0 -37
  75. data/test/acceptance/bug_21465_test.rb +0 -31
  76. data/test/acceptance/bug_21563_test.rb +0 -22
  77. data/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +0 -69
  78. data/test/acceptance/exception_rescue_test.rb +0 -53
  79. data/test/acceptance/expectations_on_multiple_methods_test.rb +0 -55
  80. data/test/acceptance/expected_invocation_count_test.rb +0 -229
  81. data/test/acceptance/failure_messages_test.rb +0 -77
  82. data/test/acceptance/issue_272_test.rb +0 -50
  83. data/test/acceptance/issue_457_test.rb +0 -31
  84. data/test/acceptance/issue_65_test.rb +0 -64
  85. data/test/acceptance/issue_70_test.rb +0 -53
  86. data/test/acceptance/mocha_example_test.rb +0 -106
  87. data/test/acceptance/mocha_test_result_test.rb +0 -83
  88. data/test/acceptance/mock_built_with_first_argument_type_being_string_test.rb +0 -98
  89. data/test/acceptance/mock_test.rb +0 -191
  90. data/test/acceptance/mocked_methods_dispatch_test.rb +0 -75
  91. data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -66
  92. data/test/acceptance/multiple_yielding_test.rb +0 -59
  93. data/test/acceptance/optional_parameters_test.rb +0 -67
  94. data/test/acceptance/parameter_matcher_test.rb +0 -299
  95. data/test/acceptance/partial_mocks_test.rb +0 -44
  96. data/test/acceptance/prepend_test.rb +0 -86
  97. data/test/acceptance/prevent_use_of_mocha_outside_test_test.rb +0 -76
  98. data/test/acceptance/raise_exception_test.rb +0 -36
  99. data/test/acceptance/return_value_test.rb +0 -49
  100. data/test/acceptance/sequence_test.rb +0 -189
  101. data/test/acceptance/states_test.rb +0 -71
  102. data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +0 -64
  103. data/test/acceptance/stub_any_instance_method_test.rb +0 -301
  104. data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +0 -105
  105. data/test/acceptance/stub_class_method_defined_on_class_test.rb +0 -78
  106. data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -73
  107. data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +0 -144
  108. data/test/acceptance/stub_everything_test.rb +0 -53
  109. data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +0 -91
  110. data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -67
  111. data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -67
  112. data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +0 -136
  113. data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -76
  114. data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +0 -75
  115. data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -67
  116. data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -70
  117. data/test/acceptance/stub_method_defined_on_module_and_aliased_test.rb +0 -38
  118. data/test/acceptance/stub_module_method_test.rb +0 -200
  119. data/test/acceptance/stub_test.rb +0 -49
  120. data/test/acceptance/stubba_example_test.rb +0 -103
  121. data/test/acceptance/stubba_test_result_test.rb +0 -71
  122. data/test/acceptance/stubbing_error_backtrace_test.rb +0 -63
  123. data/test/acceptance/stubbing_frozen_object_test.rb +0 -88
  124. data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +0 -52
  125. data/test/acceptance/stubbing_method_unnecessarily_test.rb +0 -63
  126. data/test/acceptance/stubbing_nil_test.rb +0 -60
  127. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +0 -157
  128. data/test/acceptance/stubbing_non_existent_class_method_test.rb +0 -157
  129. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +0 -145
  130. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +0 -128
  131. data/test/acceptance/stubbing_non_public_class_method_test.rb +0 -163
  132. data/test/acceptance/stubbing_non_public_instance_method_test.rb +0 -141
  133. data/test/acceptance/stubbing_on_non_mock_object_test.rb +0 -70
  134. data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +0 -33
  135. data/test/acceptance/throw_test.rb +0 -42
  136. data/test/acceptance/unexpected_invocation_test.rb +0 -23
  137. data/test/acceptance/unstubbing_test.rb +0 -194
  138. data/test/acceptance/yielding_test.rb +0 -80
  139. data/test/assertions.rb +0 -8
  140. data/test/deprecation_disabler.rb +0 -15
  141. data/test/execution_point.rb +0 -36
  142. data/test/integration/mini_test_test.rb +0 -8
  143. data/test/integration/shared_tests.rb +0 -178
  144. data/test/integration/test_unit_test.rb +0 -8
  145. data/test/method_definer.rb +0 -16
  146. data/test/mini_test_result.rb +0 -96
  147. data/test/minitest_result.rb +0 -48
  148. data/test/simple_counter.rb +0 -11
  149. data/test/test_helper.rb +0 -58
  150. data/test/test_runner.rb +0 -58
  151. data/test/test_unit_result.rb +0 -22
  152. data/test/unit/any_instance_method_test.rb +0 -175
  153. data/test/unit/array_inspect_test.rb +0 -14
  154. data/test/unit/backtrace_filter_test.rb +0 -17
  155. data/test/unit/cardinality_test.rb +0 -72
  156. data/test/unit/central_test.rb +0 -98
  157. data/test/unit/change_state_side_effect_test.rb +0 -37
  158. data/test/unit/class_methods_test.rb +0 -69
  159. data/test/unit/configuration_test.rb +0 -37
  160. data/test/unit/date_time_inspect_test.rb +0 -19
  161. data/test/unit/exception_raiser_test.rb +0 -45
  162. data/test/unit/expectation_list_test.rb +0 -82
  163. data/test/unit/expectation_test.rb +0 -504
  164. data/test/unit/hash_inspect_test.rb +0 -14
  165. data/test/unit/hooks_test.rb +0 -35
  166. data/test/unit/in_state_ordering_constraint_test.rb +0 -39
  167. data/test/unit/instance_method_test.rb +0 -282
  168. data/test/unit/method_matcher_test.rb +0 -26
  169. data/test/unit/mock_test.rb +0 -372
  170. data/test/unit/mockery_test.rb +0 -171
  171. data/test/unit/module_methods_test.rb +0 -16
  172. data/test/unit/object_inspect_test.rb +0 -60
  173. data/test/unit/object_methods_test.rb +0 -63
  174. data/test/unit/parameter_matchers/all_of_test.rb +0 -24
  175. data/test/unit/parameter_matchers/any_of_test.rb +0 -24
  176. data/test/unit/parameter_matchers/anything_test.rb +0 -19
  177. data/test/unit/parameter_matchers/equals_test.rb +0 -23
  178. data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -41
  179. data/test/unit/parameter_matchers/has_entries_test.rb +0 -51
  180. data/test/unit/parameter_matchers/has_entry_test.rb +0 -128
  181. data/test/unit/parameter_matchers/has_key_test.rb +0 -54
  182. data/test/unit/parameter_matchers/has_value_test.rb +0 -55
  183. data/test/unit/parameter_matchers/includes_test.rb +0 -106
  184. data/test/unit/parameter_matchers/instance_of_test.rb +0 -23
  185. data/test/unit/parameter_matchers/is_a_test.rb +0 -23
  186. data/test/unit/parameter_matchers/kind_of_test.rb +0 -23
  187. data/test/unit/parameter_matchers/not_test.rb +0 -24
  188. data/test/unit/parameter_matchers/regexp_matches_test.rb +0 -45
  189. data/test/unit/parameter_matchers/responds_with_test.rb +0 -38
  190. data/test/unit/parameter_matchers/stub_matcher.rb +0 -23
  191. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +0 -23
  192. data/test/unit/parameters_matcher_test.rb +0 -119
  193. data/test/unit/receivers_test.rb +0 -96
  194. data/test/unit/return_values_test.rb +0 -66
  195. data/test/unit/sequence_test.rb +0 -100
  196. data/test/unit/single_return_value_test.rb +0 -17
  197. data/test/unit/state_machine_test.rb +0 -96
  198. data/test/unit/string_inspect_test.rb +0 -9
  199. data/test/unit/thrower_test.rb +0 -23
  200. data/test/unit/yield_parameters_test.rb +0 -73
@@ -1,1285 +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.11.2
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 expected the method identified by <code>name</code>. This was undocumented behaviour and it will be removed in the future, but for the moment it can be reinstated using <span class='object_link'><a href="Configuration.html#reinstate_undocumented_behaviour_from_v1_9=-instance_method" title="Mocha::Configuration#reinstate_undocumented_behaviour_from_v1_9= (method)">Configuration#reinstate_undocumented_behaviour_from_v1_9=</a></span>.</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
- 69
506
- 70
507
- 71
508
- 72
509
- 73
510
- 74
511
- 75
512
- 76
513
- 77
514
- 78
515
- 79
516
- 80
517
- 81
518
- 82
519
- 83
520
- 84
521
- 85
522
- 86
523
- 87
524
- 88
525
- 89
526
- 90
527
- 91
528
- 92
529
- 93</pre>
530
- </td>
531
- <td>
532
- <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 69</span>
533
-
534
- <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> <span class='comment'># rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
535
- </span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_reinstate_undocumented_behaviour_from_v1_9?'>reinstate_undocumented_behaviour_from_v1_9?</span>
536
- <span class='kw'>if</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Symbol</span><span class='rparen'>)</span>
537
- <span class='id identifier rubyid_method_name'>method_name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
538
- <span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span>
539
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Explicitly include `</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>` in Hash of expected methods vs return values,</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
540
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> e.g. `mock(:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> =&gt; nil)`.</span><span class='tstring_end'>&quot;</span></span>
541
- <span class='rparen'>)</span>
542
- <span class='kw'>if</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
543
- <span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span>
544
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>In this case the 2nd argument for `mock(:#</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>, ...)` is ignored,</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
545
- <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'> but in the future a Hash of expected methods vs return values will be respected.</span><span class='tstring_end'>&#39;</span></span>
546
- <span class='rparen'>)</span>
547
- <span class='kw'>end</span>
548
- <span class='kw'>elsif</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
549
- <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
550
- <span class='kw'>end</span>
551
- <span class='kw'>elsif</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Symbol</span><span class='rparen'>)</span>
552
- <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
553
- <span class='kw'>end</span>
554
- <span class='id identifier rubyid_expectations'>expectations</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
555
- <span class='id identifier rubyid_mock'>mock</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>?</span> <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_named_mock'>named_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span> <span class='op'>:</span> <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_unnamed_mock'>unnamed_mock</span>
556
- <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>
557
- <span class='id identifier rubyid_mock'>mock</span>
558
- <span class='kw'>end</span></pre>
559
- </td>
560
- </tr>
561
- </table>
562
- </div>
563
-
564
- <div class="method_details ">
565
- <h3 class="signature " id="sequence-instance_method">
566
-
567
- #<strong>sequence</strong>(name) &#x21d2; <tt><span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span></tt>
568
-
569
-
570
-
571
-
572
-
573
- </h3><div class="docstring">
574
- <div class="discussion">
575
-
576
- <p>Builds a new sequence which can be used to constrain the order in which expectations can occur.</p>
577
-
578
- <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>
579
-
580
-
581
- </div>
582
- </div>
583
- <div class="tags">
584
-
585
- <div class="examples">
586
- <p class="tag_title">Examples:</p>
587
-
588
-
589
- <p class="example_title"><div class='inline'>
590
- <p>Ensure methods on egg are invoked in correct order.</p>
591
- </div></p>
592
-
593
- <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>
594
-
595
- <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>
596
- <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>
597
- <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>
598
- <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>
599
- <span class='kw'>end</span></code></pre>
600
-
601
- </div>
602
-
603
- <p class="tag_title">Returns:</p>
604
- <ul class="return">
605
-
606
- <li>
607
-
608
-
609
- <span class='type'>(<tt><span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span></tt>)</span>
610
-
611
-
612
-
613
- &mdash;
614
- <div class='inline'>
615
- <p>a new sequence</p>
616
- </div>
617
-
618
- </li>
619
-
620
- </ul>
621
-
622
- <p class="tag_title">See Also:</p>
623
- <ul class="see">
624
-
625
- <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>
626
-
627
- </ul>
628
-
629
- </div><table class="source_code">
630
- <tr>
631
- <td>
632
- <pre class="lines">
633
-
634
-
635
- 207
636
- 208
637
- 209</pre>
638
- </td>
639
- <td>
640
- <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 207</span>
641
-
642
- <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>
643
- <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>
644
- <span class='kw'>end</span></pre>
645
- </td>
646
- </tr>
647
- </table>
648
- </div>
649
-
650
- <div class="method_details ">
651
- <h3 class="signature " id="states-instance_method">
652
-
653
- #<strong>states</strong>(name) &#x21d2; <tt><span class='object_link'><a href="StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span></tt>
654
-
655
-
656
-
657
-
658
-
659
- </h3><div class="docstring">
660
- <div class="discussion">
661
-
662
- <p>Builds a new state machine which can be used to constrain the order in which expectations can occur.</p>
663
-
664
- <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>
665
-
666
- <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>
667
-
668
- <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>
669
-
670
- <p>A test can contain multiple state machines.</p>
671
-
672
-
673
- </div>
674
- </div>
675
- <div class="tags">
676
-
677
- <div class="examples">
678
- <p class="tag_title">Examples:</p>
679
-
680
-
681
- <p class="example_title"><div class='inline'>
682
- <p>Constrain expected invocations to occur in particular states.</p>
683
- </div></p>
684
-
685
- <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>
686
-
687
- <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>
688
- <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>
689
- <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>
690
- <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>
691
- <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>
692
- <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>
693
- <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>
694
- <span class='kw'>end</span></code></pre>
695
-
696
- </div>
697
-
698
- <p class="tag_title">Returns:</p>
699
- <ul class="return">
700
-
701
- <li>
702
-
703
-
704
- <span class='type'>(<tt><span class='object_link'><a href="StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span></tt>)</span>
705
-
706
-
707
-
708
- &mdash;
709
- <div class='inline'>
710
- <p>a new state machine</p>
711
- </div>
712
-
713
- </li>
714
-
715
- </ul>
716
-
717
- <p class="tag_title">See Also:</p>
718
- <ul class="see">
719
-
720
- <li><span class='object_link'><a href="Expectation.html#then-instance_method" title="Mocha::Expectation#then (method)">Expectation#then</a></span></li>
721
-
722
- <li><span class='object_link'><a href="Expectation.html#when-instance_method" title="Mocha::Expectation#when (method)">Expectation#when</a></span></li>
723
-
724
- <li><span class='object_link'><a href="StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span></li>
725
-
726
- </ul>
727
-
728
- </div><table class="source_code">
729
- <tr>
730
- <td>
731
- <pre class="lines">
732
-
733
-
734
- 237
735
- 238
736
- 239</pre>
737
- </td>
738
- <td>
739
- <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 237</span>
740
-
741
- <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>
742
- <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>
743
- <span class='kw'>end</span></pre>
744
- </td>
745
- </tr>
746
- </table>
747
- </div>
748
-
749
- <div class="method_details ">
750
- <h3 class="signature " id="stub-instance_method">
751
-
752
-
753
- <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>
754
-
755
- <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>
756
-
757
- <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>
758
-
759
-
760
-
761
-
762
-
763
-
764
- </h3><div class="docstring">
765
- <div class="discussion">
766
-
767
- <p>Builds a new mock object</p>
768
-
769
- <p>rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity</p>
770
-
771
-
772
- </div>
773
- </div>
774
- <div class="tags">
775
-
776
- <div class="examples">
777
- <p class="tag_title">Examples:</p>
778
-
779
-
780
- <p class="example_title"><div class='inline'>
781
- <p>Using stubbed_methods_vs_return_values Hash to setup stubbed methods.</p>
782
- </div></p>
783
-
784
- <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>
785
- <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>
786
- <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>
787
- <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>
788
- <span class='comment'># an error will not be raised even if either Motor#start or Motor#stop has not been called
789
- </span><span class='kw'>end</span></code></pre>
790
-
791
- </div>
792
-
793
- <p class="tag_title">Overloads:</p>
794
- <ul class="overload">
795
-
796
-
797
- <li class="overload_item">
798
- <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>
799
- <div class="docstring">
800
- <div class="discussion">
801
-
802
- <div class="note notetag">
803
- <strong>Note:</strong>
804
- <div class='inline'>
805
- <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 will be removed in the future, but for the moment it can be reinstated using <span class='object_link'><a href="Configuration.html#reinstate_undocumented_behaviour_from_v1_9=-instance_method" title="Mocha::Configuration#reinstate_undocumented_behaviour_from_v1_9= (method)">Configuration#reinstate_undocumented_behaviour_from_v1_9=</a></span>.</p>
806
- </div>
807
- </div>
808
-
809
-
810
-
811
- </div>
812
- </div>
813
- <div class="tags">
814
- <p class="tag_title">Parameters:</p>
815
- <ul class="param">
816
-
817
- <li>
818
-
819
- <span class='name'>name</span>
820
-
821
-
822
- <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
823
-
824
-
825
-
826
- &mdash;
827
- <div class='inline'>
828
- <p>identifies mock object in error messages.</p>
829
- </div>
830
-
831
- </li>
832
-
833
- </ul>
834
-
835
-
836
- </div>
837
- </li>
838
-
839
-
840
- <li class="overload_item">
841
- <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>
842
- <div class="docstring">
843
- <div class="discussion">
844
-
845
-
846
- </div>
847
- </div>
848
- <div class="tags">
849
- <p class="tag_title">Parameters:</p>
850
- <ul class="param">
851
-
852
- <li>
853
-
854
- <span class='name'>stubbed_methods_vs_return_values</span>
855
-
856
-
857
- <span class='type'>(<tt>Hash</tt>)</span>
858
-
859
-
860
- <em class="default">(defaults to: <tt>{}</tt>)</em>
861
-
862
-
863
- &mdash;
864
- <div class='inline'>
865
- <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>
866
- </div>
867
-
868
- </li>
869
-
870
- </ul>
871
-
872
-
873
- </div>
874
- </li>
875
-
876
-
877
- <li class="overload_item">
878
- <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>
879
- <div class="docstring">
880
- <div class="discussion">
881
-
882
-
883
- </div>
884
- </div>
885
- <div class="tags">
886
- <p class="tag_title">Parameters:</p>
887
- <ul class="param">
888
-
889
- <li>
890
-
891
- <span class='name'>name</span>
892
-
893
-
894
- <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
895
-
896
-
897
-
898
- &mdash;
899
- <div class='inline'>
900
- <p>identifies mock object in error messages.</p>
901
- </div>
902
-
903
- </li>
904
-
905
- </ul>
906
-
907
-
908
- </div>
909
- </li>
910
-
911
- </ul>
912
-
913
- <p class="tag_title">Returns:</p>
914
- <ul class="return">
915
-
916
- <li>
917
-
918
-
919
- <span class='type'>(<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
920
-
921
-
922
-
923
- &mdash;
924
- <div class='inline'>
925
- <p>a new mock object</p>
926
- </div>
927
-
928
- </li>
929
-
930
- </ul>
931
-
932
- </div><table class="source_code">
933
- <tr>
934
- <td>
935
- <pre class="lines">
936
-
937
-
938
- 115
939
- 116
940
- 117
941
- 118
942
- 119
943
- 120
944
- 121
945
- 122
946
- 123
947
- 124
948
- 125
949
- 126
950
- 127
951
- 128
952
- 129
953
- 130
954
- 131
955
- 132
956
- 133
957
- 134
958
- 135
959
- 136
960
- 137
961
- 138
962
- 139</pre>
963
- </td>
964
- <td>
965
- <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 115</span>
966
-
967
- <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>
968
- <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_reinstate_undocumented_behaviour_from_v1_9?'>reinstate_undocumented_behaviour_from_v1_9?</span>
969
- <span class='kw'>if</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Symbol</span><span class='rparen'>)</span>
970
- <span class='id identifier rubyid_method_name'>method_name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
971
- <span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span>
972
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Explicitly include `</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>` in Hash of stubbed methods vs return values,</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
973
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> e.g. `stub(:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> =&gt; nil)`.</span><span class='tstring_end'>&quot;</span></span>
974
- <span class='rparen'>)</span>
975
- <span class='kw'>if</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
976
- <span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span>
977
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>In this case the 2nd argument for `stub(:#</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>, ...)` is ignored,</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
978
- <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'> but in the future a Hash of stubbed methods vs return values will be respected.</span><span class='tstring_end'>&#39;</span></span>
979
- <span class='rparen'>)</span>
980
- <span class='kw'>end</span>
981
- <span class='kw'>elsif</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
982
- <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
983
- <span class='kw'>end</span>
984
- <span class='kw'>elsif</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Symbol</span><span class='rparen'>)</span>
985
- <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
986
- <span class='kw'>end</span>
987
- <span class='id identifier rubyid_expectations'>expectations</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
988
- <span class='id identifier rubyid_stub'>stub</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>?</span> <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_named_mock'>named_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span> <span class='op'>:</span> <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_unnamed_mock'>unnamed_mock</span>
989
- <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>
990
- <span class='id identifier rubyid_stub'>stub</span>
991
- <span class='kw'>end</span></pre>
992
- </td>
993
- </tr>
994
- </table>
995
- </div>
996
-
997
- <div class="method_details ">
998
- <h3 class="signature " id="stub_everything-instance_method">
999
-
1000
-
1001
- <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>
1002
-
1003
- <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>
1004
-
1005
- <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>
1006
-
1007
-
1008
-
1009
-
1010
-
1011
-
1012
- </h3><div class="docstring">
1013
- <div class="discussion">
1014
-
1015
- <p>Builds a mock object that accepts calls to any method. By default it will return <code>nil</code> for any method call.</p>
1016
-
1017
- <p>rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity</p>
1018
-
1019
-
1020
- </div>
1021
- </div>
1022
- <div class="tags">
1023
-
1024
- <div class="examples">
1025
- <p class="tag_title">Examples:</p>
1026
-
1027
-
1028
- <p class="example_title"><div class='inline'>
1029
- <p>Ignore invocations of irrelevant methods.</p>
1030
- </div></p>
1031
-
1032
- <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_test_motor_stops'>test_motor_stops</span>
1033
- <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>
1034
- <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
1035
- </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
1036
- </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>
1037
- <span class='kw'>end</span></code></pre>
1038
-
1039
- </div>
1040
-
1041
- <p class="tag_title">Overloads:</p>
1042
- <ul class="overload">
1043
-
1044
-
1045
- <li class="overload_item">
1046
- <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>
1047
- <div class="docstring">
1048
- <div class="discussion">
1049
-
1050
- <div class="note notetag">
1051
- <strong>Note:</strong>
1052
- <div class='inline'>
1053
- <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 will be removed in the future, but for the moment it can be reinstated using <span class='object_link'><a href="Configuration.html#reinstate_undocumented_behaviour_from_v1_9=-instance_method" title="Mocha::Configuration#reinstate_undocumented_behaviour_from_v1_9= (method)">Configuration#reinstate_undocumented_behaviour_from_v1_9=</a></span>.</p>
1054
- </div>
1055
- </div>
1056
-
1057
-
1058
-
1059
- </div>
1060
- </div>
1061
- <div class="tags">
1062
- <p class="tag_title">Parameters:</p>
1063
- <ul class="param">
1064
-
1065
- <li>
1066
-
1067
- <span class='name'>name</span>
1068
-
1069
-
1070
- <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
1071
-
1072
-
1073
-
1074
- &mdash;
1075
- <div class='inline'>
1076
- <p>identifies mock object in error messages.</p>
1077
- </div>
1078
-
1079
- </li>
1080
-
1081
- </ul>
1082
-
1083
-
1084
- </div>
1085
- </li>
1086
-
1087
-
1088
- <li class="overload_item">
1089
- <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>
1090
- <div class="docstring">
1091
- <div class="discussion">
1092
-
1093
-
1094
- </div>
1095
- </div>
1096
- <div class="tags">
1097
- <p class="tag_title">Parameters:</p>
1098
- <ul class="param">
1099
-
1100
- <li>
1101
-
1102
- <span class='name'>stubbed_methods_vs_return_values</span>
1103
-
1104
-
1105
- <span class='type'>(<tt>Hash</tt>)</span>
1106
-
1107
-
1108
- <em class="default">(defaults to: <tt>{}</tt>)</em>
1109
-
1110
-
1111
- &mdash;
1112
- <div class='inline'>
1113
- <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>
1114
- </div>
1115
-
1116
- </li>
1117
-
1118
- </ul>
1119
-
1120
-
1121
- </div>
1122
- </li>
1123
-
1124
-
1125
- <li class="overload_item">
1126
- <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>
1127
- <div class="docstring">
1128
- <div class="discussion">
1129
-
1130
-
1131
- </div>
1132
- </div>
1133
- <div class="tags">
1134
- <p class="tag_title">Parameters:</p>
1135
- <ul class="param">
1136
-
1137
- <li>
1138
-
1139
- <span class='name'>name</span>
1140
-
1141
-
1142
- <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
1143
-
1144
-
1145
-
1146
- &mdash;
1147
- <div class='inline'>
1148
- <p>identifies mock object in error messages.</p>
1149
- </div>
1150
-
1151
- </li>
1152
-
1153
- <li>
1154
-
1155
- <span class='name'>stubbed_methods_vs_return_values</span>
1156
-
1157
-
1158
- <span class='type'>(<tt>Hash</tt>)</span>
1159
-
1160
-
1161
- <em class="default">(defaults to: <tt>{}</tt>)</em>
1162
-
1163
-
1164
- &mdash;
1165
- <div class='inline'>
1166
- <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>
1167
- </div>
1168
-
1169
- </li>
1170
-
1171
- </ul>
1172
-
1173
-
1174
- </div>
1175
- </li>
1176
-
1177
- </ul>
1178
-
1179
- <p class="tag_title">Returns:</p>
1180
- <ul class="return">
1181
-
1182
- <li>
1183
-
1184
-
1185
- <span class='type'>(<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
1186
-
1187
-
1188
-
1189
- &mdash;
1190
- <div class='inline'>
1191
- <p>a new mock object</p>
1192
- </div>
1193
-
1194
- </li>
1195
-
1196
- </ul>
1197
-
1198
- </div><table class="source_code">
1199
- <tr>
1200
- <td>
1201
- <pre class="lines">
1202
-
1203
-
1204
- 163
1205
- 164
1206
- 165
1207
- 166
1208
- 167
1209
- 168
1210
- 169
1211
- 170
1212
- 171
1213
- 172
1214
- 173
1215
- 174
1216
- 175
1217
- 176
1218
- 177
1219
- 178
1220
- 179
1221
- 180
1222
- 181
1223
- 182
1224
- 183
1225
- 184
1226
- 185
1227
- 186
1228
- 187
1229
- 188</pre>
1230
- </td>
1231
- <td>
1232
- <pre class="code"><span class="info file"># File 'lib/mocha/api.rb', line 163</span>
1233
-
1234
- <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>
1235
- <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_reinstate_undocumented_behaviour_from_v1_9?'>reinstate_undocumented_behaviour_from_v1_9?</span>
1236
- <span class='kw'>if</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Symbol</span><span class='rparen'>)</span>
1237
- <span class='id identifier rubyid_method_name'>method_name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
1238
- <span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span>
1239
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Explicitly include `</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>` in Hash of stubbed methods vs return values,</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
1240
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'> e.g. `stub_everything(:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> =&gt; nil)`.</span><span class='tstring_end'>&quot;</span></span>
1241
- <span class='rparen'>)</span>
1242
- <span class='kw'>if</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
1243
- <span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span>
1244
- <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>In this case the 2nd argument for `stub_everything(:#</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_method_name'>method_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>, ...)` is ignored,</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span>
1245
- <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'> but in the future a Hash of stubbed methods vs return values will be respected.</span><span class='tstring_end'>&#39;</span></span>
1246
- <span class='rparen'>)</span>
1247
- <span class='kw'>end</span>
1248
- <span class='kw'>elsif</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
1249
- <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
1250
- <span class='kw'>end</span>
1251
- <span class='kw'>elsif</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Symbol</span><span class='rparen'>)</span>
1252
- <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
1253
- <span class='kw'>end</span>
1254
- <span class='id identifier rubyid_expectations'>expectations</span> <span class='op'>=</span> <span class='id identifier rubyid_arguments'>arguments</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
1255
- <span class='id identifier rubyid_stub'>stub</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>?</span> <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_named_mock'>named_mock</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span> <span class='op'>:</span> <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_unnamed_mock'>unnamed_mock</span>
1256
- <span class='id identifier rubyid_stub'>stub</span><span class='period'>.</span><span class='id identifier rubyid_stub_everything'>stub_everything</span>
1257
- <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>
1258
- <span class='id identifier rubyid_stub'>stub</span>
1259
- <span class='kw'>end</span></pre>
1260
- </td>
1261
- </tr>
1262
- </table>
1263
- </div>
1264
-
1265
- </div>
1266
-
1267
- <script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
1268
- <script>
1269
- window.dataLayer = window.dataLayer || [];
1270
- function gtag(){dataLayer.push(arguments);}
1271
- gtag('js', new Date());
1272
-
1273
- gtag('config', 'UA-625523-7');
1274
- </script>
1275
- </div>
1276
-
1277
- <div id="footer">
1278
- Generated on Sat Jan 4 17:36:47 2020 by
1279
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1280
- 0.9.20 (ruby-2.6.5).
1281
- </div>
1282
-
1283
- </div>
1284
- </body>
1285
- </html>