mocha 1.9.0 → 1.10.0
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 +30 -11
- data/RELEASE.md +58 -0
- data/Rakefile +9 -3
- data/docs/CNAME +1 -0
- data/docs/Mocha.html +132 -5
- data/docs/Mocha/API.html +313 -216
- data/docs/Mocha/ClassMethods.html +13 -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 +36 -14
- data/docs/file.RELEASE.html +72 -3
- data/docs/frames.html +1 -1
- data/docs/index.html +36 -14
- data/docs/method_list.html +96 -40
- 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 +65 -66
- data/lib/mocha/cardinality.rb +26 -11
- data/lib/mocha/class_methods.rb +17 -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 +14 -28
- 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
data/docs/Mocha/Expectation.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Mocha::Expectation
|
8
8
|
|
9
|
-
— Mocha 1.
|
9
|
+
— Mocha 1.10.0
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -102,8 +102,7 @@
|
|
102
102
|
<h2>Overview</h2><div class="docstring">
|
103
103
|
<div class="discussion">
|
104
104
|
|
105
|
-
<p>Methods on expectations returned from <span class='object_link'><a href="Mock.html#expects-instance_method" title="Mocha::Mock#expects (method)">Mock#expects</a></span>, <span class='object_link'><a href="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span>,
|
106
|
-
<span class='object_link'><a href="ObjectMethods.html#expects-instance_method" title="Mocha::ObjectMethods#expects (method)">ObjectMethods#expects</a></span> and <span class='object_link'><a href="ObjectMethods.html#stubs-instance_method" title="Mocha::ObjectMethods#stubs (method)">ObjectMethods#stubs</a></span>.</p>
|
105
|
+
<p>Methods on expectations returned from <span class='object_link'><a href="Mock.html#expects-instance_method" title="Mocha::Mock#expects (method)">Mock#expects</a></span>, <span class='object_link'><a href="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span>, <span class='object_link'><a href="ObjectMethods.html#expects-instance_method" title="Mocha::ObjectMethods#expects (method)">ObjectMethods#expects</a></span> and <span class='object_link'><a href="ObjectMethods.html#stubs-instance_method" title="Mocha::ObjectMethods#stubs (method)">ObjectMethods#stubs</a></span>.</p>
|
107
106
|
|
108
107
|
|
109
108
|
</div>
|
@@ -144,8 +143,7 @@
|
|
144
143
|
|
145
144
|
|
146
145
|
<span class="summary_desc"><div class='inline'>
|
147
|
-
<p>Modifies expectation so that the expected method must be called at least a
|
148
|
-
<code>minimum_number_of_times</code>.</p>
|
146
|
+
<p>Modifies expectation so that the expected method must be called at least a <code>minimum_number_of_times</code>.</p>
|
149
147
|
</div></span>
|
150
148
|
|
151
149
|
</li>
|
@@ -169,8 +167,7 @@
|
|
169
167
|
|
170
168
|
|
171
169
|
<span class="summary_desc"><div class='inline'>
|
172
|
-
<p>Modifies expectation so that the expected method must be called at least
|
173
|
-
once.</p>
|
170
|
+
<p>Modifies expectation so that the expected method must be called at least once.</p>
|
174
171
|
</div></span>
|
175
172
|
|
176
173
|
</li>
|
@@ -194,8 +191,7 @@ once.</p>
|
|
194
191
|
|
195
192
|
|
196
193
|
<span class="summary_desc"><div class='inline'>
|
197
|
-
<p>Modifies expectation so that the expected method must be called at most a
|
198
|
-
<code>maximum_number_of_times</code>.</p>
|
194
|
+
<p>Modifies expectation so that the expected method must be called at most a <code>maximum_number_of_times</code>.</p>
|
199
195
|
</div></span>
|
200
196
|
|
201
197
|
</li>
|
@@ -219,8 +215,7 @@ once.</p>
|
|
219
215
|
|
220
216
|
|
221
217
|
<span class="summary_desc"><div class='inline'>
|
222
|
-
<p>Modifies expectation so that the expected method must be called at most
|
223
|
-
once.</p>
|
218
|
+
<p>Modifies expectation so that the expected method must be called at most once.</p>
|
224
219
|
</div></span>
|
225
220
|
|
226
221
|
</li>
|
@@ -229,7 +224,7 @@ once.</p>
|
|
229
224
|
<li class="public ">
|
230
225
|
<span class="summary_signature">
|
231
226
|
|
232
|
-
<a href="#in_sequence-instance_method" title="#in_sequence (instance method)">#<strong>in_sequence</strong>(*sequences) ⇒ Expectation </a>
|
227
|
+
<a href="#in_sequence-instance_method" title="#in_sequence (instance method)">#<strong>in_sequence</strong>(sequence, *sequences) ⇒ Expectation </a>
|
233
228
|
|
234
229
|
|
235
230
|
|
@@ -244,8 +239,7 @@ once.</p>
|
|
244
239
|
|
245
240
|
|
246
241
|
<span class="summary_desc"><div class='inline'>
|
247
|
-
<p>Constrains the expectation so that it must be invoked at the current point
|
248
|
-
in the <code>sequence</code>.</p>
|
242
|
+
<p>Constrains the expectation so that it must be invoked at the current point in the <code>sequence</code>.</p>
|
249
243
|
</div></span>
|
250
244
|
|
251
245
|
</li>
|
@@ -269,9 +263,7 @@ in the <code>sequence</code>.</p>
|
|
269
263
|
|
270
264
|
|
271
265
|
<span class="summary_desc"><div class='inline'>
|
272
|
-
<p>Modifies expectation so that when the expected method is called, it yields
|
273
|
-
multiple times per invocation with the specified
|
274
|
-
<code>parameter_groups</code>.</p>
|
266
|
+
<p>Modifies expectation so that when the expected method is called, it yields multiple times per invocation with the specified <code>parameter_groups</code> (even if no block is provided, in which case yielding will result in a <code>LocalJumpError</code>).</p>
|
275
267
|
</div></span>
|
276
268
|
|
277
269
|
</li>
|
@@ -319,8 +311,7 @@ multiple times per invocation with the specified
|
|
319
311
|
|
320
312
|
|
321
313
|
<span class="summary_desc"><div class='inline'>
|
322
|
-
<p>Modifies expectation so that the expected method must be called exactly
|
323
|
-
once.</p>
|
314
|
+
<p>Modifies expectation so that the expected method must be called exactly once.</p>
|
324
315
|
</div></span>
|
325
316
|
|
326
317
|
</li>
|
@@ -344,9 +335,7 @@ once.</p>
|
|
344
335
|
|
345
336
|
|
346
337
|
<span class="summary_desc"><div class='inline'>
|
347
|
-
<p>Modifies expectation so that when the expected method is called, it raises
|
348
|
-
the specified <code>exception</code> with the specified
|
349
|
-
<code>message</code> i.e.</p>
|
338
|
+
<p>Modifies expectation so that when the expected method is called, it raises the specified <code>exception</code> with the specified <code>message</code> i.e.</p>
|
350
339
|
</div></span>
|
351
340
|
|
352
341
|
</li>
|
@@ -370,8 +359,7 @@ the specified <code>exception</code> with the specified
|
|
370
359
|
|
371
360
|
|
372
361
|
<span class="summary_desc"><div class='inline'>
|
373
|
-
<p>Modifies expectation so that when the expected method is called, it returns
|
374
|
-
the specified <code>value</code>.</p>
|
362
|
+
<p>Modifies expectation so that when the expected method is called, it returns the specified <code>value</code>.</p>
|
375
363
|
</div></span>
|
376
364
|
|
377
365
|
</li>
|
@@ -395,8 +383,7 @@ the specified <code>value</code>.</p>
|
|
395
383
|
|
396
384
|
|
397
385
|
<span class="summary_desc"><div class='inline'>
|
398
|
-
<p>The same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Expectation</a></span>
|
399
|
-
methods to be chained.</p>
|
386
|
+
<p>The same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Expectation</a></span> methods to be chained.</p>
|
400
387
|
</div></span>
|
401
388
|
|
402
389
|
</li>
|
@@ -420,9 +407,7 @@ methods to be chained.</p>
|
|
420
407
|
|
421
408
|
|
422
409
|
<span class="summary_desc"><div class='inline'>
|
423
|
-
<p>Modifies expectation so that when the expected method is called, it throws
|
424
|
-
the specified <code>tag</code> with the specific return value
|
425
|
-
<code>object</code> i.e.</p>
|
410
|
+
<p>Modifies expectation so that when the expected method is called, it throws the specified <code>tag</code> with the specific return value <code>object</code> i.e.</p>
|
426
411
|
</div></span>
|
427
412
|
|
428
413
|
</li>
|
@@ -446,8 +431,7 @@ the specified <code>tag</code> with the specific return value
|
|
446
431
|
|
447
432
|
|
448
433
|
<span class="summary_desc"><div class='inline'>
|
449
|
-
<p>Modifies expectation so that the number of calls to the expected method
|
450
|
-
must be within a specific <code>range</code>.</p>
|
434
|
+
<p>Modifies expectation so that the number of calls to the expected method must be within a specific <code>range</code>.</p>
|
451
435
|
</div></span>
|
452
436
|
|
453
437
|
</li>
|
@@ -471,8 +455,7 @@ must be within a specific <code>range</code>.</p>
|
|
471
455
|
|
472
456
|
|
473
457
|
<span class="summary_desc"><div class='inline'>
|
474
|
-
<p>Modifies expectation so that the expected method must be called exactly
|
475
|
-
twice.</p>
|
458
|
+
<p>Modifies expectation so that the expected method must be called exactly twice.</p>
|
476
459
|
</div></span>
|
477
460
|
|
478
461
|
</li>
|
@@ -496,9 +479,7 @@ twice.</p>
|
|
496
479
|
|
497
480
|
|
498
481
|
<span class="summary_desc"><div class='inline'>
|
499
|
-
<p>Constrains the expectation to occur only when the
|
500
|
-
<code>state_machine</code> is in the state specified by
|
501
|
-
<code>state_name</code>.</p>
|
482
|
+
<p>Constrains the expectation to occur only when the <code>state_machine</code> is in the state specified by <code>state_name</code>.</p>
|
502
483
|
</div></span>
|
503
484
|
|
504
485
|
</li>
|
@@ -522,8 +503,7 @@ twice.</p>
|
|
522
503
|
|
523
504
|
|
524
505
|
<span class="summary_desc"><div class='inline'>
|
525
|
-
<p>Modifies expectation so that the expected method must be called with
|
526
|
-
<code>expected_parameters</code>.</p>
|
506
|
+
<p>Modifies expectation so that the expected method must be called with <code>expected_parameters</code>.</p>
|
527
507
|
</div></span>
|
528
508
|
|
529
509
|
</li>
|
@@ -547,8 +527,7 @@ twice.</p>
|
|
547
527
|
|
548
528
|
|
549
529
|
<span class="summary_desc"><div class='inline'>
|
550
|
-
<p>Modifies expectation so that when the expected method is called, it yields
|
551
|
-
with the specified <code>parameters</code>.</p>
|
530
|
+
<p>Modifies expectation so that when the expected method is called, it yields with the specified <code>parameters</code> (even if no block is provided, in which case yielding will result in a <code>LocalJumpError</code>).</p>
|
552
531
|
</div></span>
|
553
532
|
|
554
533
|
</li>
|
@@ -575,8 +554,7 @@ with the specified <code>parameters</code>.</p>
|
|
575
554
|
</h3><div class="docstring">
|
576
555
|
<div class="discussion">
|
577
556
|
|
578
|
-
<p>Modifies expectation so that the expected method must be called at least a
|
579
|
-
<code>minimum_number_of_times</code>.</p>
|
557
|
+
<p>Modifies expectation so that the expected method must be called at least a <code>minimum_number_of_times</code>.</p>
|
580
558
|
|
581
559
|
|
582
560
|
</div>
|
@@ -635,8 +613,7 @@ with the specified <code>parameters</code>.</p>
|
|
635
613
|
|
636
614
|
—
|
637
615
|
<div class='inline'>
|
638
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
639
|
-
methods to be chained.</p>
|
616
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
640
617
|
</div>
|
641
618
|
|
642
619
|
</li>
|
@@ -649,13 +626,13 @@ methods to be chained.</p>
|
|
649
626
|
<pre class="lines">
|
650
627
|
|
651
628
|
|
652
|
-
130
|
653
629
|
131
|
654
630
|
132
|
655
|
-
133
|
631
|
+
133
|
632
|
+
134</pre>
|
656
633
|
</td>
|
657
634
|
<td>
|
658
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
635
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 131</span>
|
659
636
|
|
660
637
|
<span class='kw'>def</span> <span class='id identifier rubyid_at_least'>at_least</span><span class='lparen'>(</span><span class='id identifier rubyid_minimum_number_of_times'>minimum_number_of_times</span><span class='rparen'>)</span>
|
661
638
|
<span class='ivar'>@cardinality</span> <span class='op'>=</span> <span class='const'>Cardinality</span><span class='period'>.</span><span class='id identifier rubyid_at_least'>at_least</span><span class='lparen'>(</span><span class='id identifier rubyid_minimum_number_of_times'>minimum_number_of_times</span><span class='rparen'>)</span>
|
@@ -678,8 +655,7 @@ methods to be chained.</p>
|
|
678
655
|
</h3><div class="docstring">
|
679
656
|
<div class="discussion">
|
680
657
|
|
681
|
-
<p>Modifies expectation so that the expected method must be called at least
|
682
|
-
once.</p>
|
658
|
+
<p>Modifies expectation so that the expected method must be called at least once.</p>
|
683
659
|
|
684
660
|
|
685
661
|
</div>
|
@@ -717,8 +693,7 @@ once.</p>
|
|
717
693
|
|
718
694
|
—
|
719
695
|
<div class='inline'>
|
720
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
721
|
-
methods to be chained.</p>
|
696
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
722
697
|
</div>
|
723
698
|
|
724
699
|
</li>
|
@@ -731,13 +706,13 @@ methods to be chained.</p>
|
|
731
706
|
<pre class="lines">
|
732
707
|
|
733
708
|
|
734
|
-
148
|
735
709
|
149
|
736
710
|
150
|
737
|
-
151
|
711
|
+
151
|
712
|
+
152</pre>
|
738
713
|
</td>
|
739
714
|
<td>
|
740
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
715
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 149</span>
|
741
716
|
|
742
717
|
<span class='kw'>def</span> <span class='id identifier rubyid_at_least_once'>at_least_once</span>
|
743
718
|
<span class='id identifier rubyid_at_least'>at_least</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
|
@@ -760,8 +735,7 @@ methods to be chained.</p>
|
|
760
735
|
</h3><div class="docstring">
|
761
736
|
<div class="discussion">
|
762
737
|
|
763
|
-
<p>Modifies expectation so that the expected method must be called at most a
|
764
|
-
<code>maximum_number_of_times</code>.</p>
|
738
|
+
<p>Modifies expectation so that the expected method must be called at most a <code>maximum_number_of_times</code>.</p>
|
765
739
|
|
766
740
|
|
767
741
|
</div>
|
@@ -819,8 +793,7 @@ methods to be chained.</p>
|
|
819
793
|
|
820
794
|
—
|
821
795
|
<div class='inline'>
|
822
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
823
|
-
methods to be chained.</p>
|
796
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
824
797
|
</div>
|
825
798
|
|
826
799
|
</li>
|
@@ -833,13 +806,13 @@ methods to be chained.</p>
|
|
833
806
|
<pre class="lines">
|
834
807
|
|
835
808
|
|
836
|
-
167
|
837
809
|
168
|
838
810
|
169
|
839
|
-
170
|
811
|
+
170
|
812
|
+
171</pre>
|
840
813
|
</td>
|
841
814
|
<td>
|
842
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
815
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 168</span>
|
843
816
|
|
844
817
|
<span class='kw'>def</span> <span class='id identifier rubyid_at_most'>at_most</span><span class='lparen'>(</span><span class='id identifier rubyid_maximum_number_of_times'>maximum_number_of_times</span><span class='rparen'>)</span>
|
845
818
|
<span class='ivar'>@cardinality</span> <span class='op'>=</span> <span class='const'>Cardinality</span><span class='period'>.</span><span class='id identifier rubyid_at_most'>at_most</span><span class='lparen'>(</span><span class='id identifier rubyid_maximum_number_of_times'>maximum_number_of_times</span><span class='rparen'>)</span>
|
@@ -862,8 +835,7 @@ methods to be chained.</p>
|
|
862
835
|
</h3><div class="docstring">
|
863
836
|
<div class="discussion">
|
864
837
|
|
865
|
-
<p>Modifies expectation so that the expected method must be called at most
|
866
|
-
once.</p>
|
838
|
+
<p>Modifies expectation so that the expected method must be called at most once.</p>
|
867
839
|
|
868
840
|
|
869
841
|
</div>
|
@@ -901,8 +873,7 @@ once.</p>
|
|
901
873
|
|
902
874
|
—
|
903
875
|
<div class='inline'>
|
904
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
905
|
-
methods to be chained.</p>
|
876
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
906
877
|
</div>
|
907
878
|
|
908
879
|
</li>
|
@@ -915,13 +886,13 @@ methods to be chained.</p>
|
|
915
886
|
<pre class="lines">
|
916
887
|
|
917
888
|
|
918
|
-
185
|
919
889
|
186
|
920
890
|
187
|
921
|
-
188
|
891
|
+
188
|
892
|
+
189</pre>
|
922
893
|
</td>
|
923
894
|
<td>
|
924
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
895
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 186</span>
|
925
896
|
|
926
897
|
<span class='kw'>def</span> <span class='id identifier rubyid_at_most_once'>at_most_once</span>
|
927
898
|
<span class='id identifier rubyid_at_most'>at_most</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
|
@@ -935,7 +906,7 @@ methods to be chained.</p>
|
|
935
906
|
<div class="method_details ">
|
936
907
|
<h3 class="signature " id="in_sequence-instance_method">
|
937
908
|
|
938
|
-
#<strong>in_sequence</strong>(*sequences) ⇒ <tt><span class='object_link'><a href="" title="Mocha::Expectation (class)">Expectation</a></span></tt>
|
909
|
+
#<strong>in_sequence</strong>(sequence, *sequences) ⇒ <tt><span class='object_link'><a href="" title="Mocha::Expectation (class)">Expectation</a></span></tt>
|
939
910
|
|
940
911
|
|
941
912
|
|
@@ -944,16 +915,13 @@ methods to be chained.</p>
|
|
944
915
|
</h3><div class="docstring">
|
945
916
|
<div class="discussion">
|
946
917
|
|
947
|
-
<p>Constrains the expectation so that it must be invoked at the current point
|
948
|
-
in the <code>sequence</code>.</p>
|
918
|
+
<p>Constrains the expectation so that it must be invoked at the current point in the <code>sequence</code>.</p>
|
949
919
|
|
950
|
-
<p>To expect a sequence of invocations, write the expectations in order and
|
951
|
-
add the <tt>in_sequence(sequence)</tt> clause to each one.</p>
|
920
|
+
<p>To expect a sequence of invocations, write the expectations in order and add the <tt>in_sequence(sequence)</tt> clause to each one.</p>
|
952
921
|
|
953
922
|
<p>Expectations in a <code>sequence</code> can have any invocation count.</p>
|
954
923
|
|
955
|
-
<p>If an expectation in a sequence is stubbed, rather than expected, it can be
|
956
|
-
skipped in the <code>sequence</code>.</p>
|
924
|
+
<p>If an expectation in a sequence is stubbed, rather than expected, it can be skipped in the <code>sequence</code>.</p>
|
957
925
|
|
958
926
|
<p>An expected method can appear in multiple sequences.</p>
|
959
927
|
|
@@ -981,6 +949,22 @@ skipped in the <code>sequence</code>.</p>
|
|
981
949
|
<p class="tag_title">Parameters:</p>
|
982
950
|
<ul class="param">
|
983
951
|
|
952
|
+
<li>
|
953
|
+
|
954
|
+
<span class='name'>sequence</span>
|
955
|
+
|
956
|
+
|
957
|
+
<span class='type'>(<tt><span class='object_link'><a href="Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span></tt>)</span>
|
958
|
+
|
959
|
+
|
960
|
+
|
961
|
+
—
|
962
|
+
<div class='inline'>
|
963
|
+
<p>sequence in which expected method should appear.</p>
|
964
|
+
</div>
|
965
|
+
|
966
|
+
</li>
|
967
|
+
|
984
968
|
<li>
|
985
969
|
|
986
970
|
<span class='name'>sequences</span>
|
@@ -992,7 +976,7 @@ skipped in the <code>sequence</code>.</p>
|
|
992
976
|
|
993
977
|
—
|
994
978
|
<div class='inline'>
|
995
|
-
<p>sequences in which expected method should appear.</p>
|
979
|
+
<p>more sequences in which expected method should appear.</p>
|
996
980
|
</div>
|
997
981
|
|
998
982
|
</li>
|
@@ -1011,8 +995,7 @@ skipped in the <code>sequence</code>.</p>
|
|
1011
995
|
|
1012
996
|
—
|
1013
997
|
<div class='inline'>
|
1014
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
1015
|
-
methods to be chained.</p>
|
998
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
1016
999
|
</div>
|
1017
1000
|
|
1018
1001
|
</li>
|
@@ -1032,16 +1015,16 @@ methods to be chained.</p>
|
|
1032
1015
|
<pre class="lines">
|
1033
1016
|
|
1034
1017
|
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1018
|
+
501
|
1019
|
+
502
|
1020
|
+
503
|
1021
|
+
504</pre>
|
1039
1022
|
</td>
|
1040
1023
|
<td>
|
1041
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
1024
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 501</span>
|
1042
1025
|
|
1043
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_in_sequence'>in_sequence</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_sequences'>sequences</span><span class='rparen'>)</span>
|
1044
|
-
<span class='id identifier rubyid_sequences'>sequences</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier
|
1026
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_in_sequence'>in_sequence</span><span class='lparen'>(</span><span class='id identifier rubyid_sequence'>sequence</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_sequences'>sequences</span><span class='rparen'>)</span>
|
1027
|
+
<span class='id identifier rubyid_sequences'>sequences</span><span class='period'>.</span><span class='id identifier rubyid_unshift'>unshift</span><span class='lparen'>(</span><span class='id identifier rubyid_sequence'>sequence</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_seq'>seq</span><span class='op'>|</span> <span class='id identifier rubyid_add_in_sequence_ordering_constraint'>add_in_sequence_ordering_constraint</span><span class='lparen'>(</span><span class='id identifier rubyid_seq'>seq</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
1045
1028
|
<span class='kw'>self</span>
|
1046
1029
|
<span class='kw'>end</span></pre>
|
1047
1030
|
</td>
|
@@ -1061,9 +1044,7 @@ methods to be chained.</p>
|
|
1061
1044
|
</h3><div class="docstring">
|
1062
1045
|
<div class="discussion">
|
1063
1046
|
|
1064
|
-
<p>Modifies expectation so that when the expected method is called, it yields
|
1065
|
-
multiple times per invocation with the specified
|
1066
|
-
<code>parameter_groups</code>.</p>
|
1047
|
+
<p>Modifies expectation so that when the expected method is called, it yields multiple times per invocation with the specified <code>parameter_groups</code> (even if no block is provided, in which case yielding will result in a <code>LocalJumpError</code>).</p>
|
1067
1048
|
|
1068
1049
|
|
1069
1050
|
</div>
|
@@ -1075,32 +1056,28 @@ multiple times per invocation with the specified
|
|
1075
1056
|
|
1076
1057
|
|
1077
1058
|
<p class="example_title"><div class='inline'>
|
1078
|
-
<p>When
|
1079
|
-
block twice, the first time it passes <tt>'result_1'</tt>,
|
1080
|
-
<tt>'result_2'</tt> as the parameters, and the second time it passes
|
1081
|
-
'result_3' as the parameters.</p>
|
1059
|
+
<p>When <code>foreach</code> is called, the stub will invoke the block twice, the first time it passes ['row1_col1', 'row1_col2'] as the parameters, and the second time it passes ['row2_col1', ''] as the parameters.</p>
|
1082
1060
|
</div></p>
|
1083
1061
|
|
1084
|
-
<pre class="example code"><code><span class='id identifier
|
1085
|
-
<span class='id identifier
|
1086
|
-
<span class='id identifier
|
1087
|
-
<span class='id identifier
|
1088
|
-
<span class='id identifier
|
1062
|
+
<pre class="example code"><code><span class='id identifier rubyid_csv'>csv</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
1063
|
+
<span class='id identifier rubyid_csv'>csv</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:foreach</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'>"</span><span class='tstring_content'>path/to/file.csv</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_multiple_yields'>multiple_yields</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>row1_col1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>row1_col2</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>row2_col1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
1064
|
+
<span class='id identifier rubyid_rows'>rows</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
1065
|
+
<span class='id identifier rubyid_csv'>csv</span><span class='period'>.</span><span class='id identifier rubyid_foreach'>foreach</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_row'>row</span><span class='op'>|</span> <span class='id identifier rubyid_rows'>rows</span> <span class='op'><<</span> <span class='id identifier rubyid_row'>row</span> <span class='rbrace'>}</span>
|
1066
|
+
<span class='id identifier rubyid_rows'>rows</span> <span class='comment'># => [['row1_col1', 'row1_col2'], ['row2_col1', '']]</span></code></pre>
|
1089
1067
|
|
1090
1068
|
|
1091
1069
|
<p class="example_title"><div class='inline'>
|
1092
|
-
<p>Yield different groups of parameters on different invocations of the
|
1093
|
-
expected method.</p>
|
1070
|
+
<p>Yield different groups of parameters on different invocations of the expected method. Simulating a situation where the CSV file at 'path/to/file.csv' has been modified between the two calls to <code>foreach</code>.</p>
|
1094
1071
|
</div></p>
|
1095
1072
|
|
1096
|
-
<pre class="example code"><code><span class='id identifier
|
1097
|
-
<span class='id identifier
|
1098
|
-
<span class='id identifier
|
1099
|
-
<span class='id identifier
|
1100
|
-
<span class='id identifier
|
1101
|
-
</span><span class='id identifier
|
1102
|
-
</span><span class='id identifier
|
1103
|
-
</span><span class='id identifier
|
1073
|
+
<pre class="example code"><code><span class='id identifier rubyid_csv'>csv</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
1074
|
+
<span class='id identifier rubyid_csv'>csv</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:foreach</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'>"</span><span class='tstring_content'>path/to/file.csv</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_multiple_yields'>multiple_yields</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>old_row1_col1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>old_row1_col2</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>old_row2_col1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_then'>then</span><span class='period'>.</span><span class='id identifier rubyid_multiple_yields'>multiple_yields</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>new_row1_col1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>new_row2_col1</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>new_row2_col2</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
1075
|
+
<span class='id identifier rubyid_rows_from_first_invocation'>rows_from_first_invocation</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
1076
|
+
<span class='id identifier rubyid_rows_from_second_invocation'>rows_from_second_invocation</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
1077
|
+
<span class='id identifier rubyid_csv'>csv</span><span class='period'>.</span><span class='id identifier rubyid_foreach'>foreach</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_row'>row</span><span class='op'>|</span> <span class='id identifier rubyid_rows_from_first_invocation'>rows_from_first_invocation</span> <span class='op'><<</span> <span class='id identifier rubyid_row'>row</span> <span class='rbrace'>}</span> <span class='comment'># first invocation
|
1078
|
+
</span><span class='id identifier rubyid_csv'>csv</span><span class='period'>.</span><span class='id identifier rubyid_foreach'>foreach</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_row'>row</span><span class='op'>|</span> <span class='id identifier rubyid_rows_from_second_invocation'>rows_from_second_invocation</span> <span class='op'><<</span> <span class='id identifier rubyid_row'>row</span> <span class='rbrace'>}</span> <span class='comment'># second invocation
|
1079
|
+
</span><span class='id identifier rubyid_rows_from_first_invocation'>rows_from_first_invocation</span> <span class='comment'># => [['old_row1_col1', 'old_row1_col2'], ['old_row2_col1', '']]
|
1080
|
+
</span><span class='id identifier rubyid_rows_from_second_invocation'>rows_from_second_invocation</span> <span class='comment'># => [['new_row1_col1', ''], ['new_row2_col1', 'new_row2_col2']]</span></code></pre>
|
1104
1081
|
|
1105
1082
|
</div>
|
1106
1083
|
<p class="tag_title">Parameters:</p>
|
@@ -1117,9 +1094,7 @@ expected method.</p>
|
|
1117
1094
|
|
1118
1095
|
—
|
1119
1096
|
<div class='inline'>
|
1120
|
-
<p>each element of <code>parameter_groups</code> should iself be an
|
1121
|
-
<code>Array</code> representing the parameters to be passed to the block
|
1122
|
-
for a single yield.</p>
|
1097
|
+
<p>each element of <code>parameter_groups</code> should iself be an <code>Array</code> representing the parameters to be passed to the block for a single yield.</p>
|
1123
1098
|
</div>
|
1124
1099
|
|
1125
1100
|
</li>
|
@@ -1138,8 +1113,7 @@ for a single yield.</p>
|
|
1138
1113
|
|
1139
1114
|
—
|
1140
1115
|
<div class='inline'>
|
1141
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
1142
|
-
methods to be chained.</p>
|
1116
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
1143
1117
|
</div>
|
1144
1118
|
|
1145
1119
|
</li>
|
@@ -1159,13 +1133,13 @@ methods to be chained.</p>
|
|
1159
1133
|
<pre class="lines">
|
1160
1134
|
|
1161
1135
|
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1136
|
+
285
|
1137
|
+
286
|
1138
|
+
287
|
1139
|
+
288</pre>
|
1166
1140
|
</td>
|
1167
1141
|
<td>
|
1168
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
1142
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 285</span>
|
1169
1143
|
|
1170
1144
|
<span class='kw'>def</span> <span class='id identifier rubyid_multiple_yields'>multiple_yields</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_parameter_groups'>parameter_groups</span><span class='rparen'>)</span>
|
1171
1145
|
<span class='ivar'>@yield_parameters</span><span class='period'>.</span><span class='id identifier rubyid_multiple_add'>multiple_add</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_parameter_groups'>parameter_groups</span><span class='rparen'>)</span>
|
@@ -1225,8 +1199,7 @@ methods to be chained.</p>
|
|
1225
1199
|
|
1226
1200
|
—
|
1227
1201
|
<div class='inline'>
|
1228
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
1229
|
-
methods to be chained.</p>
|
1202
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
1230
1203
|
</div>
|
1231
1204
|
|
1232
1205
|
</li>
|
@@ -1239,13 +1212,13 @@ methods to be chained.</p>
|
|
1239
1212
|
<pre class="lines">
|
1240
1213
|
|
1241
1214
|
|
1242
|
-
110
|
1243
1215
|
111
|
1244
1216
|
112
|
1245
|
-
113
|
1217
|
+
113
|
1218
|
+
114</pre>
|
1246
1219
|
</td>
|
1247
1220
|
<td>
|
1248
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
1221
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 111</span>
|
1249
1222
|
|
1250
1223
|
<span class='kw'>def</span> <span class='id identifier rubyid_never'>never</span>
|
1251
1224
|
<span class='ivar'>@cardinality</span> <span class='op'>=</span> <span class='const'>Cardinality</span><span class='period'>.</span><span class='id identifier rubyid_exactly'>exactly</span><span class='lparen'>(</span><span class='int'>0</span><span class='rparen'>)</span>
|
@@ -1268,11 +1241,9 @@ methods to be chained.</p>
|
|
1268
1241
|
</h3><div class="docstring">
|
1269
1242
|
<div class="discussion">
|
1270
1243
|
|
1271
|
-
<p>Modifies expectation so that the expected method must be called exactly
|
1272
|
-
once.</p>
|
1244
|
+
<p>Modifies expectation so that the expected method must be called exactly once.</p>
|
1273
1245
|
|
1274
|
-
<p>Note that this is the default behaviour for an expectation, but you may
|
1275
|
-
wish to use it for clarity/emphasis.</p>
|
1246
|
+
<p>Note that this is the default behaviour for an expectation, but you may wish to use it for clarity/emphasis.</p>
|
1276
1247
|
|
1277
1248
|
|
1278
1249
|
</div>
|
@@ -1315,8 +1286,7 @@ wish to use it for clarity/emphasis.</p>
|
|
1315
1286
|
|
1316
1287
|
—
|
1317
1288
|
<div class='inline'>
|
1318
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
1319
|
-
methods to be chained.</p>
|
1289
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
1320
1290
|
</div>
|
1321
1291
|
|
1322
1292
|
</li>
|
@@ -1329,13 +1299,13 @@ methods to be chained.</p>
|
|
1329
1299
|
<pre class="lines">
|
1330
1300
|
|
1331
1301
|
|
1332
|
-
93
|
1333
1302
|
94
|
1334
1303
|
95
|
1335
|
-
96
|
1304
|
+
96
|
1305
|
+
97</pre>
|
1336
1306
|
</td>
|
1337
1307
|
<td>
|
1338
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
1308
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 94</span>
|
1339
1309
|
|
1340
1310
|
<span class='kw'>def</span> <span class='id identifier rubyid_once'>once</span>
|
1341
1311
|
<span class='ivar'>@cardinality</span> <span class='op'>=</span> <span class='const'>Cardinality</span><span class='period'>.</span><span class='id identifier rubyid_exactly'>exactly</span><span class='lparen'>(</span><span class='int'>1</span><span class='rparen'>)</span>
|
@@ -1364,9 +1334,7 @@ methods to be chained.</p>
|
|
1364
1334
|
</h3><div class="docstring">
|
1365
1335
|
<div class="discussion">
|
1366
1336
|
|
1367
|
-
<p>Modifies expectation so that when the expected method is called, it raises
|
1368
|
-
the specified <code>exception</code> with the specified
|
1369
|
-
<code>message</code> i.e. calls <tt>Kernel#raise(exception, message)</tt>.</p>
|
1337
|
+
<p>Modifies expectation so that when the expected method is called, it raises the specified <code>exception</code> with the specified <code>message</code> i.e. calls <tt>Kernel#raise(exception, message)</tt>.</p>
|
1370
1338
|
|
1371
1339
|
|
1372
1340
|
</div>
|
@@ -1387,8 +1355,7 @@ the specified <code>exception</code> with the specified
|
|
1387
1355
|
|
1388
1356
|
|
1389
1357
|
<p class="example_title"><div class='inline'>
|
1390
|
-
<p>Raise custom exception with extra constructor parameters by passing in an
|
1391
|
-
instance of the exception.</p>
|
1358
|
+
<p>Raise custom exception with extra constructor parameters by passing in an instance of the exception.</p>
|
1392
1359
|
</div></p>
|
1393
1360
|
|
1394
1361
|
<pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
@@ -1397,8 +1364,7 @@ instance of the exception.</p>
|
|
1397
1364
|
|
1398
1365
|
|
1399
1366
|
<p class="example_title"><div class='inline'>
|
1400
|
-
<p>Raise different exceptions on consecutive invocations of the expected
|
1401
|
-
method.</p>
|
1367
|
+
<p>Raise different exceptions on consecutive invocations of the expected method.</p>
|
1402
1368
|
</div></p>
|
1403
1369
|
|
1404
1370
|
<pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
@@ -1408,8 +1374,7 @@ method.</p>
|
|
1408
1374
|
|
1409
1375
|
|
1410
1376
|
<p class="example_title"><div class='inline'>
|
1411
|
-
<p>Raise an exception on first invocation of expected method and then return
|
1412
|
-
values on subsequent invocations.</p>
|
1377
|
+
<p>Raise an exception on first invocation of expected method and then return values on subsequent invocations.</p>
|
1413
1378
|
</div></p>
|
1414
1379
|
|
1415
1380
|
<pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
@@ -1472,8 +1437,7 @@ values on subsequent invocations.</p>
|
|
1472
1437
|
|
1473
1438
|
—
|
1474
1439
|
<div class='inline'>
|
1475
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
1476
|
-
methods to be chained.</p>
|
1440
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
1477
1441
|
</div>
|
1478
1442
|
|
1479
1443
|
</li>
|
@@ -1495,13 +1459,13 @@ methods to be chained.</p>
|
|
1495
1459
|
<pre class="lines">
|
1496
1460
|
|
1497
1461
|
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1462
|
+
372
|
1463
|
+
373
|
1464
|
+
374
|
1465
|
+
375</pre>
|
1502
1466
|
</td>
|
1503
1467
|
<td>
|
1504
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
1468
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 372</span>
|
1505
1469
|
|
1506
1470
|
<span class='kw'>def</span> <span class='id identifier rubyid_raises'>raises</span><span class='lparen'>(</span><span class='id identifier rubyid_exception'>exception</span> <span class='op'>=</span> <span class='const'>RuntimeError</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
1507
1471
|
<span class='ivar'>@return_values</span> <span class='op'>+=</span> <span class='const'>ReturnValues</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>ExceptionRaiser</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_exception'>exception</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
@@ -1528,8 +1492,7 @@ methods to be chained.</p>
|
|
1528
1492
|
</h3><div class="docstring">
|
1529
1493
|
<div class="discussion">
|
1530
1494
|
|
1531
|
-
<p>Modifies expectation so that when the expected method is called, it returns
|
1532
|
-
the specified <code>value</code>.</p>
|
1495
|
+
<p>Modifies expectation so that when the expected method is called, it returns the specified <code>value</code>.</p>
|
1533
1496
|
|
1534
1497
|
|
1535
1498
|
</div>
|
@@ -1583,8 +1546,7 @@ the specified <code>value</code>.</p>
|
|
1583
1546
|
|
1584
1547
|
|
1585
1548
|
<p class="example_title"><div class='inline'>
|
1586
|
-
<p>Note that in Ruby a method returning multiple values is exactly equivalent
|
1587
|
-
to a method returning an <code>Array</code> of those values.</p>
|
1549
|
+
<p>Note that in Ruby a method returning multiple values is exactly equivalent to a method returning an <code>Array</code> of those values.</p>
|
1588
1550
|
</div></p>
|
1589
1551
|
|
1590
1552
|
<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>
|
@@ -1682,8 +1644,7 @@ to a method returning an <code>Array</code> of those values.</p>
|
|
1682
1644
|
|
1683
1645
|
—
|
1684
1646
|
<div class='inline'>
|
1685
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
1686
|
-
methods to be chained.</p>
|
1647
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
1687
1648
|
</div>
|
1688
1649
|
|
1689
1650
|
</li>
|
@@ -1703,13 +1664,13 @@ methods to be chained.</p>
|
|
1703
1664
|
<pre class="lines">
|
1704
1665
|
|
1705
1666
|
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1667
|
+
332
|
1668
|
+
333
|
1669
|
+
334
|
1670
|
+
335</pre>
|
1710
1671
|
</td>
|
1711
1672
|
<td>
|
1712
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
1673
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 332</span>
|
1713
1674
|
|
1714
1675
|
<span class='kw'>def</span> <span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span>
|
1715
1676
|
<span class='ivar'>@return_values</span> <span class='op'>+=</span> <span class='const'>ReturnValues</span><span class='period'>.</span><span class='id identifier rubyid_build'>build</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span>
|
@@ -1736,8 +1697,7 @@ methods to be chained.</p>
|
|
1736
1697
|
</h3><div class="docstring">
|
1737
1698
|
<div class="discussion">
|
1738
1699
|
|
1739
|
-
<p>Returns the same expectation, thereby allowing invocations of other
|
1740
|
-
<span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
1700
|
+
<p>Returns the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
1741
1701
|
|
1742
1702
|
|
1743
1703
|
</div>
|
@@ -1749,8 +1709,7 @@ methods to be chained.</p>
|
|
1749
1709
|
|
1750
1710
|
|
1751
1711
|
<p class="example_title"><div class='inline'>
|
1752
|
-
<p>Using <span class='object_link'><a href="#then-instance_method" title="Mocha::Expectation#then (method)">#then</a></span> as syntactic sugar when specifying values to be returned and
|
1753
|
-
exceptions to be raised on consecutive invocations of the expected method.</p>
|
1712
|
+
<p>Using <span class='object_link'><a href="#then-instance_method" title="Mocha::Expectation#then (method)">#then</a></span> as syntactic sugar when specifying values to be returned and exceptions to be raised on consecutive invocations of the expected method.</p>
|
1754
1713
|
</div></p>
|
1755
1714
|
|
1756
1715
|
<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>
|
@@ -1762,8 +1721,7 @@ exceptions to be raised on consecutive invocations of the expected method.</p>
|
|
1762
1721
|
|
1763
1722
|
|
1764
1723
|
<p class="example_title"><div class='inline'>
|
1765
|
-
<p>Using <span class='object_link'><a href="#then-instance_method" title="Mocha::Expectation#then (method)">#then</a></span> to change the <code>state</code> of a
|
1766
|
-
<code>state_machine</code> on the invocation of an expected method.</p>
|
1724
|
+
<p>Using <span class='object_link'><a href="#then-instance_method" title="Mocha::Expectation#then (method)">#then</a></span> to change the <code>state</code> of a <code>state_machine</code> on the invocation of an expected method.</p>
|
1767
1725
|
</div></p>
|
1768
1726
|
|
1769
1727
|
<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'>'</span><span class='tstring_content'>power</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>off</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
@@ -1787,8 +1745,7 @@ exceptions to be raised on consecutive invocations of the expected method.</p>
|
|
1787
1745
|
<div class="docstring">
|
1788
1746
|
<div class="discussion">
|
1789
1747
|
|
1790
|
-
<p>Used as syntactic sugar to improve readability. It has no effect on state
|
1791
|
-
of the expectation.</p>
|
1748
|
+
<p>Used as syntactic sugar to improve readability. It has no effect on state of the expectation.</p>
|
1792
1749
|
|
1793
1750
|
|
1794
1751
|
</div>
|
@@ -1805,8 +1762,7 @@ of the expectation.</p>
|
|
1805
1762
|
<div class="docstring">
|
1806
1763
|
<div class="discussion">
|
1807
1764
|
|
1808
|
-
<p>Used to change the <code>state_machine</code> to the state specified by
|
1809
|
-
<code>state_name</code> when the expected invocation occurs.</p>
|
1765
|
+
<p>Used to change the <code>state_machine</code> to the state specified by <code>state_name</code> when the expected invocation occurs.</p>
|
1810
1766
|
|
1811
1767
|
|
1812
1768
|
</div>
|
@@ -1826,9 +1782,7 @@ of the expectation.</p>
|
|
1826
1782
|
|
1827
1783
|
—
|
1828
1784
|
<div class='inline'>
|
1829
|
-
<p>provides a mechanism to change the <code>state_machine</code> into the
|
1830
|
-
state specified by <code>state_name</code> when the expected method is
|
1831
|
-
invoked.</p>
|
1785
|
+
<p>provides a mechanism to change the <code>state_machine</code> into the state specified by <code>state_name</code> when the expected method is invoked.</p>
|
1832
1786
|
</div>
|
1833
1787
|
|
1834
1788
|
</li>
|
@@ -1864,8 +1818,7 @@ invoked.</p>
|
|
1864
1818
|
|
1865
1819
|
—
|
1866
1820
|
<div class='inline'>
|
1867
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
1868
|
-
methods to be chained.</p>
|
1821
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
1869
1822
|
</div>
|
1870
1823
|
|
1871
1824
|
</li>
|
@@ -1878,16 +1831,16 @@ methods to be chained.</p>
|
|
1878
1831
|
<pre class="lines">
|
1879
1832
|
|
1880
1833
|
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1834
|
+
446
|
1835
|
+
447
|
1836
|
+
448
|
1837
|
+
449
|
1838
|
+
450
|
1839
|
+
451
|
1840
|
+
452</pre>
|
1888
1841
|
</td>
|
1889
1842
|
<td>
|
1890
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
1843
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 446</span>
|
1891
1844
|
|
1892
1845
|
<span class='kw'>def</span> <span class='kw'>then</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_parameters'>parameters</span><span class='rparen'>)</span>
|
1893
1846
|
<span class='kw'>if</span> <span class='id identifier rubyid_parameters'>parameters</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>==</span> <span class='int'>1</span>
|
@@ -1917,9 +1870,7 @@ methods to be chained.</p>
|
|
1917
1870
|
</h3><div class="docstring">
|
1918
1871
|
<div class="discussion">
|
1919
1872
|
|
1920
|
-
<p>Modifies expectation so that when the expected method is called, it throws
|
1921
|
-
the specified <code>tag</code> with the specific return value
|
1922
|
-
<code>object</code> i.e. calls <tt>Kernel#throw(tag, object)</tt>.</p>
|
1873
|
+
<p>Modifies expectation so that when the expected method is called, it throws the specified <code>tag</code> with the specific return value <code>object</code> i.e. calls <tt>Kernel#throw(tag, object)</tt>.</p>
|
1923
1874
|
|
1924
1875
|
|
1925
1876
|
</div>
|
@@ -1959,8 +1910,7 @@ the specified <code>tag</code> with the specific return value
|
|
1959
1910
|
|
1960
1911
|
|
1961
1912
|
<p class="example_title"><div class='inline'>
|
1962
|
-
<p>Throw tag on first invocation of expected method and then return values for
|
1963
|
-
subsequent invocations.</p>
|
1913
|
+
<p>Throw tag on first invocation of expected method and then return values for subsequent invocations.</p>
|
1964
1914
|
</div></p>
|
1965
1915
|
|
1966
1916
|
<pre class="example code"><code><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
@@ -2021,8 +1971,7 @@ subsequent invocations.</p>
|
|
2021
1971
|
|
2022
1972
|
—
|
2023
1973
|
<div class='inline'>
|
2024
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
2025
|
-
methods to be chained.</p>
|
1974
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
2026
1975
|
</div>
|
2027
1976
|
|
2028
1977
|
</li>
|
@@ -2044,13 +1993,13 @@ methods to be chained.</p>
|
|
2044
1993
|
<pre class="lines">
|
2045
1994
|
|
2046
1995
|
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
1996
|
+
411
|
1997
|
+
412
|
1998
|
+
413
|
1999
|
+
414</pre>
|
2051
2000
|
</td>
|
2052
2001
|
<td>
|
2053
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
2002
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 411</span>
|
2054
2003
|
|
2055
2004
|
<span class='kw'>def</span> <span class='id identifier rubyid_throws'>throws</span><span class='lparen'>(</span><span class='id identifier rubyid_tag'>tag</span><span class='comma'>,</span> <span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
2056
2005
|
<span class='ivar'>@return_values</span> <span class='op'>+=</span> <span class='const'>ReturnValues</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>Thrower</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_tag'>tag</span><span class='comma'>,</span> <span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
@@ -2073,8 +2022,7 @@ methods to be chained.</p>
|
|
2073
2022
|
</h3><div class="docstring">
|
2074
2023
|
<div class="discussion">
|
2075
2024
|
|
2076
|
-
<p>Modifies expectation so that the number of calls to the expected method
|
2077
|
-
must be within a specific <code>range</code>.</p>
|
2025
|
+
<p>Modifies expectation so that the number of calls to the expected method must be within a specific <code>range</code>.</p>
|
2078
2026
|
|
2079
2027
|
|
2080
2028
|
</div>
|
@@ -2148,8 +2096,7 @@ must be within a specific <code>range</code>.</p>
|
|
2148
2096
|
|
2149
2097
|
—
|
2150
2098
|
<div class='inline'>
|
2151
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
2152
|
-
methods to be chained.</p>
|
2099
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
2153
2100
|
</div>
|
2154
2101
|
|
2155
2102
|
</li>
|
@@ -2162,13 +2109,13 @@ methods to be chained.</p>
|
|
2162
2109
|
<pre class="lines">
|
2163
2110
|
|
2164
2111
|
|
2165
|
-
42
|
2166
2112
|
43
|
2167
2113
|
44
|
2168
|
-
45
|
2114
|
+
45
|
2115
|
+
46</pre>
|
2169
2116
|
</td>
|
2170
2117
|
<td>
|
2171
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
2118
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 43</span>
|
2172
2119
|
|
2173
2120
|
<span class='kw'>def</span> <span class='id identifier rubyid_times'>times</span><span class='lparen'>(</span><span class='id identifier rubyid_range'>range</span><span class='rparen'>)</span>
|
2174
2121
|
<span class='ivar'>@cardinality</span> <span class='op'>=</span> <span class='const'>Cardinality</span><span class='period'>.</span><span class='id identifier rubyid_times'>times</span><span class='lparen'>(</span><span class='id identifier rubyid_range'>range</span><span class='rparen'>)</span>
|
@@ -2191,8 +2138,7 @@ methods to be chained.</p>
|
|
2191
2138
|
</h3><div class="docstring">
|
2192
2139
|
<div class="discussion">
|
2193
2140
|
|
2194
|
-
<p>Modifies expectation so that the expected method must be called exactly
|
2195
|
-
twice.</p>
|
2141
|
+
<p>Modifies expectation so that the expected method must be called exactly twice.</p>
|
2196
2142
|
|
2197
2143
|
|
2198
2144
|
</div>
|
@@ -2238,8 +2184,7 @@ twice.</p>
|
|
2238
2184
|
|
2239
2185
|
—
|
2240
2186
|
<div class='inline'>
|
2241
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
2242
|
-
methods to be chained.</p>
|
2187
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
2243
2188
|
</div>
|
2244
2189
|
|
2245
2190
|
</li>
|
@@ -2252,13 +2197,13 @@ methods to be chained.</p>
|
|
2252
2197
|
<pre class="lines">
|
2253
2198
|
|
2254
2199
|
|
2255
|
-
68
|
2256
2200
|
69
|
2257
2201
|
70
|
2258
|
-
71
|
2202
|
+
71
|
2203
|
+
72</pre>
|
2259
2204
|
</td>
|
2260
2205
|
<td>
|
2261
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
2206
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 69</span>
|
2262
2207
|
|
2263
2208
|
<span class='kw'>def</span> <span class='id identifier rubyid_twice'>twice</span>
|
2264
2209
|
<span class='ivar'>@cardinality</span> <span class='op'>=</span> <span class='const'>Cardinality</span><span class='period'>.</span><span class='id identifier rubyid_exactly'>exactly</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span>
|
@@ -2281,9 +2226,7 @@ methods to be chained.</p>
|
|
2281
2226
|
</h3><div class="docstring">
|
2282
2227
|
<div class="discussion">
|
2283
2228
|
|
2284
|
-
<p>Constrains the expectation to occur only when the
|
2285
|
-
<code>state_machine</code> is in the state specified by
|
2286
|
-
<code>state_name</code>.</p>
|
2229
|
+
<p>Constrains the expectation to occur only when the <code>state_machine</code> is in the state specified by <code>state_name</code>.</p>
|
2287
2230
|
|
2288
2231
|
|
2289
2232
|
</div>
|
@@ -2295,8 +2238,7 @@ methods to be chained.</p>
|
|
2295
2238
|
|
2296
2239
|
|
2297
2240
|
<p class="example_title"><div class='inline'>
|
2298
|
-
<p>Using <span class='object_link'><a href="#when-instance_method" title="Mocha::Expectation#when (method)">#when</a></span> to only allow invocation of methods when “power” state
|
2299
|
-
machine is in the “on” state.</p>
|
2241
|
+
<p>Using <span class='object_link'><a href="#when-instance_method" title="Mocha::Expectation#when (method)">#when</a></span> to only allow invocation of methods when “power” state machine is in the “on” state.</p>
|
2300
2242
|
</div></p>
|
2301
2243
|
|
2302
2244
|
<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'>'</span><span class='tstring_content'>power</span><span class='tstring_end'>'</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'>'</span><span class='tstring_content'>off</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
@@ -2324,9 +2266,7 @@ machine is in the “on” state.</p>
|
|
2324
2266
|
|
2325
2267
|
—
|
2326
2268
|
<div class='inline'>
|
2327
|
-
<p>provides a mechanism to determine whether the <code>state_machine</code> is
|
2328
|
-
in the state specified by <code>state_name</code> when the expected method
|
2329
|
-
is invoked.</p>
|
2269
|
+
<p>provides a mechanism to determine whether the <code>state_machine</code> is in the state specified by <code>state_name</code> when the expected method is invoked.</p>
|
2330
2270
|
</div>
|
2331
2271
|
|
2332
2272
|
</li>
|
@@ -2345,8 +2285,7 @@ is invoked.</p>
|
|
2345
2285
|
|
2346
2286
|
—
|
2347
2287
|
<div class='inline'>
|
2348
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
2349
|
-
methods to be chained.</p>
|
2288
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
2350
2289
|
</div>
|
2351
2290
|
|
2352
2291
|
</li>
|
@@ -2370,13 +2309,13 @@ methods to be chained.</p>
|
|
2370
2309
|
<pre class="lines">
|
2371
2310
|
|
2372
2311
|
|
2373
|
-
|
2374
|
-
|
2375
|
-
|
2376
|
-
|
2312
|
+
473
|
2313
|
+
474
|
2314
|
+
475
|
2315
|
+
476</pre>
|
2377
2316
|
</td>
|
2378
2317
|
<td>
|
2379
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
2318
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 473</span>
|
2380
2319
|
|
2381
2320
|
<span class='kw'>def</span> <span class='kw'>when</span><span class='lparen'>(</span><span class='id identifier rubyid_state_predicate'>state_predicate</span><span class='rparen'>)</span>
|
2382
2321
|
<span class='id identifier rubyid_add_ordering_constraint'>add_ordering_constraint</span><span class='lparen'>(</span><span class='const'>InStateOrderingConstraint</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_state_predicate'>state_predicate</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
@@ -2399,8 +2338,7 @@ methods to be chained.</p>
|
|
2399
2338
|
</h3><div class="docstring">
|
2400
2339
|
<div class="discussion">
|
2401
2340
|
|
2402
|
-
<p>Modifies expectation so that the expected method must be called with
|
2403
|
-
<code>expected_parameters</code>.</p>
|
2341
|
+
<p>Modifies expectation so that the expected method must be called with <code>expected_parameters</code>.</p>
|
2404
2342
|
|
2405
2343
|
<p>May be used with parameter matchers in <span class='object_link'><a href="ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span>.</p>
|
2406
2344
|
|
@@ -2532,8 +2470,7 @@ methods to be chained.</p>
|
|
2532
2470
|
|
2533
2471
|
—
|
2534
2472
|
<div class='inline'>
|
2535
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
2536
|
-
methods to be chained.</p>
|
2473
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
2537
2474
|
</div>
|
2538
2475
|
|
2539
2476
|
</li>
|
@@ -2546,13 +2483,13 @@ methods to be chained.</p>
|
|
2546
2483
|
<pre class="lines">
|
2547
2484
|
|
2548
2485
|
|
2549
|
-
221
|
2550
2486
|
222
|
2551
2487
|
223
|
2552
|
-
224
|
2488
|
+
224
|
2489
|
+
225</pre>
|
2553
2490
|
</td>
|
2554
2491
|
<td>
|
2555
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
2492
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 222</span>
|
2556
2493
|
|
2557
2494
|
<span class='kw'>def</span> <span class='id identifier rubyid_with'>with</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_expected_parameters'>expected_parameters</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_matching_block'>matching_block</span><span class='rparen'>)</span>
|
2558
2495
|
<span class='ivar'>@parameters_matcher</span> <span class='op'>=</span> <span class='const'>ParametersMatcher</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_expected_parameters'>expected_parameters</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_matching_block'>matching_block</span><span class='rparen'>)</span>
|
@@ -2575,11 +2512,9 @@ methods to be chained.</p>
|
|
2575
2512
|
</h3><div class="docstring">
|
2576
2513
|
<div class="discussion">
|
2577
2514
|
|
2578
|
-
<p>Modifies expectation so that when the expected method is called, it yields
|
2579
|
-
with the specified <code>parameters</code>.</p>
|
2515
|
+
<p>Modifies expectation so that when the expected method is called, it yields with the specified <code>parameters</code> (even if no block is provided, in which case yielding will result in a <code>LocalJumpError</code>).</p>
|
2580
2516
|
|
2581
|
-
<p>May be called multiple times on the same expectation for consecutive
|
2582
|
-
invocations.</p>
|
2517
|
+
<p>May be called multiple times on the same expectation for consecutive invocations.</p>
|
2583
2518
|
|
2584
2519
|
|
2585
2520
|
</div>
|
@@ -2590,29 +2525,40 @@ invocations.</p>
|
|
2590
2525
|
<p class="tag_title">Examples:</p>
|
2591
2526
|
|
2592
2527
|
|
2528
|
+
<p class="example_title"><div class='inline'>
|
2529
|
+
<p>Yield when expected method is invoked.</p>
|
2530
|
+
</div></p>
|
2531
|
+
|
2532
|
+
<pre class="example code"><code><span class='id identifier rubyid_benchmark'>benchmark</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
2533
|
+
<span class='id identifier rubyid_benchmark'>benchmark</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:measure</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_yields'>yields</span><span class='period'>.</span><span class='id identifier rubyid_then'>then</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0.350000 0.400000 0.750000 ( 0.835234)</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
2534
|
+
<span class='id identifier rubyid_yielded'>yielded</span> <span class='op'>=</span> <span class='kw'>false</span>
|
2535
|
+
<span class='id identifier rubyid_returned_value'>returned_value</span> <span class='op'>=</span> <span class='id identifier rubyid_benchmark'>benchmark</span><span class='period'>.</span><span class='id identifier rubyid_measure'>measure</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_yielded'>yielded</span> <span class='op'>=</span> <span class='kw'>true</span> <span class='rbrace'>}</span>
|
2536
|
+
<span class='id identifier rubyid_yielded'>yielded</span> <span class='comment'># => true
|
2537
|
+
</span><span class='id identifier rubyid_returned_value'>returned_value</span> <span class='comment'># => '0.350000 0.400000 0.750000 ( 0.835234)'</span></code></pre>
|
2538
|
+
|
2539
|
+
|
2593
2540
|
<p class="example_title"><div class='inline'>
|
2594
2541
|
<p>Yield parameters when expected method is invoked.</p>
|
2595
2542
|
</div></p>
|
2596
2543
|
|
2597
|
-
<pre class="example code"><code><span class='id identifier
|
2598
|
-
<span class='id identifier
|
2599
|
-
<span class='id identifier
|
2600
|
-
<span class='id identifier
|
2601
|
-
<span class='id identifier
|
2544
|
+
<pre class="example code"><code><span class='id identifier rubyid_fibonacci'>fibonacci</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
2545
|
+
<span class='id identifier rubyid_fibonacci'>fibonacci</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:next_pair</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_yields'>yields</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rparen'>)</span>
|
2546
|
+
<span class='id identifier rubyid_sum'>sum</span> <span class='op'>=</span> <span class='int'>0</span>
|
2547
|
+
<span class='id identifier rubyid_fibonacci'>fibonacci</span><span class='period'>.</span><span class='id identifier rubyid_next_pair'>next_pair</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span> <span class='id identifier rubyid_second'>second</span><span class='op'>|</span> <span class='id identifier rubyid_sum'>sum</span> <span class='op'>=</span> <span class='id identifier rubyid_first'>first</span> <span class='op'>+</span> <span class='id identifier rubyid_second'>second</span> <span class='rbrace'>}</span>
|
2548
|
+
<span class='id identifier rubyid_sum'>sum</span> <span class='comment'># => 1</span></code></pre>
|
2602
2549
|
|
2603
2550
|
|
2604
2551
|
<p class="example_title"><div class='inline'>
|
2605
2552
|
<p>Yield different parameters on different invocations of the expected method.</p>
|
2606
2553
|
</div></p>
|
2607
2554
|
|
2608
|
-
<pre class="example code"><code><span class='id identifier
|
2609
|
-
<span class='id identifier
|
2610
|
-
<span class='id identifier
|
2611
|
-
<span class='id identifier
|
2612
|
-
<span class='id identifier
|
2613
|
-
</span><span class='id identifier
|
2614
|
-
|
2615
|
-
</span><span class='id identifier rubyid_yielded_values_from_second_invocation'>yielded_values_from_second_invocation</span> <span class='comment'># => [2]</span></code></pre>
|
2555
|
+
<pre class="example code"><code><span class='id identifier rubyid_fibonacci'>fibonacci</span> <span class='op'>=</span> <span class='id identifier rubyid_mock'>mock</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
2556
|
+
<span class='id identifier rubyid_fibonacci'>fibonacci</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:next_pair</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_yields'>yields</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>1</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_then'>then</span><span class='period'>.</span><span class='id identifier rubyid_yields'>yields</span><span class='lparen'>(</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>1</span><span class='rparen'>)</span>
|
2557
|
+
<span class='id identifier rubyid_sum'>sum</span> <span class='op'>=</span> <span class='int'>0</span>
|
2558
|
+
<span class='id identifier rubyid_fibonacci'>fibonacci</span><span class='period'>.</span><span class='id identifier rubyid_next_pair'>next_pair</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span> <span class='id identifier rubyid_second'>second</span><span class='op'>|</span> <span class='id identifier rubyid_sum'>sum</span> <span class='op'>=</span> <span class='id identifier rubyid_first'>first</span> <span class='op'>+</span> <span class='id identifier rubyid_second'>second</span> <span class='rbrace'>}</span>
|
2559
|
+
<span class='id identifier rubyid_sum'>sum</span> <span class='comment'># => 1
|
2560
|
+
</span><span class='id identifier rubyid_fibonacci'>fibonacci</span><span class='period'>.</span><span class='id identifier rubyid_next_pair'>next_pair</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span> <span class='id identifier rubyid_second'>second</span><span class='op'>|</span> <span class='id identifier rubyid_sum'>sum</span> <span class='op'>=</span> <span class='id identifier rubyid_first'>first</span> <span class='op'>+</span> <span class='id identifier rubyid_second'>second</span> <span class='rbrace'>}</span>
|
2561
|
+
<span class='id identifier rubyid_sum'>sum</span> <span class='comment'># => 2</span></code></pre>
|
2616
2562
|
|
2617
2563
|
</div>
|
2618
2564
|
<p class="tag_title">Parameters:</p>
|
@@ -2648,8 +2594,7 @@ invocations.</p>
|
|
2648
2594
|
|
2649
2595
|
—
|
2650
2596
|
<div class='inline'>
|
2651
|
-
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span>
|
2652
|
-
methods to be chained.</p>
|
2597
|
+
<p>the same expectation, thereby allowing invocations of other <span class='object_link'><a href="" title="Mocha::Expectation (class)">Mocha::Expectation</a></span> methods to be chained.</p>
|
2653
2598
|
</div>
|
2654
2599
|
|
2655
2600
|
</li>
|
@@ -2669,13 +2614,13 @@ methods to be chained.</p>
|
|
2669
2614
|
<pre class="lines">
|
2670
2615
|
|
2671
2616
|
|
2672
|
-
|
2673
|
-
|
2674
|
-
|
2675
|
-
|
2617
|
+
258
|
2618
|
+
259
|
2619
|
+
260
|
2620
|
+
261</pre>
|
2676
2621
|
</td>
|
2677
2622
|
<td>
|
2678
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line
|
2623
|
+
<pre class="code"><span class="info file"># File 'lib/mocha/expectation.rb', line 258</span>
|
2679
2624
|
|
2680
2625
|
<span class='kw'>def</span> <span class='id identifier rubyid_yields'>yields</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_parameters'>parameters</span><span class='rparen'>)</span>
|
2681
2626
|
<span class='ivar'>@yield_parameters</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_parameters'>parameters</span><span class='rparen'>)</span>
|
@@ -2699,9 +2644,9 @@ methods to be chained.</p>
|
|
2699
2644
|
</div>
|
2700
2645
|
|
2701
2646
|
<div id="footer">
|
2702
|
-
Generated on Mon
|
2647
|
+
Generated on Mon Dec 2 17:48:41 2019 by
|
2703
2648
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2704
|
-
0.9.
|
2649
|
+
0.9.20 (ruby-2.6.5).
|
2705
2650
|
</div>
|
2706
2651
|
|
2707
2652
|
</div>
|