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