mocha 1.9.0 → 1.10.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +7 -30
- data/README.md +10 -11
- data/RELEASE.md +48 -0
- data/Rakefile +9 -3
- data/docs/CNAME +1 -0
- data/docs/Mocha.html +132 -5
- data/docs/Mocha/API.html +289 -216
- data/docs/Mocha/ClassMethods.html +88 -16
- data/docs/Mocha/Configuration.html +931 -174
- data/docs/Mocha/Expectation.html +200 -255
- data/docs/Mocha/ExpectationError.html +5 -10
- data/docs/Mocha/ExpectationErrorFactory.html +9 -18
- data/docs/Mocha/Hooks.html +12 -27
- data/docs/Mocha/Integration.html +3 -3
- data/docs/Mocha/Integration/MiniTest.html +3 -3
- data/docs/Mocha/Integration/MiniTest/Adapter.html +5 -6
- data/docs/Mocha/Integration/TestUnit.html +3 -3
- data/docs/Mocha/Integration/TestUnit/Adapter.html +5 -6
- data/docs/Mocha/Mock.html +202 -162
- data/docs/Mocha/ObjectMethods.html +121 -68
- data/docs/Mocha/ParameterMatchers.html +21 -109
- data/docs/Mocha/ParameterMatchers/AllOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/AnyOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/AnyParameters.html +3 -3
- data/docs/Mocha/ParameterMatchers/Anything.html +3 -3
- data/docs/Mocha/ParameterMatchers/Base.html +8 -15
- data/docs/Mocha/ParameterMatchers/Equals.html +4 -5
- data/docs/Mocha/ParameterMatchers/EquivalentUri.html +3 -3
- data/docs/Mocha/ParameterMatchers/HasEntries.html +4 -5
- data/docs/Mocha/ParameterMatchers/HasEntry.html +4 -5
- data/docs/Mocha/ParameterMatchers/HasKey.html +4 -5
- data/docs/Mocha/ParameterMatchers/HasValue.html +4 -5
- data/docs/Mocha/ParameterMatchers/Includes.html +4 -5
- data/docs/Mocha/ParameterMatchers/InstanceOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/IsA.html +3 -3
- data/docs/Mocha/ParameterMatchers/KindOf.html +4 -5
- data/docs/Mocha/ParameterMatchers/Not.html +4 -5
- data/docs/Mocha/ParameterMatchers/Optionally.html +3 -3
- data/docs/Mocha/ParameterMatchers/RegexpMatches.html +4 -5
- data/docs/Mocha/ParameterMatchers/RespondsWith.html +4 -5
- data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +4 -5
- data/docs/Mocha/Sequence.html +3 -3
- data/docs/Mocha/StateMachine.html +13 -25
- data/docs/Mocha/StateMachine/State.html +4 -5
- data/docs/Mocha/StateMachine/StatePredicate.html +4 -5
- data/docs/Mocha/StubbingError.html +3 -3
- data/docs/_index.html +4 -22
- data/docs/class_list.html +1 -1
- data/docs/file.COPYING.html +3 -3
- data/docs/file.MIT-LICENSE.html +3 -3
- data/docs/file.README.html +18 -15
- data/docs/file.RELEASE.html +58 -3
- data/docs/frames.html +1 -1
- data/docs/index.html +18 -15
- data/docs/method_list.html +103 -39
- data/docs/top-level-namespace.html +3 -3
- data/gemfiles/Gemfile.minitest.5.11.3 +7 -0
- data/init.rb +1 -3
- data/lib/mocha.rb +8 -0
- data/lib/mocha/any_instance_method.rb +9 -25
- data/lib/mocha/api.rb +62 -66
- data/lib/mocha/cardinality.rb +26 -11
- data/lib/mocha/class_methods.rb +16 -15
- data/lib/mocha/configuration.rb +295 -67
- data/lib/mocha/detection/test_unit.rb +1 -3
- data/lib/mocha/exception_raiser.rb +2 -1
- data/lib/mocha/expectation.rb +56 -58
- data/lib/mocha/expectation_error.rb +1 -3
- data/lib/mocha/expectation_list.rb +6 -6
- data/lib/mocha/inspect.rb +28 -26
- data/lib/mocha/instance_method.rb +19 -2
- data/lib/mocha/integration.rb +1 -3
- data/lib/mocha/integration/mini_test.rb +7 -0
- data/lib/mocha/integration/test_unit.rb +7 -0
- data/lib/mocha/invocation.rb +61 -0
- data/lib/mocha/macos_version.rb +5 -0
- data/lib/mocha/minitest.rb +6 -1
- data/lib/mocha/mock.rb +46 -31
- data/lib/mocha/mockery.rb +28 -61
- data/lib/mocha/names.rb +1 -1
- data/lib/mocha/object_methods.rb +13 -19
- data/lib/mocha/parameter_matchers.rb +1 -1
- data/lib/mocha/parameter_matchers/all_of.rb +1 -1
- data/lib/mocha/parameter_matchers/any_of.rb +1 -1
- data/lib/mocha/parameter_matchers/equivalent_uri.rb +0 -9
- data/lib/mocha/parameter_matchers/includes.rb +2 -0
- data/lib/mocha/parameter_matchers/instance_methods.rb +18 -0
- data/lib/mocha/raised_exception.rb +11 -0
- data/lib/mocha/return_values.rb +3 -3
- data/lib/mocha/setup.rb +5 -0
- data/lib/mocha/single_return_value.rb +2 -1
- data/lib/mocha/singleton_class.rb +9 -0
- data/lib/mocha/{class_method.rb → stubbed_method.rb} +23 -43
- data/lib/mocha/test_unit.rb +6 -1
- data/lib/mocha/thrower.rb +2 -1
- data/lib/mocha/thrown_object.rb +12 -0
- data/lib/mocha/version.rb +1 -1
- data/mocha.gemspec +1 -3
- data/test/acceptance/acceptance_test_helper.rb +6 -0
- data/test/acceptance/bug_18914_test.rb +0 -1
- data/test/acceptance/bug_21465_test.rb +0 -1
- data/test/acceptance/bug_21563_test.rb +0 -1
- data/test/acceptance/display_matching_invocations_alongside_expectations_test.rb +69 -0
- data/test/acceptance/exception_rescue_test.rb +1 -2
- data/test/acceptance/expectations_on_multiple_methods_test.rb +0 -1
- data/test/acceptance/expected_invocation_count_test.rb +2 -3
- data/test/acceptance/failure_messages_test.rb +0 -1
- data/test/acceptance/issue_272_test.rb +1 -2
- data/test/acceptance/issue_65_test.rb +0 -1
- data/test/acceptance/issue_70_test.rb +0 -1
- data/test/acceptance/mocha_example_test.rb +0 -1
- data/test/acceptance/mocha_test_result_test.rb +0 -1
- data/test/acceptance/mock_test.rb +47 -6
- data/test/acceptance/mocked_methods_dispatch_test.rb +0 -1
- data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -1
- data/test/acceptance/optional_parameters_test.rb +0 -1
- data/test/acceptance/parameter_matcher_test.rb +0 -1
- data/test/acceptance/partial_mocks_test.rb +0 -1
- data/test/acceptance/prepend_test.rb +0 -1
- data/test/acceptance/prevent_use_of_mocha_outside_test_test.rb +0 -1
- data/test/acceptance/raise_exception_test.rb +0 -1
- data/test/acceptance/return_value_test.rb +0 -1
- data/test/acceptance/sequence_test.rb +0 -1
- data/test/acceptance/states_test.rb +0 -1
- data/test/acceptance/stub_any_instance_method_defined_on_superclass_test.rb +1 -2
- data/test/acceptance/stub_any_instance_method_test.rb +20 -1
- data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_class_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_module_test.rb +0 -1
- data/test/acceptance/stub_class_method_defined_on_superclass_test.rb +1 -2
- data/test/acceptance/stub_everything_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_active_record_association_proxy_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_class_and_aliased_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_kernel_module_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_module_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_object_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +0 -1
- data/test/acceptance/stub_instance_method_defined_on_superclass_test.rb +0 -1
- data/test/acceptance/stub_method_defined_on_module_and_aliased_test.rb +0 -1
- data/test/acceptance/stub_module_method_test.rb +0 -1
- data/test/acceptance/stub_test.rb +0 -1
- data/test/acceptance/stubba_example_test.rb +0 -1
- data/test/acceptance/stubba_test_result_test.rb +0 -1
- data/test/acceptance/stubbing_error_backtrace_test.rb +4 -5
- data/test/acceptance/stubbing_frozen_object_test.rb +0 -1
- data/test/acceptance/stubbing_method_accepting_block_parameter_test.rb +0 -1
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +5 -5
- data/test/acceptance/stubbing_nil_test.rb +5 -5
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +8 -8
- data/test/acceptance/stubbing_non_public_class_method_test.rb +9 -9
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +9 -9
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
- data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +0 -1
- data/test/acceptance/throw_test.rb +0 -1
- data/test/acceptance/unexpected_invocation_test.rb +0 -1
- data/test/acceptance/unstubbing_test.rb +0 -1
- data/test/integration/shared_tests.rb +5 -3
- data/test/method_definer.rb +11 -17
- data/test/test_runner.rb +2 -0
- data/test/unit/any_instance_method_test.rb +41 -40
- data/test/unit/cardinality_test.rb +41 -23
- data/test/unit/central_test.rb +0 -1
- data/test/unit/class_methods_test.rb +1 -1
- data/test/unit/configuration_test.rb +12 -12
- data/test/unit/exception_raiser_test.rb +10 -5
- data/test/unit/expectation_list_test.rb +13 -11
- data/test/unit/expectation_test.rb +88 -103
- data/test/unit/instance_method_test.rb +282 -0
- data/test/unit/mock_test.rb +28 -19
- data/test/unit/mockery_test.rb +8 -11
- data/test/unit/module_methods_test.rb +2 -3
- data/test/unit/object_inspect_test.rb +6 -4
- data/test/unit/object_methods_test.rb +3 -2
- data/test/unit/parameter_matchers/equivalent_uri_test.rb +0 -9
- data/test/unit/parameter_matchers/has_entries_test.rb +1 -1
- data/test/unit/parameter_matchers/has_entry_test.rb +1 -1
- data/test/unit/parameter_matchers/has_key_test.rb +1 -1
- data/test/unit/parameter_matchers/has_value_test.rb +1 -1
- data/test/unit/parameter_matchers/includes_test.rb +1 -1
- data/test/unit/parameter_matchers/responds_with_test.rb +1 -1
- data/test/unit/return_values_test.rb +25 -20
- data/test/unit/single_return_value_test.rb +6 -1
- data/test/unit/thrower_test.rb +7 -2
- metadata +16 -30
- data/docs/Mocha/UnexpectedInvocation.html +0 -140
- data/lib/mocha/mini_test.rb +0 -5
- data/lib/mocha/module_method.rb +0 -6
- data/lib/mocha/module_methods.rb +0 -10
- data/lib/mocha/parameter_matchers/object.rb +0 -15
- data/lib/mocha/standalone.rb +0 -4
- data/lib/mocha/unexpected_invocation.rb +0 -24
- data/lib/mocha_standalone.rb +0 -4
- data/test/acceptance/mock_with_initializer_block_test.rb +0 -56
- data/test/unit/class_method_test.rb +0 -276
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Exception: Mocha::ExpectationError
|
8
8
|
|
9
|
-
— Mocha 1.
|
9
|
+
— Mocha 1.10.0.alpha
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -104,14 +104,9 @@
|
|
104
104
|
<h2>Overview</h2><div class="docstring">
|
105
105
|
<div class="discussion">
|
106
106
|
|
107
|
-
<p>Default exception class raised when an unexpected invocation or an
|
108
|
-
unsatisfied expectation occurs.</p>
|
107
|
+
<p>Default exception class raised when an unexpected invocation or an unsatisfied expectation occurs.</p>
|
109
108
|
|
110
|
-
<p>Authors of test libraries may use
|
111
|
-
<code>Mocha::ExpectationErrorFactory</code> to have Mocha raise a different
|
112
|
-
exception.</p>
|
113
|
-
|
114
|
-
<p>rubocop:disable Lint/InheritException</p>
|
109
|
+
<p>Authors of test libraries may use <code>Mocha::ExpectationErrorFactory</code> to have Mocha raise a different exception.</p>
|
115
110
|
|
116
111
|
|
117
112
|
</div>
|
@@ -147,9 +142,9 @@ exception.</p>
|
|
147
142
|
</div>
|
148
143
|
|
149
144
|
<div id="footer">
|
150
|
-
Generated on
|
145
|
+
Generated on Sun Nov 24 15:26:50 2019 by
|
151
146
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
152
|
-
0.9.
|
147
|
+
0.9.20 (ruby-2.6.5).
|
153
148
|
</div>
|
154
149
|
|
155
150
|
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Mocha::ExpectationErrorFactory
|
8
8
|
|
9
|
-
— Mocha 1.
|
9
|
+
— Mocha 1.10.0.alpha
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -102,16 +102,11 @@
|
|
102
102
|
<h2>Overview</h2><div class="docstring">
|
103
103
|
<div class="discussion">
|
104
104
|
|
105
|
-
<p>This factory determines what class of exception should be raised when Mocha
|
106
|
-
detects a test failure.</p>
|
105
|
+
<p>This factory determines what class of exception should be raised when Mocha detects a test failure.</p>
|
107
106
|
|
108
|
-
<p>This class should only be used by authors of test libraries and not by
|
109
|
-
typical “users” of Mocha.</p>
|
107
|
+
<p>This class should only be used by authors of test libraries and not by typical “users” of Mocha.</p>
|
110
108
|
|
111
|
-
<p>For example, it is used by
|
112
|
-
<code>Mocha::Integration::MiniTest::Adapter</code> in order to have Mocha
|
113
|
-
raise a <code>MiniTest::Assertion</code> which can then be sensibly handled
|
114
|
-
by <code>MiniTest::Unit::TestCase</code>.</p>
|
109
|
+
<p>For example, it is used by <code>Mocha::Integration::MiniTest::Adapter</code> in order to have Mocha raise a <code>MiniTest::Assertion</code> which can then be sensibly handled by <code>MiniTest::Unit::TestCase</code>.</p>
|
115
110
|
|
116
111
|
|
117
112
|
</div>
|
@@ -154,8 +149,7 @@ by <code>MiniTest::Unit::TestCase</code>.</p>
|
|
154
149
|
|
155
150
|
|
156
151
|
<span class="summary_desc"><div class='inline'>
|
157
|
-
<p>Determines what class of exception should be raised when Mocha detects a
|
158
|
-
test failure.</p>
|
152
|
+
<p>Determines what class of exception should be raised when Mocha detects a test failure.</p>
|
159
153
|
</div></span>
|
160
154
|
|
161
155
|
</li>
|
@@ -184,12 +178,9 @@ test failure.</p>
|
|
184
178
|
</h3><div class="docstring">
|
185
179
|
<div class="discussion">
|
186
180
|
|
187
|
-
<p>Determines what class of exception should be raised when Mocha detects a
|
188
|
-
test failure.</p>
|
181
|
+
<p>Determines what class of exception should be raised when Mocha detects a test failure.</p>
|
189
182
|
|
190
|
-
<p>This attribute may be set by authors of test libraries in order to have
|
191
|
-
Mocha raise exceptions of a specific class when there is an unexpected
|
192
|
-
invocation or an unsatisfied expectation.</p>
|
183
|
+
<p>This attribute may be set by authors of test libraries in order to have Mocha raise exceptions of a specific class when there is an unexpected invocation or an unsatisfied expectation.</p>
|
193
184
|
|
194
185
|
<p>By default a <code>Mocha::ExpectationError</code> will be raised.</p>
|
195
186
|
|
@@ -259,9 +250,9 @@ invocation or an unsatisfied expectation.</p>
|
|
259
250
|
</div>
|
260
251
|
|
261
252
|
<div id="footer">
|
262
|
-
Generated on
|
253
|
+
Generated on Sun Nov 24 15:26:50 2019 by
|
263
254
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
264
|
-
0.9.
|
255
|
+
0.9.20 (ruby-2.6.5).
|
265
256
|
</div>
|
266
257
|
|
267
258
|
</div>
|
data/docs/Mocha/Hooks.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Mocha::Hooks
|
8
8
|
|
9
|
-
— Mocha 1.
|
9
|
+
— Mocha 1.10.0.alpha
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -93,23 +93,13 @@
|
|
93
93
|
|
94
94
|
<p>Integration hooks for test library authors.</p>
|
95
95
|
|
96
|
-
<p>The methods in this module should be called from test libraries wishing to
|
97
|
-
integrate with Mocha.</p>
|
96
|
+
<p>The methods in this module should be called from test libraries wishing to integrate with Mocha.</p>
|
98
97
|
|
99
|
-
<p>This module is provided as part of the <code>Mocha::API</code> module and
|
100
|
-
is therefore part of the public API, but should only be used by authors of
|
101
|
-
test libraries and not by typical “users” of Mocha.</p>
|
98
|
+
<p>This module is provided as part of the <code>Mocha::API</code> module and is therefore part of the public API, but should only be used by authors of test libraries and not by typical “users” of Mocha.</p>
|
102
99
|
|
103
|
-
<p>Integration with Test::Unit and MiniTest are provided as part of Mocha,
|
104
|
-
because they are (or were once) part of the Ruby standard library.
|
105
|
-
Integration with other test libraries is not provided as
|
106
|
-
<strong>part</strong> of Mocha, but is supported by means of the methods in
|
107
|
-
this module.</p>
|
100
|
+
<p>Integration with Test::Unit and MiniTest are provided as part of Mocha, because they are (or were once) part of the Ruby standard library. Integration with other test libraries is not provided as <strong>part</strong> of Mocha, but is supported by means of the methods in this module.</p>
|
108
101
|
|
109
|
-
<p>See the code in the <code>Adapter</code> modules for examples of how to use
|
110
|
-
the methods in this module. <code>Mocha::ExpectationErrorFactory</code> may
|
111
|
-
be used if you want <code>Mocha</code> to raise a different type of
|
112
|
-
exception.</p>
|
102
|
+
<p>See the code in the <code>Adapter</code> modules for examples of how to use the methods in this module. <code>Mocha::ExpectationErrorFactory</code> may be used if you want <code>Mocha</code> to raise a different type of exception.</p>
|
113
103
|
|
114
104
|
|
115
105
|
</div>
|
@@ -211,8 +201,7 @@ exception.</p>
|
|
211
201
|
|
212
202
|
|
213
203
|
<span class="summary_desc"><div class='inline'>
|
214
|
-
<p>Verifies that all mock expectations have been met (only for use by authors
|
215
|
-
of test libraries).</p>
|
204
|
+
<p>Verifies that all mock expectations have been met (only for use by authors of test libraries).</p>
|
216
205
|
</div></span>
|
217
206
|
|
218
207
|
</li>
|
@@ -241,8 +230,7 @@ of test libraries).</p>
|
|
241
230
|
|
242
231
|
<p>Prepares Mocha before a test (only for use by authors of test libraries).</p>
|
243
232
|
|
244
|
-
<p>This method should be called before each individual test starts (including
|
245
|
-
before any “setup” code).</p>
|
233
|
+
<p>This method should be called before each individual test starts (including before any “setup” code).</p>
|
246
234
|
|
247
235
|
|
248
236
|
</div>
|
@@ -285,8 +273,7 @@ before any “setup” code).</p>
|
|
285
273
|
|
286
274
|
<p>Resets Mocha after a test (only for use by authors of test libraries).</p>
|
287
275
|
|
288
|
-
<p>This method should be called after each individual test has finished
|
289
|
-
(including after any “teardown” code).</p>
|
276
|
+
<p>This method should be called after each individual test has finished (including after any “teardown” code).</p>
|
290
277
|
|
291
278
|
|
292
279
|
</div>
|
@@ -327,13 +314,11 @@ before any “setup” code).</p>
|
|
327
314
|
</h3><div class="docstring">
|
328
315
|
<div class="discussion">
|
329
316
|
|
330
|
-
<p>Verifies that all mock expectations have been met (only for use by authors
|
331
|
-
of test libraries).</p>
|
317
|
+
<p>Verifies that all mock expectations have been met (only for use by authors of test libraries).</p>
|
332
318
|
|
333
319
|
<p>This is equivalent to a series of “assertions”.</p>
|
334
320
|
|
335
|
-
<p>This method should be called at the end of each individual test, before it
|
336
|
-
has been determined whether or not the test has passed.</p>
|
321
|
+
<p>This method should be called at the end of each individual test, before it has been determined whether or not the test has passed.</p>
|
337
322
|
|
338
323
|
|
339
324
|
</div>
|
@@ -375,9 +360,9 @@ has been determined whether or not the test has passed.</p>
|
|
375
360
|
</div>
|
376
361
|
|
377
362
|
<div id="footer">
|
378
|
-
Generated on
|
363
|
+
Generated on Sun Nov 24 15:26:49 2019 by
|
379
364
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
380
|
-
0.9.
|
365
|
+
0.9.20 (ruby-2.6.5).
|
381
366
|
</div>
|
382
367
|
|
383
368
|
</div>
|
data/docs/Mocha/Integration.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Mocha::Integration
|
8
8
|
|
9
|
-
— Mocha 1.
|
9
|
+
— Mocha 1.10.0.alpha
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -115,9 +115,9 @@
|
|
115
115
|
</div>
|
116
116
|
|
117
117
|
<div id="footer">
|
118
|
-
Generated on
|
118
|
+
Generated on Sun Nov 24 15:26:49 2019 by
|
119
119
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
120
|
-
0.9.
|
120
|
+
0.9.20 (ruby-2.6.5).
|
121
121
|
</div>
|
122
122
|
|
123
123
|
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Mocha::Integration::MiniTest
|
8
8
|
|
9
|
-
— Mocha 1.
|
9
|
+
— Mocha 1.10.0.alpha
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -113,9 +113,9 @@
|
|
113
113
|
</div>
|
114
114
|
|
115
115
|
<div id="footer">
|
116
|
-
Generated on
|
116
|
+
Generated on Sun Nov 24 15:26:49 2019 by
|
117
117
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
118
|
-
0.9.
|
118
|
+
0.9.20 (ruby-2.6.5).
|
119
119
|
</div>
|
120
120
|
|
121
121
|
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Mocha::Integration::MiniTest::Adapter
|
8
8
|
|
9
|
-
— Mocha 1.
|
9
|
+
— Mocha 1.10.0.alpha
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -93,8 +93,7 @@
|
|
93
93
|
|
94
94
|
<p>Integrates Mocha into recent versions of MiniTest.</p>
|
95
95
|
|
96
|
-
<p>See the source code for an example of how to integrate Mocha into a test
|
97
|
-
library.</p>
|
96
|
+
<p>See the source code for an example of how to integrate Mocha into a test library.</p>
|
98
97
|
|
99
98
|
|
100
99
|
</div>
|
@@ -141,7 +140,7 @@ library.</p>
|
|
141
140
|
|
142
141
|
|
143
142
|
<h3 class="inherited">Methods included from <span class='object_link'><a href="../../ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span></h3>
|
144
|
-
<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#
|
143
|
+
<p class="inherited"><span class='object_link'><a href="../../ParameterMatchers.html#Not-instance_method" title="Mocha::ParameterMatchers#Not (method)">#Not</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#all_of-instance_method" title="Mocha::ParameterMatchers#all_of (method)">#all_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#any_of-instance_method" title="Mocha::ParameterMatchers#any_of (method)">#any_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#any_parameters-instance_method" title="Mocha::ParameterMatchers#any_parameters (method)">#any_parameters</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#anything-instance_method" title="Mocha::ParameterMatchers#anything (method)">#anything</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#equals-instance_method" title="Mocha::ParameterMatchers#equals (method)">#equals</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#equivalent_uri-instance_method" title="Mocha::ParameterMatchers#equivalent_uri (method)">#equivalent_uri</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_entries-instance_method" title="Mocha::ParameterMatchers#has_entries (method)">#has_entries</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_entry-instance_method" title="Mocha::ParameterMatchers#has_entry (method)">#has_entry</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_key-instance_method" title="Mocha::ParameterMatchers#has_key (method)">#has_key</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_value-instance_method" title="Mocha::ParameterMatchers#has_value (method)">#has_value</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#includes-instance_method" title="Mocha::ParameterMatchers#includes (method)">#includes</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#instance_of-instance_method" title="Mocha::ParameterMatchers#instance_of (method)">#instance_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#is_a-instance_method" title="Mocha::ParameterMatchers#is_a (method)">#is_a</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#kind_of-instance_method" title="Mocha::ParameterMatchers#kind_of (method)">#kind_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#optionally-instance_method" title="Mocha::ParameterMatchers#optionally (method)">#optionally</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#regexp_matches-instance_method" title="Mocha::ParameterMatchers#regexp_matches (method)">#regexp_matches</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#responds_with-instance_method" title="Mocha::ParameterMatchers#responds_with (method)">#responds_with</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#yaml_equivalent-instance_method" title="Mocha::ParameterMatchers#yaml_equivalent (method)">#yaml_equivalent</a></span></p>
|
145
144
|
|
146
145
|
|
147
146
|
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
|
@@ -155,9 +154,9 @@ library.</p>
|
|
155
154
|
</div>
|
156
155
|
|
157
156
|
<div id="footer">
|
158
|
-
Generated on
|
157
|
+
Generated on Sun Nov 24 15:26:49 2019 by
|
159
158
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
160
|
-
0.9.
|
159
|
+
0.9.20 (ruby-2.6.5).
|
161
160
|
</div>
|
162
161
|
|
163
162
|
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Mocha::Integration::TestUnit
|
8
8
|
|
9
|
-
— Mocha 1.
|
9
|
+
— Mocha 1.10.0.alpha
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -113,9 +113,9 @@
|
|
113
113
|
</div>
|
114
114
|
|
115
115
|
<div id="footer">
|
116
|
-
Generated on
|
116
|
+
Generated on Sun Nov 24 15:26:49 2019 by
|
117
117
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
118
|
-
0.9.
|
118
|
+
0.9.20 (ruby-2.6.5).
|
119
119
|
</div>
|
120
120
|
|
121
121
|
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Mocha::Integration::TestUnit::Adapter
|
8
8
|
|
9
|
-
— Mocha 1.
|
9
|
+
— Mocha 1.10.0.alpha
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -93,8 +93,7 @@
|
|
93
93
|
|
94
94
|
<p>Integrates Mocha into recent versions of Test::Unit.</p>
|
95
95
|
|
96
|
-
<p>See the source code for an example of how to integrate Mocha into a test
|
97
|
-
library.</p>
|
96
|
+
<p>See the source code for an example of how to integrate Mocha into a test library.</p>
|
98
97
|
|
99
98
|
|
100
99
|
</div>
|
@@ -141,7 +140,7 @@ library.</p>
|
|
141
140
|
|
142
141
|
|
143
142
|
<h3 class="inherited">Methods included from <span class='object_link'><a href="../../ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span></h3>
|
144
|
-
<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#
|
143
|
+
<p class="inherited"><span class='object_link'><a href="../../ParameterMatchers.html#Not-instance_method" title="Mocha::ParameterMatchers#Not (method)">#Not</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#all_of-instance_method" title="Mocha::ParameterMatchers#all_of (method)">#all_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#any_of-instance_method" title="Mocha::ParameterMatchers#any_of (method)">#any_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#any_parameters-instance_method" title="Mocha::ParameterMatchers#any_parameters (method)">#any_parameters</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#anything-instance_method" title="Mocha::ParameterMatchers#anything (method)">#anything</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#equals-instance_method" title="Mocha::ParameterMatchers#equals (method)">#equals</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#equivalent_uri-instance_method" title="Mocha::ParameterMatchers#equivalent_uri (method)">#equivalent_uri</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_entries-instance_method" title="Mocha::ParameterMatchers#has_entries (method)">#has_entries</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_entry-instance_method" title="Mocha::ParameterMatchers#has_entry (method)">#has_entry</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_key-instance_method" title="Mocha::ParameterMatchers#has_key (method)">#has_key</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#has_value-instance_method" title="Mocha::ParameterMatchers#has_value (method)">#has_value</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#includes-instance_method" title="Mocha::ParameterMatchers#includes (method)">#includes</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#instance_of-instance_method" title="Mocha::ParameterMatchers#instance_of (method)">#instance_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#is_a-instance_method" title="Mocha::ParameterMatchers#is_a (method)">#is_a</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#kind_of-instance_method" title="Mocha::ParameterMatchers#kind_of (method)">#kind_of</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#optionally-instance_method" title="Mocha::ParameterMatchers#optionally (method)">#optionally</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#regexp_matches-instance_method" title="Mocha::ParameterMatchers#regexp_matches (method)">#regexp_matches</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#responds_with-instance_method" title="Mocha::ParameterMatchers#responds_with (method)">#responds_with</a></span>, <span class='object_link'><a href="../../ParameterMatchers.html#yaml_equivalent-instance_method" title="Mocha::ParameterMatchers#yaml_equivalent (method)">#yaml_equivalent</a></span></p>
|
145
144
|
|
146
145
|
|
147
146
|
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
|
@@ -155,9 +154,9 @@ library.</p>
|
|
155
154
|
</div>
|
156
155
|
|
157
156
|
<div id="footer">
|
158
|
-
Generated on
|
157
|
+
Generated on Sun Nov 24 15:26:49 2019 by
|
159
158
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
160
|
-
0.9.
|
159
|
+
0.9.20 (ruby-2.6.5).
|
161
160
|
</div>
|
162
161
|
|
163
162
|
</div>
|
data/docs/Mocha/Mock.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Mocha::Mock
|
8
8
|
|
9
|
-
— Mocha 1.
|
9
|
+
— Mocha 1.10.0.alpha
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -104,56 +104,33 @@
|
|
104
104
|
|
105
105
|
<p>Traditional mock object.</p>
|
106
106
|
|
107
|
-
<p>
|
108
|
-
methods on <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</p>
|
107
|
+
<p><span class='object_link'><a href="#expects-instance_method" title="Mocha::Mock#expects (method)">#expects</a></span> and <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span> return an <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span> which can be further modified by methods on <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</p>
|
109
108
|
|
110
|
-
<p>
|
111
|
-
expectation of zero or more invocations. The <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span> method is syntactic
|
112
|
-
sugar to make the intent of the test more explicit.</p>
|
109
|
+
<p><span class='object_link'><a href="#responds_like-instance_method" title="Mocha::Mock#responds_like (method)">#responds_like</a></span> and <span class='object_link'><a href="#responds_like_instance_of-instance_method" title="Mocha::Mock#responds_like_instance_of (method)">#responds_like_instance_of</a></span> both return a <span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span>, and can therefore, be chained to the original creation methods in <span class='object_link'><a href="API.html" title="Mocha::API (module)">API</a></span>. They force the mock to indicate what it is supposed to be mocking, thus making it a safer verifying mock. They check that the underlying <code>responder</code> will actually respond to the methods being stubbed, throwing a <code>NoMethodError</code> upon invocation otherwise.</p>
|
113
110
|
|
114
|
-
<p>
|
115
|
-
|
116
|
-
invocation. After the invocation, the matching expectation might stop
|
117
|
-
matching further invocations. For example, an <tt>expects(:foo).once</tt>
|
118
|
-
expectation only matches once and will be ignored on future invocations
|
119
|
-
while an <tt>expects(:foo).at_least_once</tt> expectation will always be matched
|
120
|
-
against invocations.</p>
|
111
|
+
<p>Stubs and expectations are basically the same thing. A stub is just an expectation of zero or more invocations. The <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span> method is syntactic sugar to make the intent of the test more explicit.</p>
|
112
|
+
|
113
|
+
<p>When a method is invoked on a mock object, the mock object searches through its expectations from newest to oldest to find one that matches the invocation. After the invocation, the matching expectation might stop matching further invocations. For example, an <tt>expects(:foo).once</tt> expectation only matches once and will be ignored on future invocations while an <tt>expects(:foo).at_least_once</tt> expectation will always be matched against invocations.</p>
|
121
114
|
|
122
115
|
<p>This scheme allows you to:</p>
|
123
116
|
<ul><li>
|
124
|
-
<p>Set up default stubs in your the <code>setup</code> method of your test
|
125
|
-
class and override some of those stubs in individual tests.</p>
|
117
|
+
<p>Set up default stubs in your the <code>setup</code> method of your test class and override some of those stubs in individual tests.</p>
|
126
118
|
</li><li>
|
127
|
-
<p>Set up different <code>once</code> expectations for the same method with
|
128
|
-
different action per invocation. However, it's better to use the
|
129
|
-
<span class='object_link'><a href="Expectation.html#returns-instance_method" title="Mocha::Expectation#returns (method)">Expectation#returns</a></span> method with multiple arguments to do this, as
|
130
|
-
described below.</p>
|
119
|
+
<p>Set up different <code>once</code> expectations for the same method with different action per invocation. However, it's better to use the <span class='object_link'><a href="Expectation.html#returns-instance_method" title="Mocha::Expectation#returns (method)">Expectation#returns</a></span> method with multiple arguments to do this, as described below.</p>
|
131
120
|
</li></ul>
|
132
121
|
|
133
122
|
<p>However, there are some possible “gotchas” caused by this scheme:</p>
|
134
123
|
<ul><li>
|
135
|
-
<p>if you create an expectation and then a stub for the same method, the stub
|
136
|
-
will always override the expectation and the expectation will never be met.</p>
|
124
|
+
<p>if you create an expectation and then a stub for the same method, the stub will always override the expectation and the expectation will never be met.</p>
|
137
125
|
</li><li>
|
138
|
-
<p>if you create a stub and then an expectation for the same method, the
|
139
|
-
expectation will match, and when it stops matching the stub will be used
|
140
|
-
instead, possibly masking test failures.</p>
|
126
|
+
<p>if you create a stub and then an expectation for the same method, the expectation will match, and when it stops matching the stub will be used instead, possibly masking test failures.</p>
|
141
127
|
</li><li>
|
142
|
-
<p>if you create different expectations for the same method, they will be
|
143
|
-
invoked in the opposite order than that in which they were specified,
|
144
|
-
rather than the same order.</p>
|
128
|
+
<p>if you create different expectations for the same method, they will be invoked in the opposite order than that in which they were specified, rather than the same order.</p>
|
145
129
|
</li></ul>
|
146
130
|
|
147
|
-
<p>The best thing to do is not set up multiple expectations and stubs for the
|
148
|
-
same method with exactly the same matchers. Instead, use the
|
149
|
-
<span class='object_link'><a href="Expectation.html#returns-instance_method" title="Mocha::Expectation#returns (method)">Expectation#returns</a></span> method with multiple arguments to create multiple
|
150
|
-
actions for a method. You can also chain multiple calls to
|
151
|
-
<span class='object_link'><a href="Expectation.html#returns-instance_method" title="Mocha::Expectation#returns (method)">Expectation#returns</a></span> and <span class='object_link'><a href="Expectation.html#raises-instance_method" title="Mocha::Expectation#raises (method)">Expectation#raises</a></span> (along with syntactic sugar
|
152
|
-
<span class='object_link'><a href="Expectation.html#then-instance_method" title="Mocha::Expectation#then (method)">Expectation#then</a></span> if desired).</p>
|
131
|
+
<p>The best thing to do is not set up multiple expectations and stubs for the same method with exactly the same matchers. Instead, use the <span class='object_link'><a href="Expectation.html#returns-instance_method" title="Mocha::Expectation#returns (method)">Expectation#returns</a></span> method with multiple arguments to create multiple actions for a method. You can also chain multiple calls to <span class='object_link'><a href="Expectation.html#returns-instance_method" title="Mocha::Expectation#returns (method)">Expectation#returns</a></span> and <span class='object_link'><a href="Expectation.html#raises-instance_method" title="Mocha::Expectation#raises (method)">Expectation#raises</a></span> (along with syntactic sugar <span class='object_link'><a href="Expectation.html#then-instance_method" title="Mocha::Expectation#then (method)">Expectation#then</a></span> if desired).</p>
|
153
132
|
|
154
|
-
<p>If you want to specify more complex ordering or order invocations across
|
155
|
-
different mock objects, use the <span class='object_link'><a href="Expectation.html#in_sequence-instance_method" title="Mocha::Expectation#in_sequence (method)">Expectation#in_sequence</a></span> method to
|
156
|
-
explicitly define a total or partial ordering of invocations.</p>
|
133
|
+
<p>If you want to specify more complex ordering or order invocations across different mock objects, use the <span class='object_link'><a href="Expectation.html#in_sequence-instance_method" title="Mocha::Expectation#in_sequence (method)">Expectation#in_sequence</a></span> method to explicitly define a total or partial ordering of invocations.</p>
|
157
134
|
|
158
135
|
|
159
136
|
</div>
|
@@ -208,8 +185,7 @@ explicitly define a total or partial ordering of invocations.</p>
|
|
208
185
|
|
209
186
|
|
210
187
|
<span class="summary_desc"><div class='inline'>
|
211
|
-
<p>Adds an expectation that the specified method must be called exactly once
|
212
|
-
with any parameters.</p>
|
188
|
+
<p>Adds an expectation that the specified method must be called exactly once with any parameters.</p>
|
213
189
|
</div></span>
|
214
190
|
|
215
191
|
</li>
|
@@ -257,8 +233,7 @@ with any parameters.</p>
|
|
257
233
|
|
258
234
|
|
259
235
|
<span class="summary_desc"><div class='inline'>
|
260
|
-
<p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span> instance so that it can only expect or stub methods
|
261
|
-
to which <code>responder</code> responds.</p>
|
236
|
+
<p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span> instance so that it can only expect or stub methods to which <code>responder</code> responds.</p>
|
262
237
|
</div></span>
|
263
238
|
|
264
239
|
</li>
|
@@ -284,8 +259,7 @@ to which <code>responder</code> responds.</p>
|
|
284
259
|
|
285
260
|
|
286
261
|
<span class="summary_desc"><div class='inline'>
|
287
|
-
<p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span> instance so that it can only expect or stub methods
|
288
|
-
to which an instance of the <code>responder_class</code> responds.</p>
|
262
|
+
<p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mock</a></span> instance so that it can only expect or stub methods to which an instance of the <code>responder_class</code> responds.</p>
|
289
263
|
</div></span>
|
290
264
|
|
291
265
|
</li>
|
@@ -311,8 +285,7 @@ to which an instance of the <code>responder_class</code> responds.</p>
|
|
311
285
|
|
312
286
|
|
313
287
|
<span class="summary_desc"><div class='inline'>
|
314
|
-
<p>Adds an expectation that the specified method may be called any number of
|
315
|
-
times with any parameters.</p>
|
288
|
+
<p>Adds an expectation that the specified method may be called any number of times with any parameters.</p>
|
316
289
|
</div></span>
|
317
290
|
|
318
291
|
</li>
|
@@ -321,7 +294,7 @@ times with any parameters.</p>
|
|
321
294
|
<li class="public ">
|
322
295
|
<span class="summary_signature">
|
323
296
|
|
324
|
-
<a href="#unstub-instance_method" title="#unstub (instance method)">#<strong>unstub</strong>(
|
297
|
+
<a href="#unstub-instance_method" title="#unstub (instance method)">#<strong>unstub</strong>(*method_names) ⇒ Object </a>
|
325
298
|
|
326
299
|
|
327
300
|
|
@@ -336,8 +309,7 @@ times with any parameters.</p>
|
|
336
309
|
|
337
310
|
|
338
311
|
<span class="summary_desc"><div class='inline'>
|
339
|
-
<p>Removes the specified stubbed
|
340
|
-
<span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span>) and all expectations associated with it.</p>
|
312
|
+
<p>Removes the specified stubbed methods (added by calls to <span class='object_link'><a href="#expects-instance_method" title="Mocha::Mock#expects (method)">#expects</a></span> or <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span>) and all expectations associated with them.</p>
|
341
313
|
</div></span>
|
342
314
|
|
343
315
|
</li>
|
@@ -365,7 +337,7 @@ times with any parameters.</p>
|
|
365
337
|
</h3><div class="docstring">
|
366
338
|
<div class="discussion">
|
367
339
|
|
368
|
-
<p>rubocop:disable Style/MethodMissingSuper</p>
|
340
|
+
<p>rubocop:disable Style/MethodMissingSuper,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity</p>
|
369
341
|
|
370
342
|
|
371
343
|
</div>
|
@@ -379,44 +351,44 @@ times with any parameters.</p>
|
|
379
351
|
<pre class="lines">
|
380
352
|
|
381
353
|
|
382
|
-
294
|
383
|
-
295
|
384
|
-
296
|
385
|
-
297
|
386
|
-
298
|
387
|
-
299
|
388
|
-
300
|
389
|
-
301
|
390
|
-
302
|
391
|
-
303
|
392
|
-
304
|
393
|
-
305
|
394
|
-
306
|
395
|
-
307
|
396
|
-
308
|
397
354
|
309
|
398
355
|
310
|
399
|
-
311
|
356
|
+
311
|
357
|
+
312
|
358
|
+
313
|
359
|
+
314
|
360
|
+
315
|
361
|
+
316
|
362
|
+
317
|
363
|
+
318
|
364
|
+
319
|
365
|
+
320
|
366
|
+
321
|
367
|
+
322
|
368
|
+
323
|
369
|
+
324
|
370
|
+
325
|
371
|
+
326</pre>
|
400
372
|
</td>
|
401
373
|
<td>
|
402
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line
|
374
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 309</span>
|
403
375
|
|
404
376
|
<span class='kw'>def</span> <span class='id identifier rubyid_method_missing'>method_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
405
377
|
<span class='kw'>if</span> <span class='ivar'>@responder</span> <span class='op'>&&</span> <span class='op'>!</span><span class='ivar'>@responder</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='rparen'>)</span>
|
406
378
|
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>NoMethodError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>undefined method `</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_symbol'>symbol</span><span class='embexpr_end'>}</span><span class='tstring_content'>' for </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_mocha_inspect'>mocha_inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> which responds like </span><span class='embexpr_beg'>#{</span><span class='ivar'>@responder</span><span class='period'>.</span><span class='id identifier rubyid_mocha_inspect'>mocha_inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
407
379
|
<span class='kw'>end</span>
|
408
|
-
<span class='
|
409
|
-
|
410
|
-
|
380
|
+
<span class='id identifier rubyid_invocation'>invocation</span> <span class='op'>=</span> <span class='const'>Invocation</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_symbol'>symbol</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_arguments'>arguments</span><span class='rparen'>)</span>
|
381
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_matching_expectation_allowing_invocation'>matching_expectation_allowing_invocation</span> <span class='op'>=</span> <span class='id identifier rubyid_all_expectations'>all_expectations</span><span class='period'>.</span><span class='id identifier rubyid_match_allowing_invocation'>match_allowing_invocation</span><span class='lparen'>(</span><span class='id identifier rubyid_invocation'>invocation</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
382
|
+
<span class='id identifier rubyid_matching_expectation_allowing_invocation'>matching_expectation_allowing_invocation</span><span class='period'>.</span><span class='id identifier rubyid_invoke'>invoke</span><span class='lparen'>(</span><span class='id identifier rubyid_invocation'>invocation</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
383
|
+
<span class='kw'>elsif</span> <span class='lparen'>(</span><span class='id identifier rubyid_matching_expectation'>matching_expectation</span> <span class='op'>=</span> <span class='id identifier rubyid_all_expectations'>all_expectations</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='id identifier rubyid_invocation'>invocation</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='op'>!</span><span class='id identifier rubyid_matching_expectation'>matching_expectation</span> <span class='op'>&&</span> <span class='op'>!</span><span class='ivar'>@everything_stubbed</span><span class='rparen'>)</span>
|
411
384
|
<span class='kw'>if</span> <span class='ivar'>@unexpected_invocation</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
412
|
-
<span class='ivar'>@unexpected_invocation</span> <span class='op'>=</span> <span class='
|
413
|
-
<span class='id identifier rubyid_matching_expectation'>matching_expectation</span><span class='period'>.</span><span class='id identifier rubyid_invoke'>invoke</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_matching_expectation'>matching_expectation</span>
|
414
|
-
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='ivar'>@unexpected_invocation</span><span class='period'>.</span><span class='id identifier
|
415
|
-
<span class='id identifier rubyid_message'>message</span> <span class='op'><<</span> <span class='ivar'>@mockery</span><span class='period'>.</span><span class='id identifier rubyid_mocha_inspect'>mocha_inspect</span>
|
385
|
+
<span class='ivar'>@unexpected_invocation</span> <span class='op'>=</span> <span class='id identifier rubyid_invocation'>invocation</span>
|
386
|
+
<span class='id identifier rubyid_matching_expectation'>matching_expectation</span><span class='period'>.</span><span class='id identifier rubyid_invoke'>invoke</span><span class='lparen'>(</span><span class='id identifier rubyid_invocation'>invocation</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_matching_expectation'>matching_expectation</span>
|
387
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='ivar'>@unexpected_invocation</span><span class='period'>.</span><span class='id identifier rubyid_call_description'>call_description</span><span class='embexpr_end'>}</span><span class='tstring_content'>\n</span><span class='embexpr_beg'>#{</span><span class='ivar'>@mockery</span><span class='period'>.</span><span class='id identifier rubyid_mocha_inspect'>mocha_inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
416
388
|
<span class='kw'>else</span>
|
417
|
-
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='ivar'>@unexpected_invocation</span><span class='period'>.</span><span class='id identifier
|
389
|
+
<span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='ivar'>@unexpected_invocation</span><span class='period'>.</span><span class='id identifier rubyid_short_call_description'>short_call_description</span>
|
418
390
|
<span class='kw'>end</span>
|
419
|
-
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ExpectationErrorFactory.html" title="Mocha::ExpectationErrorFactory (class)">ExpectationErrorFactory</a></span></span><span class='period'>.</span><span class='id identifier rubyid_build'>build</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span><span class='rparen'>)</span>
|
391
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ExpectationErrorFactory.html" title="Mocha::ExpectationErrorFactory (class)">ExpectationErrorFactory</a></span></span><span class='period'>.</span><span class='id identifier rubyid_build'>build</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>unexpected invocation: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span><span class='rparen'>)</span>
|
420
392
|
<span class='kw'>end</span>
|
421
393
|
<span class='kw'>end</span></pre>
|
422
394
|
</td>
|
@@ -451,8 +423,7 @@ times with any parameters.</p>
|
|
451
423
|
</h3><div class="docstring">
|
452
424
|
<div class="discussion">
|
453
425
|
|
454
|
-
<p>Adds an expectation that the specified method must be called exactly once
|
455
|
-
with any parameters.</p>
|
426
|
+
<p>Adds an expectation that the specified method must be called exactly once with any parameters.</p>
|
456
427
|
|
457
428
|
|
458
429
|
</div>
|
@@ -492,8 +463,7 @@ with any parameters.</p>
|
|
492
463
|
|
493
464
|
|
494
465
|
<p class="example_title"><div class='inline'>
|
495
|
-
<p>Setup multiple expectations using
|
496
|
-
<code>expected_methods_vs_return_values</code>.</p>
|
466
|
+
<p>Setup multiple expectations using <code>expected_methods_vs_return_values</code>.</p>
|
497
467
|
</div></p>
|
498
468
|
|
499
469
|
<pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
@@ -506,7 +476,21 @@ with any parameters.</p>
|
|
506
476
|
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:expected_method_two</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='symbol'>:result_two</span><span class='rparen'>)</span></code></pre>
|
507
477
|
|
508
478
|
</div>
|
509
|
-
|
479
|
+
|
480
|
+
<p class="tag_title">Overloads:</p>
|
481
|
+
<ul class="overload">
|
482
|
+
|
483
|
+
|
484
|
+
<li class="overload_item">
|
485
|
+
<span class="signature">#<strong>expects</strong>(method_name) ⇒ <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
|
486
|
+
<div class="docstring">
|
487
|
+
<div class="discussion">
|
488
|
+
|
489
|
+
|
490
|
+
</div>
|
491
|
+
</div>
|
492
|
+
<div class="tags">
|
493
|
+
<p class="tag_title">Parameters:</p>
|
510
494
|
<ul class="param">
|
511
495
|
|
512
496
|
<li>
|
@@ -525,6 +509,25 @@ with any parameters.</p>
|
|
525
509
|
|
526
510
|
</li>
|
527
511
|
|
512
|
+
</ul>
|
513
|
+
|
514
|
+
|
515
|
+
</div>
|
516
|
+
</li>
|
517
|
+
|
518
|
+
|
519
|
+
<li class="overload_item">
|
520
|
+
<span class="signature">#<strong>expects</strong>(expected_methods_vs_return_values) ⇒ <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
|
521
|
+
<div class="docstring">
|
522
|
+
<div class="discussion">
|
523
|
+
|
524
|
+
|
525
|
+
</div>
|
526
|
+
</div>
|
527
|
+
<div class="tags">
|
528
|
+
<p class="tag_title">Parameters:</p>
|
529
|
+
<ul class="param">
|
530
|
+
|
528
531
|
<li>
|
529
532
|
|
530
533
|
<span class='name'>expected_methods_vs_return_values</span>
|
@@ -536,15 +539,19 @@ with any parameters.</p>
|
|
536
539
|
|
537
540
|
—
|
538
541
|
<div class='inline'>
|
539
|
-
<p>expected method name symbols as keys and corresponding return values as
|
540
|
-
values - these expectations are setup as if <span class='object_link'><a href="#expects-instance_method" title="Mocha::Mock#expects (method)">#expects</a></span> were called multiple
|
541
|
-
times.</p>
|
542
|
+
<p>expected method name symbols as keys and corresponding return values as values - these expectations are setup as if <span class='object_link'><a href="#expects-instance_method" title="Mocha::Mock#expects (method)">#expects</a></span> were called multiple times.</p>
|
542
543
|
</div>
|
543
544
|
|
544
545
|
</li>
|
545
546
|
|
546
547
|
</ul>
|
547
548
|
|
549
|
+
|
550
|
+
</div>
|
551
|
+
</li>
|
552
|
+
|
553
|
+
</ul>
|
554
|
+
|
548
555
|
<p class="tag_title">Returns:</p>
|
549
556
|
<ul class="return">
|
550
557
|
|
@@ -557,8 +564,7 @@ times.</p>
|
|
557
564
|
|
558
565
|
—
|
559
566
|
<div class='inline'>
|
560
|
-
<p>last-built expectation which can be further modified by methods on
|
561
|
-
<span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</p>
|
567
|
+
<p>last-built expectation which can be further modified by methods on <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</p>
|
562
568
|
</div>
|
563
569
|
|
564
570
|
</li>
|
@@ -571,19 +577,19 @@ times.</p>
|
|
571
577
|
<pre class="lines">
|
572
578
|
|
573
579
|
|
574
|
-
105
|
575
|
-
106
|
576
|
-
107
|
577
|
-
108
|
578
|
-
109
|
579
|
-
110
|
580
580
|
111
|
581
581
|
112
|
582
582
|
113
|
583
|
-
114
|
583
|
+
114
|
584
|
+
115
|
585
|
+
116
|
586
|
+
117
|
587
|
+
118
|
588
|
+
119
|
589
|
+
120</pre>
|
584
590
|
</td>
|
585
591
|
<td>
|
586
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line
|
592
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 111</span>
|
587
593
|
|
588
594
|
<span class='kw'>def</span> <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name_or_hash'>method_name_or_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_backtrace'>backtrace</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
589
595
|
<span class='id identifier rubyid_iterator'>iterator</span> <span class='op'>=</span> <span class='const'>ArgumentIterator</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name_or_hash'>method_name_or_hash</span><span class='rparen'>)</span>
|
@@ -637,12 +643,12 @@ times.</p>
|
|
637
643
|
<pre class="lines">
|
638
644
|
|
639
645
|
|
640
|
-
|
641
|
-
|
642
|
-
|
646
|
+
344
|
647
|
+
345
|
648
|
+
346</pre>
|
643
649
|
</td>
|
644
650
|
<td>
|
645
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line
|
651
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 344</span>
|
646
652
|
|
647
653
|
<span class='kw'>def</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='comma'>,</span> <span class='id identifier rubyid_include_private'>include_private</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
648
654
|
<span class='id identifier rubyid_respond_to_missing?'>respond_to_missing?</span><span class='lparen'>(</span><span class='id identifier rubyid_symbol'>symbol</span><span class='comma'>,</span> <span class='id identifier rubyid_include_private'>include_private</span><span class='rparen'>)</span>
|
@@ -668,16 +674,11 @@ times.</p>
|
|
668
674
|
</h3><div class="docstring">
|
669
675
|
<div class="discussion">
|
670
676
|
|
671
|
-
<p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance so that it can only expect or stub methods
|
672
|
-
to which <code>responder</code> responds. The constraint is only applied at
|
673
|
-
method invocation time.</p>
|
677
|
+
<p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance so that it can only expect or stub methods to which <code>responder</code> responds. The constraint is only applied at method invocation time.</p>
|
674
678
|
|
675
|
-
<p>A <code>NoMethodError</code> will be raised if the <code>responder</code>
|
676
|
-
does not <code>#respond_to?</code> a method invocation (even if the method
|
677
|
-
has been expected or stubbed).</p>
|
679
|
+
<p>A <code>NoMethodError</code> will be raised if the <code>responder</code> does not <code>#respond_to?</code> a method invocation (even if the method has been expected or stubbed).</p>
|
678
680
|
|
679
|
-
<p>The <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance will delegate its <code>#respond_to?</code> method to
|
680
|
-
the <code>responder</code>.</p>
|
681
|
+
<p>The <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance will delegate its <code>#respond_to?</code> method to the <code>responder</code>.</p>
|
681
682
|
|
682
683
|
<p>Note that the methods on <code>responder</code> are never actually invoked.</p>
|
683
684
|
|
@@ -754,8 +755,7 @@ the <code>responder</code>.</p>
|
|
754
755
|
|
755
756
|
—
|
756
757
|
<div class='inline'>
|
757
|
-
<p>an object used to determine whether <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance should
|
758
|
-
<code>#respond_to?</code> to an invocation.</p>
|
758
|
+
<p>an object used to determine whether <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance should <code>#respond_to?</code> to an invocation.</p>
|
759
759
|
</div>
|
760
760
|
|
761
761
|
</li>
|
@@ -774,8 +774,7 @@ the <code>responder</code>.</p>
|
|
774
774
|
|
775
775
|
—
|
776
776
|
<div class='inline'>
|
777
|
-
<p>the same <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span>
|
778
|
-
methods to be chained.</p>
|
777
|
+
<p>the same <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> methods to be chained.</p>
|
779
778
|
</div>
|
780
779
|
|
781
780
|
</li>
|
@@ -795,13 +794,13 @@ methods to be chained.</p>
|
|
795
794
|
<pre class="lines">
|
796
795
|
|
797
796
|
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
797
|
+
232
|
798
|
+
233
|
799
|
+
234
|
800
|
+
235</pre>
|
802
801
|
</td>
|
803
802
|
<td>
|
804
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line
|
803
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 232</span>
|
805
804
|
|
806
805
|
<span class='kw'>def</span> <span class='id identifier rubyid_responds_like'>responds_like</span><span class='lparen'>(</span><span class='id identifier rubyid_responder'>responder</span><span class='rparen'>)</span>
|
807
806
|
<span class='ivar'>@responder</span> <span class='op'>=</span> <span class='id identifier rubyid_responder'>responder</span>
|
@@ -828,17 +827,11 @@ methods to be chained.</p>
|
|
828
827
|
</h3><div class="docstring">
|
829
828
|
<div class="discussion">
|
830
829
|
|
831
|
-
<p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance so that it can only expect or stub methods
|
832
|
-
to which an instance of the <code>responder_class</code> responds. The
|
833
|
-
constraint is only applied at method invocation time. Note that the
|
834
|
-
responder instance is instantiated using <tt>Class#allocate</tt>.</p>
|
830
|
+
<p>Constrains the <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance so that it can only expect or stub methods to which an instance of the <code>responder_class</code> responds. The constraint is only applied at method invocation time. Note that the responder instance is instantiated using <tt>Class#allocate</tt>.</p>
|
835
831
|
|
836
|
-
<p>A <code>NoMethodError</code> will be raised if the responder instance does
|
837
|
-
not <code>#respond_to?</code> a method invocation (even if the method has
|
838
|
-
been expected or stubbed).</p>
|
832
|
+
<p>A <code>NoMethodError</code> will be raised if the responder instance does not <code>#respond_to?</code> a method invocation (even if the method has been expected or stubbed).</p>
|
839
833
|
|
840
|
-
<p>The <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance will delegate its <code>#respond_to?</code> method to
|
841
|
-
the responder instance.</p>
|
834
|
+
<p>The <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance will delegate its <code>#respond_to?</code> method to the responder instance.</p>
|
842
835
|
|
843
836
|
<p>Note that the methods on the responder instance are never actually invoked.</p>
|
844
837
|
|
@@ -886,8 +879,7 @@ the responder instance.</p>
|
|
886
879
|
|
887
880
|
—
|
888
881
|
<div class='inline'>
|
889
|
-
<p>a class used to determine whether <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance should
|
890
|
-
<code>#respond_to?</code> to an invocation.</p>
|
882
|
+
<p>a class used to determine whether <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance should <code>#respond_to?</code> to an invocation.</p>
|
891
883
|
</div>
|
892
884
|
|
893
885
|
</li>
|
@@ -906,8 +898,7 @@ the responder instance.</p>
|
|
906
898
|
|
907
899
|
—
|
908
900
|
<div class='inline'>
|
909
|
-
<p>the same <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span>
|
910
|
-
methods to be chained.</p>
|
901
|
+
<p>the same <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> instance, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Mock (class)">Mocha::Mock</a></span> methods to be chained.</p>
|
911
902
|
</div>
|
912
903
|
|
913
904
|
</li>
|
@@ -927,12 +918,12 @@ methods to be chained.</p>
|
|
927
918
|
<pre class="lines">
|
928
919
|
|
929
920
|
|
930
|
-
|
931
|
-
|
932
|
-
|
921
|
+
265
|
922
|
+
266
|
923
|
+
267</pre>
|
933
924
|
</td>
|
934
925
|
<td>
|
935
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line
|
926
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 265</span>
|
936
927
|
|
937
928
|
<span class='kw'>def</span> <span class='id identifier rubyid_responds_like_instance_of'>responds_like_instance_of</span><span class='lparen'>(</span><span class='id identifier rubyid_responder_class'>responder_class</span><span class='rparen'>)</span>
|
938
929
|
<span class='id identifier rubyid_responds_like'>responds_like</span><span class='lparen'>(</span><span class='id identifier rubyid_responder_class'>responder_class</span><span class='period'>.</span><span class='id identifier rubyid_allocate'>allocate</span><span class='rparen'>)</span>
|
@@ -962,8 +953,7 @@ methods to be chained.</p>
|
|
962
953
|
</h3><div class="docstring">
|
963
954
|
<div class="discussion">
|
964
955
|
|
965
|
-
<p>Adds an expectation that the specified method may be called any number of
|
966
|
-
times with any parameters.</p>
|
956
|
+
<p>Adds an expectation that the specified method may be called any number of times with any parameters.</p>
|
967
957
|
|
968
958
|
|
969
959
|
</div>
|
@@ -986,8 +976,7 @@ times with any parameters.</p>
|
|
986
976
|
|
987
977
|
|
988
978
|
<p class="example_title"><div class='inline'>
|
989
|
-
<p>Setup multiple expectations using
|
990
|
-
<code>stubbed_methods_vs_return_values</code>.</p>
|
979
|
+
<p>Setup multiple expectations using <code>stubbed_methods_vs_return_values</code>.</p>
|
991
980
|
</div></p>
|
992
981
|
|
993
982
|
<pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
@@ -1000,7 +989,21 @@ times with any parameters.</p>
|
|
1000
989
|
<span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:stubbed_method_two</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='symbol'>:result_two</span><span class='rparen'>)</span></code></pre>
|
1001
990
|
|
1002
991
|
</div>
|
1003
|
-
|
992
|
+
|
993
|
+
<p class="tag_title">Overloads:</p>
|
994
|
+
<ul class="overload">
|
995
|
+
|
996
|
+
|
997
|
+
<li class="overload_item">
|
998
|
+
<span class="signature">#<strong>stubs</strong>(method_name) ⇒ <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
|
999
|
+
<div class="docstring">
|
1000
|
+
<div class="discussion">
|
1001
|
+
|
1002
|
+
|
1003
|
+
</div>
|
1004
|
+
</div>
|
1005
|
+
<div class="tags">
|
1006
|
+
<p class="tag_title">Parameters:</p>
|
1004
1007
|
<ul class="param">
|
1005
1008
|
|
1006
1009
|
<li>
|
@@ -1019,6 +1022,25 @@ times with any parameters.</p>
|
|
1019
1022
|
|
1020
1023
|
</li>
|
1021
1024
|
|
1025
|
+
</ul>
|
1026
|
+
|
1027
|
+
|
1028
|
+
</div>
|
1029
|
+
</li>
|
1030
|
+
|
1031
|
+
|
1032
|
+
<li class="overload_item">
|
1033
|
+
<span class="signature">#<strong>stubs</strong>(stubbed_methods_vs_return_values) ⇒ <tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt> </span>
|
1034
|
+
<div class="docstring">
|
1035
|
+
<div class="discussion">
|
1036
|
+
|
1037
|
+
|
1038
|
+
</div>
|
1039
|
+
</div>
|
1040
|
+
<div class="tags">
|
1041
|
+
<p class="tag_title">Parameters:</p>
|
1042
|
+
<ul class="param">
|
1043
|
+
|
1022
1044
|
<li>
|
1023
1045
|
|
1024
1046
|
<span class='name'>stubbed_methods_vs_return_values</span>
|
@@ -1030,15 +1052,19 @@ times with any parameters.</p>
|
|
1030
1052
|
|
1031
1053
|
—
|
1032
1054
|
<div class='inline'>
|
1033
|
-
<p>stubbed method name symbols as keys and corresponding return values as
|
1034
|
-
values - these stubbed methods are setup as if <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span> were called
|
1035
|
-
multiple times.</p>
|
1055
|
+
<p>stubbed method name symbols as keys and corresponding return values as values - these stubbed methods are setup as if <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span> were called multiple times.</p>
|
1036
1056
|
</div>
|
1037
1057
|
|
1038
1058
|
</li>
|
1039
1059
|
|
1040
1060
|
</ul>
|
1041
1061
|
|
1062
|
+
|
1063
|
+
</div>
|
1064
|
+
</li>
|
1065
|
+
|
1066
|
+
</ul>
|
1067
|
+
|
1042
1068
|
<p class="tag_title">Returns:</p>
|
1043
1069
|
<ul class="return">
|
1044
1070
|
|
@@ -1051,8 +1077,7 @@ multiple times.</p>
|
|
1051
1077
|
|
1052
1078
|
—
|
1053
1079
|
<div class='inline'>
|
1054
|
-
<p>last-built expectation which can be further modified by methods on
|
1055
|
-
<span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</p>
|
1080
|
+
<p>last-built expectation which can be further modified by methods on <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</p>
|
1056
1081
|
</div>
|
1057
1082
|
|
1058
1083
|
</li>
|
@@ -1065,20 +1090,20 @@ multiple times.</p>
|
|
1065
1090
|
<pre class="lines">
|
1066
1091
|
|
1067
1092
|
|
1068
|
-
141
|
1069
|
-
142
|
1070
|
-
143
|
1071
|
-
144
|
1072
|
-
145
|
1073
|
-
146
|
1074
1093
|
147
|
1075
1094
|
148
|
1076
1095
|
149
|
1077
1096
|
150
|
1078
|
-
151
|
1097
|
+
151
|
1098
|
+
152
|
1099
|
+
153
|
1100
|
+
154
|
1101
|
+
155
|
1102
|
+
156
|
1103
|
+
157</pre>
|
1079
1104
|
</td>
|
1080
1105
|
<td>
|
1081
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line
|
1106
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 147</span>
|
1082
1107
|
|
1083
1108
|
<span class='kw'>def</span> <span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name_or_hash'>method_name_or_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_backtrace'>backtrace</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1084
1109
|
<span class='id identifier rubyid_iterator'>iterator</span> <span class='op'>=</span> <span class='const'>ArgumentIterator</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name_or_hash'>method_name_or_hash</span><span class='rparen'>)</span>
|
@@ -1099,7 +1124,7 @@ multiple times.</p>
|
|
1099
1124
|
<div class="method_details ">
|
1100
1125
|
<h3 class="signature " id="unstub-instance_method">
|
1101
1126
|
|
1102
|
-
#<strong>unstub</strong>(
|
1127
|
+
#<strong>unstub</strong>(*method_names) ⇒ <tt><span class='object_link'>Object</span></tt>
|
1103
1128
|
|
1104
1129
|
|
1105
1130
|
|
@@ -1108,8 +1133,7 @@ multiple times.</p>
|
|
1108
1133
|
</h3><div class="docstring">
|
1109
1134
|
<div class="discussion">
|
1110
1135
|
|
1111
|
-
<p>Removes the specified stubbed
|
1112
|
-
<span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span>) and all expectations associated with it.</p>
|
1136
|
+
<p>Removes the specified stubbed methods (added by calls to <span class='object_link'><a href="#expects-instance_method" title="Mocha::Mock#expects (method)">#expects</a></span> or <span class='object_link'><a href="#stubs-instance_method" title="Mocha::Mock#stubs (method)">#stubs</a></span>) and all expectations associated with them.</p>
|
1113
1137
|
|
1114
1138
|
|
1115
1139
|
</div>
|
@@ -1130,22 +1154,34 @@ object.stubbed_method # => :result_one
|
|
1130
1154
|
object.unstub(:stubbed_method)
|
1131
1155
|
object.stubbed_method # => unexpected invocation: #<Mock:mock>.stubbed_method()</code></pre>
|
1132
1156
|
|
1157
|
+
|
1158
|
+
<p class="example_title"><div class='inline'>
|
1159
|
+
<p>Unstubbing multiple methods.</p>
|
1160
|
+
</div></p>
|
1161
|
+
|
1162
|
+
<pre class="example code"><code><span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='symbol'>:double</span><span class='comma'>,</span> <span class='symbol'>:triple</span><span class='rparen'>)</span>
|
1163
|
+
|
1164
|
+
<span class='comment'># exactly equivalent to
|
1165
|
+
</span>
|
1166
|
+
<span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='symbol'>:double</span><span class='rparen'>)</span>
|
1167
|
+
<span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='symbol'>:triple</span><span class='rparen'>)</span></code></pre>
|
1168
|
+
|
1133
1169
|
</div>
|
1134
1170
|
<p class="tag_title">Parameters:</p>
|
1135
1171
|
<ul class="param">
|
1136
1172
|
|
1137
1173
|
<li>
|
1138
1174
|
|
1139
|
-
<span class='name'>
|
1175
|
+
<span class='name'>method_names</span>
|
1140
1176
|
|
1141
1177
|
|
1142
|
-
<span class='type'>(<tt>Symbol
|
1178
|
+
<span class='type'>(<tt>Array<Symbol></tt>)</span>
|
1143
1179
|
|
1144
1180
|
|
1145
1181
|
|
1146
1182
|
—
|
1147
1183
|
<div class='inline'>
|
1148
|
-
<p>
|
1184
|
+
<p>names of methods to unstub.</p>
|
1149
1185
|
</div>
|
1150
1186
|
|
1151
1187
|
</li>
|
@@ -1159,15 +1195,19 @@ object.stubbed_method # => unexpected invocation: #<Mock:mock>.stubbed_
|
|
1159
1195
|
<pre class="lines">
|
1160
1196
|
|
1161
1197
|
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1198
|
+
177
|
1199
|
+
178
|
1200
|
+
179
|
1201
|
+
180
|
1202
|
+
181</pre>
|
1165
1203
|
</td>
|
1166
1204
|
<td>
|
1167
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line
|
1205
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/mock.rb', line 177</span>
|
1168
1206
|
|
1169
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='id identifier
|
1170
|
-
<span class='
|
1207
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_method_names'>method_names</span><span class='rparen'>)</span>
|
1208
|
+
<span class='id identifier rubyid_method_names'>method_names</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_method_name'>method_name</span><span class='op'>|</span>
|
1209
|
+
<span class='ivar'>@expectations</span><span class='period'>.</span><span class='id identifier rubyid_remove_all_matching_method'>remove_all_matching_method</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name'>method_name</span><span class='rparen'>)</span>
|
1210
|
+
<span class='kw'>end</span>
|
1171
1211
|
<span class='kw'>end</span></pre>
|
1172
1212
|
</td>
|
1173
1213
|
</tr>
|
@@ -1187,9 +1227,9 @@ object.stubbed_method # => unexpected invocation: #<Mock:mock>.stubbed_
|
|
1187
1227
|
</div>
|
1188
1228
|
|
1189
1229
|
<div id="footer">
|
1190
|
-
Generated on
|
1230
|
+
Generated on Sun Nov 24 15:26:49 2019 by
|
1191
1231
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1192
|
-
0.9.
|
1232
|
+
0.9.20 (ruby-2.6.5).
|
1193
1233
|
</div>
|
1194
1234
|
|
1195
1235
|
</div>
|