mocha 1.10.1 → 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/.github/FUNDING.yml +1 -0
- data/.yardopts +1 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +28 -30
- data/RELEASE.md +69 -0
- data/Rakefile +7 -5
- data/lib/mocha/api.rb +78 -19
- data/lib/mocha/block_matcher.rb +31 -0
- data/lib/mocha/cardinality.rb +30 -27
- data/lib/mocha/configuration.rb +57 -1
- data/lib/mocha/deprecation.rb +2 -1
- data/lib/mocha/expectation.rb +72 -31
- data/lib/mocha/invocation.rb +20 -4
- data/lib/mocha/mock.rb +43 -17
- data/lib/mocha/mockery.rb +17 -27
- data/lib/mocha/parameter_matchers/has_entries.rb +2 -3
- data/lib/mocha/parameter_matchers/has_entry.rb +2 -3
- data/lib/mocha/parameter_matchers/has_key.rb +2 -3
- data/lib/mocha/parameter_matchers/has_value.rb +2 -3
- data/lib/mocha/parameter_matchers/is_a.rb +2 -3
- data/lib/mocha/parameter_matchers/not.rb +2 -3
- data/lib/mocha/state_machine.rb +31 -40
- data/lib/mocha/stubbed_method.rb +4 -6
- data/lib/mocha/version.rb +1 -1
- data/lib/mocha/yield_parameters.rb +5 -11
- data/mocha.gemspec +3 -1
- metadata +7 -195
- data/docs/CNAME +0 -1
- data/docs/Mocha.html +0 -254
- data/docs/Mocha/API.html +0 -1153
- data/docs/Mocha/ClassMethods.html +0 -264
- data/docs/Mocha/Configuration.html +0 -1383
- data/docs/Mocha/Expectation.html +0 -2654
- 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 -1237
- data/docs/Mocha/ObjectMethods.html +0 -765
- data/docs/Mocha/ParameterMatchers.html +0 -2961
- 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 -963
- 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 -627
- data/docs/top-level-namespace.html +0 -118
- data/lib/mocha/multiple_yields.rb +0 -15
- data/lib/mocha/no_yields.rb +0 -5
- data/lib/mocha/pretty_parameters.rb +0 -24
- data/lib/mocha/single_yield.rb +0 -13
- data/test/acceptance/acceptance_test_helper.rb +0 -41
- 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 -61
- data/test/acceptance/issue_272_test.rb +0 -50
- 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 -96
- data/test/acceptance/mocha_test_result_test.rb +0 -83
- data/test/acceptance/mock_test.rb +0 -139
- data/test/acceptance/mocked_methods_dispatch_test.rb +0 -75
- data/test/acceptance/multiple_expectations_failure_message_test.rb +0 -66
- 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 -93
- 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/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 -477
- 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/multiple_yields_test.rb +0 -16
- data/test/unit/no_yields_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/single_yield_test.rb +0 -16
- 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 -91
@@ -1,264 +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::ClassMethods
|
8
|
-
|
9
|
-
— Mocha 1.10.1
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
pathId = "Mocha::ClassMethods";
|
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 (C)</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">ClassMethods</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::ClassMethods
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
</h1>
|
67
|
-
<div class="box_info">
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<dl>
|
80
|
-
<dt>Defined in:</dt>
|
81
|
-
<dd>lib/mocha/class_methods.rb</dd>
|
82
|
-
</dl>
|
83
|
-
|
84
|
-
</div>
|
85
|
-
|
86
|
-
<h2>Overview</h2><div class="docstring">
|
87
|
-
<div class="discussion">
|
88
|
-
|
89
|
-
<p>Methods added to all classes to allow mocking and stubbing on real (i.e. non-mock) objects.</p>
|
90
|
-
|
91
|
-
|
92
|
-
</div>
|
93
|
-
</div>
|
94
|
-
<div class="tags">
|
95
|
-
|
96
|
-
|
97
|
-
</div>
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
<h2>
|
106
|
-
Instance Method Summary
|
107
|
-
<small><a href="#" class="summary_toggle">collapse</a></small>
|
108
|
-
</h2>
|
109
|
-
|
110
|
-
<ul class="summary">
|
111
|
-
|
112
|
-
<li class="public ">
|
113
|
-
<span class="summary_signature">
|
114
|
-
|
115
|
-
<a href="#any_instance-instance_method" title="#any_instance (instance method)">#<strong>any_instance</strong> ⇒ Mock </a>
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
</span>
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
<span class="summary_desc"><div class='inline'>
|
130
|
-
<p>A mock object which will detect calls to any instance of this class.</p>
|
131
|
-
</div></span>
|
132
|
-
|
133
|
-
</li>
|
134
|
-
|
135
|
-
|
136
|
-
</ul>
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
<div id="instance_method_details" class="method_details_list">
|
142
|
-
<h2>Instance Method Details</h2>
|
143
|
-
|
144
|
-
|
145
|
-
<div class="method_details first">
|
146
|
-
<h3 class="signature first" id="any_instance-instance_method">
|
147
|
-
|
148
|
-
#<strong>any_instance</strong> ⇒ <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
</h3><div class="docstring">
|
155
|
-
<div class="discussion">
|
156
|
-
|
157
|
-
<p>Returns a mock object which will detect calls to any instance of this class.</p>
|
158
|
-
|
159
|
-
|
160
|
-
</div>
|
161
|
-
</div>
|
162
|
-
<div class="tags">
|
163
|
-
|
164
|
-
<div class="examples">
|
165
|
-
<p class="tag_title">Examples:</p>
|
166
|
-
|
167
|
-
|
168
|
-
<p class="example_title"><div class='inline'>
|
169
|
-
<p>Return false to invocation of <tt>Product#save</tt> for any instance of <code>Product</code>.</p>
|
170
|
-
</div></p>
|
171
|
-
|
172
|
-
<pre class="example code"><code><span class='const'>Product</span><span class='period'>.</span><span class='id identifier rubyid_any_instance'>any_instance</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:save</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='kw'>false</span><span class='rparen'>)</span>
|
173
|
-
<span class='id identifier rubyid_product_1'>product_1</span> <span class='op'>=</span> <span class='const'>Product</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
174
|
-
<span class='id identifier rubyid_assert_equal'>assert_equal</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_product_1'>product_1</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
|
175
|
-
<span class='id identifier rubyid_product_2'>product_2</span> <span class='op'>=</span> <span class='const'>Product</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
176
|
-
<span class='id identifier rubyid_assert_equal'>assert_equal</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='id identifier rubyid_product_2'>product_2</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span></code></pre>
|
177
|
-
|
178
|
-
</div>
|
179
|
-
|
180
|
-
<p class="tag_title">Returns:</p>
|
181
|
-
<ul class="return">
|
182
|
-
|
183
|
-
<li>
|
184
|
-
|
185
|
-
|
186
|
-
<span class='type'>(<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
—
|
191
|
-
<div class='inline'>
|
192
|
-
<p>a mock object which will detect calls to any instance of this class.</p>
|
193
|
-
</div>
|
194
|
-
|
195
|
-
</li>
|
196
|
-
|
197
|
-
</ul>
|
198
|
-
<p class="tag_title">Raises:</p>
|
199
|
-
<ul class="raise">
|
200
|
-
|
201
|
-
<li>
|
202
|
-
|
203
|
-
|
204
|
-
<span class='type'>(<tt><span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span></tt>)</span>
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
—
|
209
|
-
<div class='inline'>
|
210
|
-
<p>if attempting to stub method which is not allowed.</p>
|
211
|
-
</div>
|
212
|
-
|
213
|
-
</li>
|
214
|
-
|
215
|
-
</ul>
|
216
|
-
|
217
|
-
</div><table class="source_code">
|
218
|
-
<tr>
|
219
|
-
<td>
|
220
|
-
<pre class="lines">
|
221
|
-
|
222
|
-
|
223
|
-
45
|
224
|
-
46
|
225
|
-
47
|
226
|
-
48
|
227
|
-
49
|
228
|
-
50</pre>
|
229
|
-
</td>
|
230
|
-
<td>
|
231
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/class_methods.rb', line 45</span>
|
232
|
-
|
233
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_any_instance'>any_instance</span>
|
234
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_frozen?'>frozen?</span>
|
235
|
-
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>can't stub method on frozen object: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_mocha_inspect'>mocha_inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'>.any_instance</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span><span class='rparen'>)</span>
|
236
|
-
<span class='kw'>end</span>
|
237
|
-
<span class='ivar'>@any_instance</span> <span class='op'>||=</span> <span class='const'>AnyInstance</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
|
238
|
-
<span class='kw'>end</span></pre>
|
239
|
-
</td>
|
240
|
-
</tr>
|
241
|
-
</table>
|
242
|
-
</div>
|
243
|
-
|
244
|
-
</div>
|
245
|
-
|
246
|
-
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
|
247
|
-
<script>
|
248
|
-
window.dataLayer = window.dataLayer || [];
|
249
|
-
function gtag(){dataLayer.push(arguments);}
|
250
|
-
gtag('js', new Date());
|
251
|
-
|
252
|
-
gtag('config', 'UA-625523-7');
|
253
|
-
</script>
|
254
|
-
</div>
|
255
|
-
|
256
|
-
<div id="footer">
|
257
|
-
Generated on Wed Dec 4 09:20:47 2019 by
|
258
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
259
|
-
0.9.20 (ruby-2.6.5).
|
260
|
-
</div>
|
261
|
-
|
262
|
-
</div>
|
263
|
-
</body>
|
264
|
-
</html>
|
@@ -1,1383 +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::Configuration
|
8
|
-
|
9
|
-
— Mocha 1.10.1
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
pathId = "Mocha::Configuration";
|
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 (C)</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">Configuration</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::Configuration
|
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::Configuration</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/configuration.rb</dd>
|
98
|
-
</dl>
|
99
|
-
|
100
|
-
</div>
|
101
|
-
|
102
|
-
<h2>Overview</h2><div class="docstring">
|
103
|
-
<div class="discussion">
|
104
|
-
|
105
|
-
<p>This class provides a number of ways to configure the library.</p>
|
106
|
-
|
107
|
-
<p>Typically the configuration is set globally in a <code>test_helper.rb</code> or <code>spec_helper.rb</code> file.</p>
|
108
|
-
|
109
|
-
|
110
|
-
</div>
|
111
|
-
</div>
|
112
|
-
<div class="tags">
|
113
|
-
|
114
|
-
<div class="examples">
|
115
|
-
<p class="tag_title">Examples:</p>
|
116
|
-
|
117
|
-
|
118
|
-
<p class="example_title"><div class='inline'>
|
119
|
-
<p>Setting multiple configuration options</p>
|
120
|
-
</div></p>
|
121
|
-
|
122
|
-
<pre class="example code"><code><span class='const'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="../Mocha.html#configure-class_method" title="Mocha.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span>
|
123
|
-
<span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_method_unnecessarily'>stubbing_method_unnecessarily</span> <span class='op'>=</span> <span class='symbol'>:prevent</span>
|
124
|
-
<span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_method_on_non_mock_object'>stubbing_method_on_non_mock_object</span> <span class='op'>=</span> <span class='symbol'>:warn</span>
|
125
|
-
<span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_method_on_nil'>stubbing_method_on_nil</span> <span class='op'>=</span> <span class='symbol'>:allow</span>
|
126
|
-
<span class='kw'>end</span></code></pre>
|
127
|
-
|
128
|
-
</div>
|
129
|
-
|
130
|
-
|
131
|
-
</div>
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
<h2>
|
140
|
-
Class Method Summary
|
141
|
-
<small><a href="#" class="summary_toggle">collapse</a></small>
|
142
|
-
</h2>
|
143
|
-
|
144
|
-
<ul class="summary">
|
145
|
-
|
146
|
-
<li class="public deprecated">
|
147
|
-
<span class="summary_signature">
|
148
|
-
|
149
|
-
<a href="#allow-class_method" title="allow (class method)">.<strong>allow</strong>(action) { ... } ⇒ Object </a>
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
</span>
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
<span class="deprecated note title">deprecated</span>
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
<span class="summary_desc"><strong>Deprecated.</strong> <div class='inline'>
|
164
|
-
<p>If a block is supplied, call <span class='object_link'><a href="#override-class_method" title="Mocha::Configuration.override (method)">Configuration.override</a></span> with a <code>Hash</code> containing an entry with the <code>action</code> as the key and <code>:allow</code> as the value. If no block is supplied, call the appropriate <code>action</code> writer method with <code>value</code> set to <code>:allow</code> via <span class='object_link'><a href="../Mocha.html#configure-class_method" title="Mocha.configure (method)">configure</a></span>. The writer method will be the one of the following corresponding to the <code>action</code>:</p>
|
165
|
-
<ul><li>
|
166
|
-
<p><span class='object_link'><a href="#stubbing_method_unnecessarily=-instance_method" title="Mocha::Configuration#stubbing_method_unnecessarily= (method)">#stubbing_method_unnecessarily=</a></span></p>
|
167
|
-
</li><li>
|
168
|
-
<p><span class='object_link'><a href="#stubbing_method_on_non_mock_object=-instance_method" title="Mocha::Configuration#stubbing_method_on_non_mock_object= (method)">#stubbing_method_on_non_mock_object=</a></span></p>
|
169
|
-
</li><li>
|
170
|
-
<p><span class='object_link'><a href="#stubbing_non_existent_method=-instance_method" title="Mocha::Configuration#stubbing_non_existent_method= (method)">#stubbing_non_existent_method=</a></span></p>
|
171
|
-
</li><li>
|
172
|
-
<p><span class='object_link'><a href="#stubbing_non_public_method=-instance_method" title="Mocha::Configuration#stubbing_non_public_method= (method)">#stubbing_non_public_method=</a></span></p>
|
173
|
-
</li><li>
|
174
|
-
<p><span class='object_link'><a href="#stubbing_method_on_nil=-instance_method" title="Mocha::Configuration#stubbing_method_on_nil= (method)">#stubbing_method_on_nil=</a></span></p>
|
175
|
-
</li></ul>
|
176
|
-
</div></span>
|
177
|
-
|
178
|
-
</li>
|
179
|
-
|
180
|
-
|
181
|
-
<li class="public ">
|
182
|
-
<span class="summary_signature">
|
183
|
-
|
184
|
-
<a href="#override-class_method" title="override (class method)">.<strong>override</strong>(temporary_options) { ... } ⇒ Object </a>
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
</span>
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
<span class="summary_desc"><div class='inline'>
|
199
|
-
<p>Temporarily modify <span class='object_link'><a href="" title="Mocha::Configuration (class)">Configuration</a></span> options.</p>
|
200
|
-
</div></span>
|
201
|
-
|
202
|
-
</li>
|
203
|
-
|
204
|
-
|
205
|
-
<li class="public deprecated">
|
206
|
-
<span class="summary_signature">
|
207
|
-
|
208
|
-
<a href="#prevent-class_method" title="prevent (class method)">.<strong>prevent</strong>(action) { ... } ⇒ Object </a>
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
</span>
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
<span class="deprecated note title">deprecated</span>
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
<span class="summary_desc"><strong>Deprecated.</strong> <div class='inline'>
|
223
|
-
<p>If a block is supplied, call <span class='object_link'><a href="#override-class_method" title="Mocha::Configuration.override (method)">Configuration.override</a></span> with a <code>Hash</code> containing an entry with the <code>action</code> as the key and <code>:prevent</code> as the value. If no block is supplied, call the appropriate <code>action</code> writer method with <code>value</code> set to <code>:prevent</code> via <span class='object_link'><a href="../Mocha.html#configure-class_method" title="Mocha.configure (method)">configure</a></span>. The writer method will be the one of the following corresponding to the <code>action</code>:</p>
|
224
|
-
<ul><li>
|
225
|
-
<p><span class='object_link'><a href="#stubbing_method_unnecessarily=-instance_method" title="Mocha::Configuration#stubbing_method_unnecessarily= (method)">#stubbing_method_unnecessarily=</a></span></p>
|
226
|
-
</li><li>
|
227
|
-
<p><span class='object_link'><a href="#stubbing_method_on_non_mock_object=-instance_method" title="Mocha::Configuration#stubbing_method_on_non_mock_object= (method)">#stubbing_method_on_non_mock_object=</a></span></p>
|
228
|
-
</li><li>
|
229
|
-
<p><span class='object_link'><a href="#stubbing_non_existent_method=-instance_method" title="Mocha::Configuration#stubbing_non_existent_method= (method)">#stubbing_non_existent_method=</a></span></p>
|
230
|
-
</li><li>
|
231
|
-
<p><span class='object_link'><a href="#stubbing_non_public_method=-instance_method" title="Mocha::Configuration#stubbing_non_public_method= (method)">#stubbing_non_public_method=</a></span></p>
|
232
|
-
</li><li>
|
233
|
-
<p><span class='object_link'><a href="#stubbing_method_on_nil=-instance_method" title="Mocha::Configuration#stubbing_method_on_nil= (method)">#stubbing_method_on_nil=</a></span></p>
|
234
|
-
</li></ul>
|
235
|
-
</div></span>
|
236
|
-
|
237
|
-
</li>
|
238
|
-
|
239
|
-
|
240
|
-
<li class="public deprecated">
|
241
|
-
<span class="summary_signature">
|
242
|
-
|
243
|
-
<a href="#warn_when-class_method" title="warn_when (class method)">.<strong>warn_when</strong>(action) { ... } ⇒ Object </a>
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
</span>
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
<span class="deprecated note title">deprecated</span>
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
<span class="summary_desc"><strong>Deprecated.</strong> <div class='inline'>
|
258
|
-
<p>If a block is supplied, call <span class='object_link'><a href="#override-class_method" title="Mocha::Configuration.override (method)">Configuration.override</a></span> with a <code>Hash</code> containing an entry with the <code>action</code> as the key and <code>:warn</code> as the value. If no block is supplied, call the appropriate <code>action</code> writer method with <code>value</code> set to <code>:warn</code> via <span class='object_link'><a href="../Mocha.html#configure-class_method" title="Mocha.configure (method)">configure</a></span>. The writer method will be the one of the following corresponding to the <code>action</code>:</p>
|
259
|
-
<ul><li>
|
260
|
-
<p><span class='object_link'><a href="#stubbing_method_unnecessarily=-instance_method" title="Mocha::Configuration#stubbing_method_unnecessarily= (method)">#stubbing_method_unnecessarily=</a></span></p>
|
261
|
-
</li><li>
|
262
|
-
<p><span class='object_link'><a href="#stubbing_method_on_non_mock_object=-instance_method" title="Mocha::Configuration#stubbing_method_on_non_mock_object= (method)">#stubbing_method_on_non_mock_object=</a></span></p>
|
263
|
-
</li><li>
|
264
|
-
<p><span class='object_link'><a href="#stubbing_non_existent_method=-instance_method" title="Mocha::Configuration#stubbing_non_existent_method= (method)">#stubbing_non_existent_method=</a></span></p>
|
265
|
-
</li><li>
|
266
|
-
<p><span class='object_link'><a href="#stubbing_non_public_method=-instance_method" title="Mocha::Configuration#stubbing_non_public_method= (method)">#stubbing_non_public_method=</a></span></p>
|
267
|
-
</li><li>
|
268
|
-
<p><span class='object_link'><a href="#stubbing_method_on_nil=-instance_method" title="Mocha::Configuration#stubbing_method_on_nil= (method)">#stubbing_method_on_nil=</a></span></p>
|
269
|
-
</li></ul>
|
270
|
-
</div></span>
|
271
|
-
|
272
|
-
</li>
|
273
|
-
|
274
|
-
|
275
|
-
</ul>
|
276
|
-
|
277
|
-
<h2>
|
278
|
-
Instance Method Summary
|
279
|
-
<small><a href="#" class="summary_toggle">collapse</a></small>
|
280
|
-
</h2>
|
281
|
-
|
282
|
-
<ul class="summary">
|
283
|
-
|
284
|
-
<li class="public ">
|
285
|
-
<span class="summary_signature">
|
286
|
-
|
287
|
-
<a href="#display_matching_invocations_on_failure=-instance_method" title="#display_matching_invocations_on_failure= (instance method)">#<strong>display_matching_invocations_on_failure=</strong>(value) ⇒ Object </a>
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
</span>
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
<span class="summary_desc"><div class='inline'>
|
302
|
-
<p>Display matching invocations alongside expectations on Mocha-related test failure.</p>
|
303
|
-
</div></span>
|
304
|
-
|
305
|
-
</li>
|
306
|
-
|
307
|
-
|
308
|
-
<li class="public ">
|
309
|
-
<span class="summary_signature">
|
310
|
-
|
311
|
-
<a href="#stubbing_method_on_nil=-instance_method" title="#stubbing_method_on_nil= (instance method)">#<strong>stubbing_method_on_nil=</strong>(value) ⇒ Object </a>
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
</span>
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
<span class="summary_desc"><div class='inline'>
|
326
|
-
<p>Configure whether stubbing methods on the <code>nil</code> object is allowed.</p>
|
327
|
-
</div></span>
|
328
|
-
|
329
|
-
</li>
|
330
|
-
|
331
|
-
|
332
|
-
<li class="public ">
|
333
|
-
<span class="summary_signature">
|
334
|
-
|
335
|
-
<a href="#stubbing_method_on_non_mock_object=-instance_method" title="#stubbing_method_on_non_mock_object= (instance method)">#<strong>stubbing_method_on_non_mock_object=</strong>(value) ⇒ Object </a>
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
</span>
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
<span class="summary_desc"><div class='inline'>
|
350
|
-
<p>Configure whether stubbing methods on non-mock objects is allowed.</p>
|
351
|
-
</div></span>
|
352
|
-
|
353
|
-
</li>
|
354
|
-
|
355
|
-
|
356
|
-
<li class="public ">
|
357
|
-
<span class="summary_signature">
|
358
|
-
|
359
|
-
<a href="#stubbing_method_unnecessarily=-instance_method" title="#stubbing_method_unnecessarily= (instance method)">#<strong>stubbing_method_unnecessarily=</strong>(value) ⇒ Object </a>
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
</span>
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
<span class="summary_desc"><div class='inline'>
|
374
|
-
<p>Configure whether stubbing methods unnecessarily is allowed.</p>
|
375
|
-
</div></span>
|
376
|
-
|
377
|
-
</li>
|
378
|
-
|
379
|
-
|
380
|
-
<li class="public ">
|
381
|
-
<span class="summary_signature">
|
382
|
-
|
383
|
-
<a href="#stubbing_non_existent_method=-instance_method" title="#stubbing_non_existent_method= (instance method)">#<strong>stubbing_non_existent_method=</strong>(value) ⇒ Object </a>
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
</span>
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
<span class="summary_desc"><div class='inline'>
|
398
|
-
<p>Configure whether stubbing of non-existent methods is allowed.</p>
|
399
|
-
</div></span>
|
400
|
-
|
401
|
-
</li>
|
402
|
-
|
403
|
-
|
404
|
-
<li class="public ">
|
405
|
-
<span class="summary_signature">
|
406
|
-
|
407
|
-
<a href="#stubbing_non_public_method=-instance_method" title="#stubbing_non_public_method= (instance method)">#<strong>stubbing_non_public_method=</strong>(value) ⇒ Object </a>
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
</span>
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
<span class="summary_desc"><div class='inline'>
|
422
|
-
<p>Configure whether stubbing of non-public methods is allowed.</p>
|
423
|
-
</div></span>
|
424
|
-
|
425
|
-
</li>
|
426
|
-
|
427
|
-
|
428
|
-
</ul>
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
<div id="class_method_details" class="method_details_list">
|
434
|
-
<h2>Class Method Details</h2>
|
435
|
-
|
436
|
-
|
437
|
-
<div class="method_details first">
|
438
|
-
<h3 class="signature first" id="allow-class_method">
|
439
|
-
|
440
|
-
.<strong>allow</strong>(action) { ... } ⇒ <tt><span class='object_link'>Object</span></tt>
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
</h3><div class="docstring">
|
447
|
-
<div class="discussion">
|
448
|
-
<div class="note deprecated"><strong>Deprecated.</strong> <div class='inline'>
|
449
|
-
<p>If a block is supplied, call <span class='object_link'><a href="#override-class_method" title="Mocha::Configuration.override (method)">override</a></span> with a <code>Hash</code> containing an entry with the <code>action</code> as the key and <code>:allow</code> as the value. If no block is supplied, call the appropriate <code>action</code> writer method with <code>value</code> set to <code>:allow</code> via <span class='object_link'><a href="../Mocha.html#configure-class_method" title="Mocha.configure (method)">Mocha.configure</a></span>. The writer method will be the one of the following corresponding to the <code>action</code>:</p>
|
450
|
-
<ul><li>
|
451
|
-
<p><span class='object_link'><a href="#stubbing_method_unnecessarily=-instance_method" title="Mocha::Configuration#stubbing_method_unnecessarily= (method)">#stubbing_method_unnecessarily=</a></span></p>
|
452
|
-
</li><li>
|
453
|
-
<p><span class='object_link'><a href="#stubbing_method_on_non_mock_object=-instance_method" title="Mocha::Configuration#stubbing_method_on_non_mock_object= (method)">#stubbing_method_on_non_mock_object=</a></span></p>
|
454
|
-
</li><li>
|
455
|
-
<p><span class='object_link'><a href="#stubbing_non_existent_method=-instance_method" title="Mocha::Configuration#stubbing_non_existent_method= (method)">#stubbing_non_existent_method=</a></span></p>
|
456
|
-
</li><li>
|
457
|
-
<p><span class='object_link'><a href="#stubbing_non_public_method=-instance_method" title="Mocha::Configuration#stubbing_non_public_method= (method)">#stubbing_non_public_method=</a></span></p>
|
458
|
-
</li><li>
|
459
|
-
<p><span class='object_link'><a href="#stubbing_method_on_nil=-instance_method" title="Mocha::Configuration#stubbing_method_on_nil= (method)">#stubbing_method_on_nil=</a></span></p>
|
460
|
-
</li></ul>
|
461
|
-
</div></div>
|
462
|
-
|
463
|
-
<p>Allow the specified <code>action</code>.</p>
|
464
|
-
|
465
|
-
|
466
|
-
</div>
|
467
|
-
</div>
|
468
|
-
<div class="tags">
|
469
|
-
<p class="tag_title">Parameters:</p>
|
470
|
-
<ul class="param">
|
471
|
-
|
472
|
-
<li>
|
473
|
-
|
474
|
-
<span class='name'>action</span>
|
475
|
-
|
476
|
-
|
477
|
-
<span class='type'>(<tt>Symbol</tt>)</span>
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
—
|
482
|
-
<div class='inline'>
|
483
|
-
<p>one of <code>:stubbing_method_unnecessarily</code>, <code>:stubbing_method_on_non_mock_object</code>, <code>:stubbing_non_existent_method</code>, <code>:stubbing_non_public_method</code>, <code>:stubbing_method_on_nil</code>.</p>
|
484
|
-
</div>
|
485
|
-
|
486
|
-
</li>
|
487
|
-
|
488
|
-
</ul>
|
489
|
-
|
490
|
-
<p class="tag_title">Yields:</p>
|
491
|
-
<ul class="yield">
|
492
|
-
|
493
|
-
<li>
|
494
|
-
|
495
|
-
|
496
|
-
<span class='type'></span>
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
<div class='inline'>
|
502
|
-
<p>optional block during which the configuration change will be changed before being returned to its original value at the end of the block.</p>
|
503
|
-
</div>
|
504
|
-
|
505
|
-
</li>
|
506
|
-
|
507
|
-
</ul>
|
508
|
-
|
509
|
-
</div><table class="source_code">
|
510
|
-
<tr>
|
511
|
-
<td>
|
512
|
-
<pre class="lines">
|
513
|
-
|
514
|
-
|
515
|
-
261
|
516
|
-
262
|
517
|
-
263
|
518
|
-
264
|
519
|
-
265
|
520
|
-
266
|
521
|
-
267
|
522
|
-
268</pre>
|
523
|
-
</td>
|
524
|
-
<td>
|
525
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 261</span>
|
526
|
-
|
527
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_allow'>allow</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
528
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
529
|
-
<span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Use Mocha::Configuration.override(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_action'>action</span><span class='embexpr_end'>}</span><span class='tstring_content'>: :allow) with the same block</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
530
|
-
<span class='kw'>else</span>
|
531
|
-
<span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Use Mocha.configure { |c| c.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_action'>action</span><span class='embexpr_end'>}</span><span class='tstring_content'> = :allow }</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
532
|
-
<span class='kw'>end</span>
|
533
|
-
<span class='id identifier rubyid_change_config'>change_config</span> <span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='symbol'>:allow</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span>
|
534
|
-
<span class='kw'>end</span></pre>
|
535
|
-
</td>
|
536
|
-
</tr>
|
537
|
-
</table>
|
538
|
-
</div>
|
539
|
-
|
540
|
-
<div class="method_details ">
|
541
|
-
<h3 class="signature " id="override-class_method">
|
542
|
-
|
543
|
-
.<strong>override</strong>(temporary_options) { ... } ⇒ <tt><span class='object_link'>Object</span></tt>
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
</h3><div class="docstring">
|
550
|
-
<div class="discussion">
|
551
|
-
|
552
|
-
<p>Temporarily modify <span class='object_link'><a href="" title="Mocha::Configuration (class)">Mocha::Configuration</a></span> options.</p>
|
553
|
-
|
554
|
-
<p>The supplied <code>temporary_options</code> will override the current configuration for the duration of the supplied block. The configuration will be returned to its original state when the block returns.</p>
|
555
|
-
|
556
|
-
|
557
|
-
</div>
|
558
|
-
</div>
|
559
|
-
<div class="tags">
|
560
|
-
|
561
|
-
<div class="examples">
|
562
|
-
<p class="tag_title">Examples:</p>
|
563
|
-
|
564
|
-
|
565
|
-
<p class="example_title"><div class='inline'>
|
566
|
-
<p>Temporarily allow stubbing of <code>nil</code></p>
|
567
|
-
</div></p>
|
568
|
-
|
569
|
-
<pre class="example code"><code><span class='const'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Mocha::Configuration (class)">Configuration</a></span></span><span class='period'>.</span><span class='id identifier rubyid_override'>override</span><span class='lparen'>(</span><span class='label'>stubbing_method_on_nil:</span> <span class='symbol'>:allow</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
570
|
-
<span class='kw'>nil</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:foo</span><span class='rparen'>)</span>
|
571
|
-
<span class='kw'>end</span></code></pre>
|
572
|
-
|
573
|
-
</div>
|
574
|
-
<p class="tag_title">Parameters:</p>
|
575
|
-
<ul class="param">
|
576
|
-
|
577
|
-
<li>
|
578
|
-
|
579
|
-
<span class='name'>temporary_options</span>
|
580
|
-
|
581
|
-
|
582
|
-
<span class='type'>(<tt>Hash</tt>)</span>
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
—
|
587
|
-
<div class='inline'>
|
588
|
-
<p>the configuration options to apply for the duration of the block.</p>
|
589
|
-
</div>
|
590
|
-
|
591
|
-
</li>
|
592
|
-
|
593
|
-
</ul>
|
594
|
-
|
595
|
-
<p class="tag_title">Yields:</p>
|
596
|
-
<ul class="yield">
|
597
|
-
|
598
|
-
<li>
|
599
|
-
|
600
|
-
|
601
|
-
<span class='type'></span>
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
<div class='inline'>
|
607
|
-
<p>block during which the configuration change will be in force.</p>
|
608
|
-
</div>
|
609
|
-
|
610
|
-
</li>
|
611
|
-
|
612
|
-
</ul>
|
613
|
-
|
614
|
-
</div><table class="source_code">
|
615
|
-
<tr>
|
616
|
-
<td>
|
617
|
-
<pre class="lines">
|
618
|
-
|
619
|
-
|
620
|
-
340
|
621
|
-
341
|
622
|
-
342
|
623
|
-
343
|
624
|
-
344
|
625
|
-
345
|
626
|
-
346</pre>
|
627
|
-
</td>
|
628
|
-
<td>
|
629
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 340</span>
|
630
|
-
|
631
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_override'>override</span><span class='lparen'>(</span><span class='id identifier rubyid_temporary_options'>temporary_options</span><span class='rparen'>)</span>
|
632
|
-
<span class='id identifier rubyid_original_configuration'>original_configuration</span> <span class='op'>=</span> <span class='id identifier rubyid_configuration'>configuration</span>
|
633
|
-
<span class='ivar'>@configuration</span> <span class='op'>=</span> <span class='id identifier rubyid_configuration'>configuration</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_temporary_options'>temporary_options</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
634
|
-
<span class='kw'>yield</span>
|
635
|
-
<span class='kw'>ensure</span>
|
636
|
-
<span class='ivar'>@configuration</span> <span class='op'>=</span> <span class='id identifier rubyid_original_configuration'>original_configuration</span>
|
637
|
-
<span class='kw'>end</span></pre>
|
638
|
-
</td>
|
639
|
-
</tr>
|
640
|
-
</table>
|
641
|
-
</div>
|
642
|
-
|
643
|
-
<div class="method_details ">
|
644
|
-
<h3 class="signature " id="prevent-class_method">
|
645
|
-
|
646
|
-
.<strong>prevent</strong>(action) { ... } ⇒ <tt><span class='object_link'>Object</span></tt>
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
</h3><div class="docstring">
|
653
|
-
<div class="discussion">
|
654
|
-
<div class="note deprecated"><strong>Deprecated.</strong> <div class='inline'>
|
655
|
-
<p>If a block is supplied, call <span class='object_link'><a href="#override-class_method" title="Mocha::Configuration.override (method)">override</a></span> with a <code>Hash</code> containing an entry with the <code>action</code> as the key and <code>:prevent</code> as the value. If no block is supplied, call the appropriate <code>action</code> writer method with <code>value</code> set to <code>:prevent</code> via <span class='object_link'><a href="../Mocha.html#configure-class_method" title="Mocha.configure (method)">Mocha.configure</a></span>. The writer method will be the one of the following corresponding to the <code>action</code>:</p>
|
656
|
-
<ul><li>
|
657
|
-
<p><span class='object_link'><a href="#stubbing_method_unnecessarily=-instance_method" title="Mocha::Configuration#stubbing_method_unnecessarily= (method)">#stubbing_method_unnecessarily=</a></span></p>
|
658
|
-
</li><li>
|
659
|
-
<p><span class='object_link'><a href="#stubbing_method_on_non_mock_object=-instance_method" title="Mocha::Configuration#stubbing_method_on_non_mock_object= (method)">#stubbing_method_on_non_mock_object=</a></span></p>
|
660
|
-
</li><li>
|
661
|
-
<p><span class='object_link'><a href="#stubbing_non_existent_method=-instance_method" title="Mocha::Configuration#stubbing_non_existent_method= (method)">#stubbing_non_existent_method=</a></span></p>
|
662
|
-
</li><li>
|
663
|
-
<p><span class='object_link'><a href="#stubbing_non_public_method=-instance_method" title="Mocha::Configuration#stubbing_non_public_method= (method)">#stubbing_non_public_method=</a></span></p>
|
664
|
-
</li><li>
|
665
|
-
<p><span class='object_link'><a href="#stubbing_method_on_nil=-instance_method" title="Mocha::Configuration#stubbing_method_on_nil= (method)">#stubbing_method_on_nil=</a></span></p>
|
666
|
-
</li></ul>
|
667
|
-
</div></div>
|
668
|
-
|
669
|
-
<p>Raise a <span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span> if the specified <code>action</code> is attempted.</p>
|
670
|
-
|
671
|
-
|
672
|
-
</div>
|
673
|
-
</div>
|
674
|
-
<div class="tags">
|
675
|
-
<p class="tag_title">Parameters:</p>
|
676
|
-
<ul class="param">
|
677
|
-
|
678
|
-
<li>
|
679
|
-
|
680
|
-
<span class='name'>action</span>
|
681
|
-
|
682
|
-
|
683
|
-
<span class='type'>(<tt>Symbol</tt>)</span>
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
—
|
688
|
-
<div class='inline'>
|
689
|
-
<p>one of <code>:stubbing_method_unnecessarily</code>, <code>:stubbing_method_on_non_mock_object</code>, <code>:stubbing_non_existent_method</code>, <code>:stubbing_non_public_method</code>, <code>:stubbing_method_on_nil</code>.</p>
|
690
|
-
</div>
|
691
|
-
|
692
|
-
</li>
|
693
|
-
|
694
|
-
</ul>
|
695
|
-
|
696
|
-
<p class="tag_title">Yields:</p>
|
697
|
-
<ul class="yield">
|
698
|
-
|
699
|
-
<li>
|
700
|
-
|
701
|
-
|
702
|
-
<span class='type'></span>
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
<div class='inline'>
|
708
|
-
<p>optional block during which the configuration change will be changed before being returned to its original value at the end of the block.</p>
|
709
|
-
</div>
|
710
|
-
|
711
|
-
</li>
|
712
|
-
|
713
|
-
</ul>
|
714
|
-
|
715
|
-
</div><table class="source_code">
|
716
|
-
<tr>
|
717
|
-
<td>
|
718
|
-
<pre class="lines">
|
719
|
-
|
720
|
-
|
721
|
-
309
|
722
|
-
310
|
723
|
-
311
|
724
|
-
312
|
725
|
-
313
|
726
|
-
314
|
727
|
-
315
|
728
|
-
316</pre>
|
729
|
-
</td>
|
730
|
-
<td>
|
731
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 309</span>
|
732
|
-
|
733
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_prevent'>prevent</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
734
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
735
|
-
<span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Use Mocha::Configuration.override(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_action'>action</span><span class='embexpr_end'>}</span><span class='tstring_content'>: :prevent) with the same block</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
736
|
-
<span class='kw'>else</span>
|
737
|
-
<span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Use Mocha.configure { |c| c.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_action'>action</span><span class='embexpr_end'>}</span><span class='tstring_content'> = :prevent }</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
738
|
-
<span class='kw'>end</span>
|
739
|
-
<span class='id identifier rubyid_change_config'>change_config</span> <span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='symbol'>:prevent</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span>
|
740
|
-
<span class='kw'>end</span></pre>
|
741
|
-
</td>
|
742
|
-
</tr>
|
743
|
-
</table>
|
744
|
-
</div>
|
745
|
-
|
746
|
-
<div class="method_details ">
|
747
|
-
<h3 class="signature " id="warn_when-class_method">
|
748
|
-
|
749
|
-
.<strong>warn_when</strong>(action) { ... } ⇒ <tt><span class='object_link'>Object</span></tt>
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
</h3><div class="docstring">
|
756
|
-
<div class="discussion">
|
757
|
-
<div class="note deprecated"><strong>Deprecated.</strong> <div class='inline'>
|
758
|
-
<p>If a block is supplied, call <span class='object_link'><a href="#override-class_method" title="Mocha::Configuration.override (method)">override</a></span> with a <code>Hash</code> containing an entry with the <code>action</code> as the key and <code>:warn</code> as the value. If no block is supplied, call the appropriate <code>action</code> writer method with <code>value</code> set to <code>:warn</code> via <span class='object_link'><a href="../Mocha.html#configure-class_method" title="Mocha.configure (method)">Mocha.configure</a></span>. The writer method will be the one of the following corresponding to the <code>action</code>:</p>
|
759
|
-
<ul><li>
|
760
|
-
<p><span class='object_link'><a href="#stubbing_method_unnecessarily=-instance_method" title="Mocha::Configuration#stubbing_method_unnecessarily= (method)">#stubbing_method_unnecessarily=</a></span></p>
|
761
|
-
</li><li>
|
762
|
-
<p><span class='object_link'><a href="#stubbing_method_on_non_mock_object=-instance_method" title="Mocha::Configuration#stubbing_method_on_non_mock_object= (method)">#stubbing_method_on_non_mock_object=</a></span></p>
|
763
|
-
</li><li>
|
764
|
-
<p><span class='object_link'><a href="#stubbing_non_existent_method=-instance_method" title="Mocha::Configuration#stubbing_non_existent_method= (method)">#stubbing_non_existent_method=</a></span></p>
|
765
|
-
</li><li>
|
766
|
-
<p><span class='object_link'><a href="#stubbing_non_public_method=-instance_method" title="Mocha::Configuration#stubbing_non_public_method= (method)">#stubbing_non_public_method=</a></span></p>
|
767
|
-
</li><li>
|
768
|
-
<p><span class='object_link'><a href="#stubbing_method_on_nil=-instance_method" title="Mocha::Configuration#stubbing_method_on_nil= (method)">#stubbing_method_on_nil=</a></span></p>
|
769
|
-
</li></ul>
|
770
|
-
</div></div>
|
771
|
-
|
772
|
-
<p>Warn if the specified <code>action</code> is attempted.</p>
|
773
|
-
|
774
|
-
|
775
|
-
</div>
|
776
|
-
</div>
|
777
|
-
<div class="tags">
|
778
|
-
<p class="tag_title">Parameters:</p>
|
779
|
-
<ul class="param">
|
780
|
-
|
781
|
-
<li>
|
782
|
-
|
783
|
-
<span class='name'>action</span>
|
784
|
-
|
785
|
-
|
786
|
-
<span class='type'>(<tt>Symbol</tt>)</span>
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
—
|
791
|
-
<div class='inline'>
|
792
|
-
<p>one of <code>:stubbing_method_unnecessarily</code>, <code>:stubbing_method_on_non_mock_object</code>, <code>:stubbing_non_existent_method</code>, <code>:stubbing_non_public_method</code>, <code>:stubbing_method_on_nil</code>.</p>
|
793
|
-
</div>
|
794
|
-
|
795
|
-
</li>
|
796
|
-
|
797
|
-
</ul>
|
798
|
-
|
799
|
-
<p class="tag_title">Yields:</p>
|
800
|
-
<ul class="yield">
|
801
|
-
|
802
|
-
<li>
|
803
|
-
|
804
|
-
|
805
|
-
<span class='type'></span>
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
<div class='inline'>
|
811
|
-
<p>optional block during which the configuration change will be changed before being returned to its original value at the end of the block.</p>
|
812
|
-
</div>
|
813
|
-
|
814
|
-
</li>
|
815
|
-
|
816
|
-
</ul>
|
817
|
-
|
818
|
-
</div><table class="source_code">
|
819
|
-
<tr>
|
820
|
-
<td>
|
821
|
-
<pre class="lines">
|
822
|
-
|
823
|
-
|
824
|
-
285
|
825
|
-
286
|
826
|
-
287
|
827
|
-
288
|
828
|
-
289
|
829
|
-
290
|
830
|
-
291
|
831
|
-
292</pre>
|
832
|
-
</td>
|
833
|
-
<td>
|
834
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 285</span>
|
835
|
-
|
836
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_warn_when'>warn_when</span><span class='lparen'>(</span><span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
837
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
838
|
-
<span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Use Mocha::Configuration.override(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_action'>action</span><span class='embexpr_end'>}</span><span class='tstring_content'>: :warn) with the same block</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
839
|
-
<span class='kw'>else</span>
|
840
|
-
<span class='const'>Deprecation</span><span class='period'>.</span><span class='id identifier rubyid_warning'>warning</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Use Mocha.configure { |c| c.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_action'>action</span><span class='embexpr_end'>}</span><span class='tstring_content'> = :warn }</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
841
|
-
<span class='kw'>end</span>
|
842
|
-
<span class='id identifier rubyid_change_config'>change_config</span> <span class='id identifier rubyid_action'>action</span><span class='comma'>,</span> <span class='symbol'>:warn</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span>
|
843
|
-
<span class='kw'>end</span></pre>
|
844
|
-
</td>
|
845
|
-
</tr>
|
846
|
-
</table>
|
847
|
-
</div>
|
848
|
-
|
849
|
-
</div>
|
850
|
-
|
851
|
-
<div id="instance_method_details" class="method_details_list">
|
852
|
-
<h2>Instance Method Details</h2>
|
853
|
-
|
854
|
-
|
855
|
-
<div class="method_details first">
|
856
|
-
<h3 class="signature first" id="display_matching_invocations_on_failure=-instance_method">
|
857
|
-
|
858
|
-
#<strong>display_matching_invocations_on_failure=</strong>(value) ⇒ <tt><span class='object_link'>Object</span></tt>
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
</h3><div class="docstring">
|
865
|
-
<div class="discussion">
|
866
|
-
|
867
|
-
<p>Display matching invocations alongside expectations on Mocha-related test failure.</p>
|
868
|
-
|
869
|
-
|
870
|
-
</div>
|
871
|
-
</div>
|
872
|
-
<div class="tags">
|
873
|
-
|
874
|
-
<div class="examples">
|
875
|
-
<p class="tag_title">Examples:</p>
|
876
|
-
|
877
|
-
|
878
|
-
<p class="example_title"><div class='inline'>
|
879
|
-
<p>Enable display of matching invocations</p>
|
880
|
-
</div></p>
|
881
|
-
|
882
|
-
<pre class="example code"><code>Mocha.configure do |c|
|
883
|
-
c.display_matching_invocations_on_failure = true
|
884
|
-
end
|
885
|
-
|
886
|
-
foo = mock('foo')
|
887
|
-
foo.expects(:bar)
|
888
|
-
foo.stubs(:baz).returns('baz').raises(RuntimeError).throws(:tag, 'value')
|
889
|
-
|
890
|
-
foo.baz(1, 2)
|
891
|
-
assert_raises(RuntimeError) { foo.baz(3, 4) }
|
892
|
-
assert_throws(:tag) { foo.baz(5, 6) }
|
893
|
-
|
894
|
-
not all expectations were satisfied
|
895
|
-
unsatisfied expectations:
|
896
|
-
- expected exactly once, invoked never: #<Mock:foo>.bar
|
897
|
-
satisfied expectations:
|
898
|
-
- allowed any number of times, invoked 3 times: #<Mock:foo>.baz(any_parameters)
|
899
|
-
- #<Mock:foo>.baz(1, 2) # => "baz"
|
900
|
-
- #<Mock:foo>.baz(3, 4) # => raised RuntimeError
|
901
|
-
- #<Mock:foo>.baz(5, 6) # => threw (:tag, "value")</code></pre>
|
902
|
-
|
903
|
-
</div>
|
904
|
-
<p class="tag_title">Parameters:</p>
|
905
|
-
<ul class="param">
|
906
|
-
|
907
|
-
<li>
|
908
|
-
|
909
|
-
<span class='name'>value</span>
|
910
|
-
|
911
|
-
|
912
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
—
|
917
|
-
<div class='inline'>
|
918
|
-
<p><code>true</code> to enable display of matching invocations; disabled by default.</p>
|
919
|
-
</div>
|
920
|
-
|
921
|
-
</li>
|
922
|
-
|
923
|
-
</ul>
|
924
|
-
|
925
|
-
|
926
|
-
</div><table class="source_code">
|
927
|
-
<tr>
|
928
|
-
<td>
|
929
|
-
<pre class="lines">
|
930
|
-
|
931
|
-
|
932
|
-
241
|
933
|
-
242
|
934
|
-
243</pre>
|
935
|
-
</td>
|
936
|
-
<td>
|
937
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 241</span>
|
938
|
-
|
939
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_display_matching_invocations_on_failure='>display_matching_invocations_on_failure=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
940
|
-
<span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:display_matching_invocations_on_failure</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
941
|
-
<span class='kw'>end</span></pre>
|
942
|
-
</td>
|
943
|
-
</tr>
|
944
|
-
</table>
|
945
|
-
</div>
|
946
|
-
|
947
|
-
<div class="method_details ">
|
948
|
-
<h3 class="signature " id="stubbing_method_on_nil=-instance_method">
|
949
|
-
|
950
|
-
#<strong>stubbing_method_on_nil=</strong>(value) ⇒ <tt><span class='object_link'>Object</span></tt>
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
</h3><div class="docstring">
|
957
|
-
<div class="discussion">
|
958
|
-
|
959
|
-
<p>Configure whether stubbing methods on the <code>nil</code> object is allowed.</p>
|
960
|
-
|
961
|
-
<p>This is usually done accidentally, but there might be rare cases where it is intended.</p>
|
962
|
-
|
963
|
-
<p>This option only works for Ruby < v2.2.0. In later versions of Ruby <code>nil</code> is frozen and so a <span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span> will be raised if you attempt to stub a method on <code>nil</code>.</p>
|
964
|
-
|
965
|
-
<p>When <code>value</code> is <code>:allow</code>, do nothing. When <code>value</code> is <code>:warn</code>, display a warning. When <code>value</code> is <code>:prevent</code>, raise a <span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span>. This is the default.</p>
|
966
|
-
|
967
|
-
|
968
|
-
</div>
|
969
|
-
</div>
|
970
|
-
<div class="tags">
|
971
|
-
<p class="tag_title">Parameters:</p>
|
972
|
-
<ul class="param">
|
973
|
-
|
974
|
-
<li>
|
975
|
-
|
976
|
-
<span class='name'>value</span>
|
977
|
-
|
978
|
-
|
979
|
-
<span class='type'>(<tt>Symbol</tt>)</span>
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
—
|
984
|
-
<div class='inline'>
|
985
|
-
<p>one of <code>:allow</code>, <code>:warn</code>, <code>:prevent</code>.</p>
|
986
|
-
</div>
|
987
|
-
|
988
|
-
</li>
|
989
|
-
|
990
|
-
</ul>
|
991
|
-
|
992
|
-
|
993
|
-
</div><table class="source_code">
|
994
|
-
<tr>
|
995
|
-
<td>
|
996
|
-
<pre class="lines">
|
997
|
-
|
998
|
-
|
999
|
-
207
|
1000
|
-
208
|
1001
|
-
209</pre>
|
1002
|
-
</td>
|
1003
|
-
<td>
|
1004
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 207</span>
|
1005
|
-
|
1006
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_stubbing_method_on_nil='>stubbing_method_on_nil=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1007
|
-
<span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:stubbing_method_on_nil</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
1008
|
-
<span class='kw'>end</span></pre>
|
1009
|
-
</td>
|
1010
|
-
</tr>
|
1011
|
-
</table>
|
1012
|
-
</div>
|
1013
|
-
|
1014
|
-
<div class="method_details ">
|
1015
|
-
<h3 class="signature " id="stubbing_method_on_non_mock_object=-instance_method">
|
1016
|
-
|
1017
|
-
#<strong>stubbing_method_on_non_mock_object=</strong>(value) ⇒ <tt><span class='object_link'>Object</span></tt>
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
</h3><div class="docstring">
|
1024
|
-
<div class="discussion">
|
1025
|
-
|
1026
|
-
<p>Configure whether stubbing methods on non-mock objects is allowed.</p>
|
1027
|
-
|
1028
|
-
<p>If you like the idea of <a href="http://www.jmock.org/oopsla2004.pdf" target="_parent" title="mocking roles not objects">mocking roles not objects</a> and <a href="http://www.mockobjects.com/2007/04/test-smell-mocking-concrete-classes.html" target="_parent" title="you don&#39;t like stubbing concrete classes">you don't like stubbing concrete classes</a>, this is the setting for you. However, while this restriction makes a lot of sense in Java with its <a href="http://java.sun.com/docs/books/tutorial/java/concepts/interface.html" target="_parent" title="explicit interfaces">explicit interfaces</a>, it may be moot in Ruby where roles are probably best represented as Modules.</p>
|
1029
|
-
|
1030
|
-
<p>When <code>value</code> is <code>:allow</code>, do nothing. This is the default. When <code>value</code> is <code>:warn</code>, display a warning. When <code>value</code> is <code>:prevent</code>, raise a <span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span>.</p>
|
1031
|
-
|
1032
|
-
|
1033
|
-
</div>
|
1034
|
-
</div>
|
1035
|
-
<div class="tags">
|
1036
|
-
|
1037
|
-
<div class="examples">
|
1038
|
-
<p class="tag_title">Examples:</p>
|
1039
|
-
|
1040
|
-
|
1041
|
-
<p class="example_title"><div class='inline'>
|
1042
|
-
<p>Preventing stubbing of a method on a non-mock object</p>
|
1043
|
-
</div></p>
|
1044
|
-
|
1045
|
-
<pre class="example code"><code><span class='const'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="../Mocha.html#configure-class_method" title="Mocha.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span>
|
1046
|
-
<span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_method_on_non_mock_object'>stubbing_method_on_non_mock_object</span> <span class='op'>=</span> <span class='symbol'>:prevent</span>
|
1047
|
-
<span class='kw'>end</span>
|
1048
|
-
|
1049
|
-
<span class='kw'>class</span> <span class='const'>Example</span>
|
1050
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_example_method'>example_method</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
1051
|
-
<span class='kw'>end</span>
|
1052
|
-
|
1053
|
-
<span class='id identifier rubyid_example'>example</span> <span class='op'>=</span> <span class='const'>Example</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
1054
|
-
<span class='id identifier rubyid_example'>example</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:example_method</span><span class='rparen'>)</span>
|
1055
|
-
<span class='comment'># => Mocha::StubbingError: stubbing method on non-mock object:
|
1056
|
-
</span><span class='comment'># => #<Example:0x593620>.example_method</span></code></pre>
|
1057
|
-
|
1058
|
-
</div>
|
1059
|
-
<p class="tag_title">Parameters:</p>
|
1060
|
-
<ul class="param">
|
1061
|
-
|
1062
|
-
<li>
|
1063
|
-
|
1064
|
-
<span class='name'>value</span>
|
1065
|
-
|
1066
|
-
|
1067
|
-
<span class='type'>(<tt>Symbol</tt>)</span>
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
—
|
1072
|
-
<div class='inline'>
|
1073
|
-
<p>one of <code>:allow</code>, <code>:warn</code>, <code>:prevent</code>.</p>
|
1074
|
-
</div>
|
1075
|
-
|
1076
|
-
</li>
|
1077
|
-
|
1078
|
-
</ul>
|
1079
|
-
|
1080
|
-
|
1081
|
-
</div><table class="source_code">
|
1082
|
-
<tr>
|
1083
|
-
<td>
|
1084
|
-
<pre class="lines">
|
1085
|
-
|
1086
|
-
|
1087
|
-
119
|
1088
|
-
120
|
1089
|
-
121</pre>
|
1090
|
-
</td>
|
1091
|
-
<td>
|
1092
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 119</span>
|
1093
|
-
|
1094
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_stubbing_method_on_non_mock_object='>stubbing_method_on_non_mock_object=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1095
|
-
<span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:stubbing_method_on_non_mock_object</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
1096
|
-
<span class='kw'>end</span></pre>
|
1097
|
-
</td>
|
1098
|
-
</tr>
|
1099
|
-
</table>
|
1100
|
-
</div>
|
1101
|
-
|
1102
|
-
<div class="method_details ">
|
1103
|
-
<h3 class="signature " id="stubbing_method_unnecessarily=-instance_method">
|
1104
|
-
|
1105
|
-
#<strong>stubbing_method_unnecessarily=</strong>(value) ⇒ <tt><span class='object_link'>Object</span></tt>
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
</h3><div class="docstring">
|
1112
|
-
<div class="discussion">
|
1113
|
-
|
1114
|
-
<p>Configure whether stubbing methods unnecessarily is allowed.</p>
|
1115
|
-
|
1116
|
-
<p>This is useful for identifying unused stubs. Unused stubs are often accidentally introduced when code is <a href="http://martinfowler.com/bliki/DefinitionOfRefactoring.html" target="_parent" title="refactored">refactored</a>.</p>
|
1117
|
-
|
1118
|
-
<p>When <code>value</code> is <code>:allow</code>, do nothing. This is the default. When <code>value</code> is <code>:warn</code>, display a warning. When <code>value</code> is <code>:prevent</code>, raise a <span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span>.</p>
|
1119
|
-
|
1120
|
-
|
1121
|
-
</div>
|
1122
|
-
</div>
|
1123
|
-
<div class="tags">
|
1124
|
-
|
1125
|
-
<div class="examples">
|
1126
|
-
<p class="tag_title">Examples:</p>
|
1127
|
-
|
1128
|
-
|
1129
|
-
<p class="example_title"><div class='inline'>
|
1130
|
-
<p>Preventing unnecessary stubbing of a method</p>
|
1131
|
-
</div></p>
|
1132
|
-
|
1133
|
-
<pre class="example code"><code><span class='const'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="../Mocha.html#configure-class_method" title="Mocha.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span>
|
1134
|
-
<span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_method_unnecessarily'>stubbing_method_unnecessarily</span> <span class='op'>=</span> <span class='symbol'>:prevent</span>
|
1135
|
-
<span class='kw'>end</span>
|
1136
|
-
|
1137
|
-
<span class='id identifier rubyid_example'>example</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'>example</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
1138
|
-
<span class='id identifier rubyid_example'>example</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:unused_stub</span><span class='rparen'>)</span>
|
1139
|
-
<span class='comment'># => Mocha::StubbingError: stubbing method unnecessarily:
|
1140
|
-
</span><span class='comment'># => #<Mock:example>.unused_stub(any_parameters)</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'>value</span>
|
1149
|
-
|
1150
|
-
|
1151
|
-
<span class='type'>(<tt>Symbol</tt>)</span>
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
—
|
1156
|
-
<div class='inline'>
|
1157
|
-
<p>one of <code>:allow</code>, <code>:warn</code>, <code>:prevent</code>.</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
|
-
86
|
1172
|
-
87
|
1173
|
-
88</pre>
|
1174
|
-
</td>
|
1175
|
-
<td>
|
1176
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 86</span>
|
1177
|
-
|
1178
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_stubbing_method_unnecessarily='>stubbing_method_unnecessarily=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1179
|
-
<span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:stubbing_method_unnecessarily</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
1180
|
-
<span class='kw'>end</span></pre>
|
1181
|
-
</td>
|
1182
|
-
</tr>
|
1183
|
-
</table>
|
1184
|
-
</div>
|
1185
|
-
|
1186
|
-
<div class="method_details ">
|
1187
|
-
<h3 class="signature " id="stubbing_non_existent_method=-instance_method">
|
1188
|
-
|
1189
|
-
#<strong>stubbing_non_existent_method=</strong>(value) ⇒ <tt><span class='object_link'>Object</span></tt>
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
</h3><div class="docstring">
|
1196
|
-
<div class="discussion">
|
1197
|
-
|
1198
|
-
<p>Configure whether stubbing of non-existent methods is allowed.</p>
|
1199
|
-
|
1200
|
-
<p>This is useful if you want to ensure that methods you're mocking really exist. A common criticism of unit tests with mock objects is that such a test may (incorrectly) pass when an equivalent non-mocking test would (correctly) fail. While you should always have some integration tests, particularly for critical business functionality, this Mocha configuration setting should catch scenarios when mocked methods and real methods have become misaligned.</p>
|
1201
|
-
|
1202
|
-
<p>When <code>value</code> is <code>:allow</code>, do nothing. This is the default. When <code>value</code> is <code>:warn</code>, display a warning. When <code>value</code> is <code>:prevent</code>, raise a <span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span>.</p>
|
1203
|
-
|
1204
|
-
|
1205
|
-
</div>
|
1206
|
-
</div>
|
1207
|
-
<div class="tags">
|
1208
|
-
|
1209
|
-
<div class="examples">
|
1210
|
-
<p class="tag_title">Examples:</p>
|
1211
|
-
|
1212
|
-
|
1213
|
-
<p class="example_title"><div class='inline'>
|
1214
|
-
<p>Preventing stubbing of a non-existent method</p>
|
1215
|
-
</div></p>
|
1216
|
-
|
1217
|
-
<pre class="example code"><code>
|
1218
|
-
<span class='const'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="../Mocha.html#configure-class_method" title="Mocha.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span>
|
1219
|
-
<span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_non_existent_method'>stubbing_non_existent_method</span> <span class='op'>=</span> <span class='symbol'>:prevent</span>
|
1220
|
-
<span class='kw'>end</span>
|
1221
|
-
|
1222
|
-
<span class='kw'>class</span> <span class='const'>Example</span>
|
1223
|
-
<span class='kw'>end</span>
|
1224
|
-
|
1225
|
-
<span class='id identifier rubyid_example'>example</span> <span class='op'>=</span> <span class='const'>Example</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
1226
|
-
<span class='id identifier rubyid_example'>example</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:method_that_doesnt_exist</span><span class='rparen'>)</span>
|
1227
|
-
<span class='comment'># => Mocha::StubbingError: stubbing non-existent method:
|
1228
|
-
</span><span class='comment'># => #<Example:0x593760>.method_that_doesnt_exist</span></code></pre>
|
1229
|
-
|
1230
|
-
</div>
|
1231
|
-
<p class="tag_title">Parameters:</p>
|
1232
|
-
<ul class="param">
|
1233
|
-
|
1234
|
-
<li>
|
1235
|
-
|
1236
|
-
<span class='name'>value</span>
|
1237
|
-
|
1238
|
-
|
1239
|
-
<span class='type'>(<tt>Symbol</tt>)</span>
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
—
|
1244
|
-
<div class='inline'>
|
1245
|
-
<p>one of <code>:allow</code>, <code>:warn</code>, <code>:prevent</code>.</p>
|
1246
|
-
</div>
|
1247
|
-
|
1248
|
-
</li>
|
1249
|
-
|
1250
|
-
</ul>
|
1251
|
-
|
1252
|
-
|
1253
|
-
</div><table class="source_code">
|
1254
|
-
<tr>
|
1255
|
-
<td>
|
1256
|
-
<pre class="lines">
|
1257
|
-
|
1258
|
-
|
1259
|
-
152
|
1260
|
-
153
|
1261
|
-
154</pre>
|
1262
|
-
</td>
|
1263
|
-
<td>
|
1264
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 152</span>
|
1265
|
-
|
1266
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_stubbing_non_existent_method='>stubbing_non_existent_method=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1267
|
-
<span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:stubbing_non_existent_method</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
1268
|
-
<span class='kw'>end</span></pre>
|
1269
|
-
</td>
|
1270
|
-
</tr>
|
1271
|
-
</table>
|
1272
|
-
</div>
|
1273
|
-
|
1274
|
-
<div class="method_details ">
|
1275
|
-
<h3 class="signature " id="stubbing_non_public_method=-instance_method">
|
1276
|
-
|
1277
|
-
#<strong>stubbing_non_public_method=</strong>(value) ⇒ <tt><span class='object_link'>Object</span></tt>
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
</h3><div class="docstring">
|
1284
|
-
<div class="discussion">
|
1285
|
-
|
1286
|
-
<p>Configure whether stubbing of non-public methods is allowed.</p>
|
1287
|
-
|
1288
|
-
<p>Many people think that it's good practice only to mock public methods. This is one way to prevent your tests being too tightly coupled to the internal implementation of a class. Such tests tend to be very brittle and not much use when refactoring.</p>
|
1289
|
-
|
1290
|
-
<p>When <code>value</code> is <code>:allow</code>, do nothing. This is the default. When <code>value</code> is <code>:warn</code>, display a warning. When <code>value</code> is <code>:prevent</code>, raise a <span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span>.</p>
|
1291
|
-
|
1292
|
-
|
1293
|
-
</div>
|
1294
|
-
</div>
|
1295
|
-
<div class="tags">
|
1296
|
-
|
1297
|
-
<div class="examples">
|
1298
|
-
<p class="tag_title">Examples:</p>
|
1299
|
-
|
1300
|
-
|
1301
|
-
<p class="example_title"><div class='inline'>
|
1302
|
-
<p>Preventing stubbing of a non-public method</p>
|
1303
|
-
</div></p>
|
1304
|
-
|
1305
|
-
<pre class="example code"><code><span class='const'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'><span class='object_link'><a href="../Mocha.html#configure-class_method" title="Mocha.configure (method)">configure</a></span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span>
|
1306
|
-
<span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_stubbing_non_public_method'>stubbing_non_public_method</span> <span class='op'>=</span> <span class='symbol'>:prevent</span>
|
1307
|
-
<span class='kw'>end</span>
|
1308
|
-
|
1309
|
-
<span class='kw'>class</span> <span class='const'>Example</span>
|
1310
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_internal_method'>internal_method</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
1311
|
-
<span class='id identifier rubyid_private'>private</span> <span class='symbol'>:internal_method</span>
|
1312
|
-
<span class='kw'>end</span>
|
1313
|
-
|
1314
|
-
<span class='id identifier rubyid_example'>example</span> <span class='op'>=</span> <span class='const'>Example</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
1315
|
-
<span class='id identifier rubyid_example'>example</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:internal_method</span><span class='rparen'>)</span>
|
1316
|
-
<span class='comment'># => Mocha::StubbingError: stubbing non-public method:
|
1317
|
-
</span><span class='comment'># => #<Example:0x593530>.internal_method</span></code></pre>
|
1318
|
-
|
1319
|
-
</div>
|
1320
|
-
<p class="tag_title">Parameters:</p>
|
1321
|
-
<ul class="param">
|
1322
|
-
|
1323
|
-
<li>
|
1324
|
-
|
1325
|
-
<span class='name'>value</span>
|
1326
|
-
|
1327
|
-
|
1328
|
-
<span class='type'>(<tt>Symbol</tt>)</span>
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
—
|
1333
|
-
<div class='inline'>
|
1334
|
-
<p>one of <code>:allow</code>, <code>:warn</code>, <code>:prevent</code>.</p>
|
1335
|
-
</div>
|
1336
|
-
|
1337
|
-
</li>
|
1338
|
-
|
1339
|
-
</ul>
|
1340
|
-
|
1341
|
-
|
1342
|
-
</div><table class="source_code">
|
1343
|
-
<tr>
|
1344
|
-
<td>
|
1345
|
-
<pre class="lines">
|
1346
|
-
|
1347
|
-
|
1348
|
-
186
|
1349
|
-
187
|
1350
|
-
188</pre>
|
1351
|
-
</td>
|
1352
|
-
<td>
|
1353
|
-
<pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 186</span>
|
1354
|
-
|
1355
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_stubbing_non_public_method='>stubbing_non_public_method=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1356
|
-
<span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:stubbing_non_public_method</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
1357
|
-
<span class='kw'>end</span></pre>
|
1358
|
-
</td>
|
1359
|
-
</tr>
|
1360
|
-
</table>
|
1361
|
-
</div>
|
1362
|
-
|
1363
|
-
</div>
|
1364
|
-
|
1365
|
-
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
|
1366
|
-
<script>
|
1367
|
-
window.dataLayer = window.dataLayer || [];
|
1368
|
-
function gtag(){dataLayer.push(arguments);}
|
1369
|
-
gtag('js', new Date());
|
1370
|
-
|
1371
|
-
gtag('config', 'UA-625523-7');
|
1372
|
-
</script>
|
1373
|
-
</div>
|
1374
|
-
|
1375
|
-
<div id="footer">
|
1376
|
-
Generated on Wed Dec 4 09:20:48 2019 by
|
1377
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1378
|
-
0.9.20 (ruby-2.6.5).
|
1379
|
-
</div>
|
1380
|
-
|
1381
|
-
</div>
|
1382
|
-
</body>
|
1383
|
-
</html>
|