mocha 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +4 -9
  3. data/README.md +17 -16
  4. data/RELEASE.md +10 -0
  5. data/Rakefile +6 -13
  6. data/bin/build-matrix +16 -2
  7. data/docs/CNAME +1 -0
  8. data/docs/Mocha.html +127 -0
  9. data/docs/Mocha/API.html +1056 -0
  10. data/docs/Mocha/ClassMethods.html +267 -0
  11. data/docs/Mocha/Configuration.html +626 -0
  12. data/docs/Mocha/Expectation.html +2709 -0
  13. data/docs/Mocha/ExpectationError.html +157 -0
  14. data/docs/Mocha/ExpectationErrorFactory.html +269 -0
  15. data/docs/Mocha/Hooks.html +385 -0
  16. data/docs/Mocha/Integration.html +125 -0
  17. data/docs/Mocha/Integration/MiniTest.html +123 -0
  18. data/docs/Mocha/Integration/MiniTest/Adapter.html +165 -0
  19. data/docs/Mocha/Integration/TestUnit.html +123 -0
  20. data/docs/Mocha/Integration/TestUnit/Adapter.html +165 -0
  21. data/docs/Mocha/Mock.html +1197 -0
  22. data/docs/Mocha/ObjectMethods.html +712 -0
  23. data/docs/Mocha/ParameterMatchers.html +3049 -0
  24. data/docs/Mocha/ParameterMatchers/AllOf.html +154 -0
  25. data/docs/Mocha/ParameterMatchers/AnyOf.html +154 -0
  26. data/docs/Mocha/ParameterMatchers/AnyParameters.html +153 -0
  27. data/docs/Mocha/ParameterMatchers/Anything.html +153 -0
  28. data/docs/Mocha/ParameterMatchers/Base.html +448 -0
  29. data/docs/Mocha/ParameterMatchers/Equals.html +154 -0
  30. data/docs/Mocha/ParameterMatchers/EquivalentUri.html +153 -0
  31. data/docs/Mocha/ParameterMatchers/HasEntries.html +154 -0
  32. data/docs/Mocha/ParameterMatchers/HasEntry.html +154 -0
  33. data/docs/Mocha/ParameterMatchers/HasKey.html +154 -0
  34. data/docs/Mocha/ParameterMatchers/HasValue.html +154 -0
  35. data/docs/Mocha/ParameterMatchers/Includes.html +154 -0
  36. data/docs/Mocha/ParameterMatchers/InstanceOf.html +154 -0
  37. data/docs/Mocha/ParameterMatchers/IsA.html +153 -0
  38. data/docs/Mocha/ParameterMatchers/KindOf.html +154 -0
  39. data/docs/Mocha/ParameterMatchers/Not.html +154 -0
  40. data/docs/Mocha/ParameterMatchers/Optionally.html +153 -0
  41. data/docs/Mocha/ParameterMatchers/RegexpMatches.html +154 -0
  42. data/docs/Mocha/ParameterMatchers/RespondsWith.html +154 -0
  43. data/docs/Mocha/ParameterMatchers/YamlEquivalent.html +154 -0
  44. data/docs/Mocha/Sequence.html +149 -0
  45. data/docs/Mocha/StateMachine.html +539 -0
  46. data/docs/Mocha/StateMachine/State.html +141 -0
  47. data/docs/Mocha/StateMachine/StatePredicate.html +141 -0
  48. data/docs/Mocha/StubbingError.html +150 -0
  49. data/docs/Mocha/UnexpectedInvocation.html +140 -0
  50. data/docs/_index.html +537 -0
  51. data/docs/class_list.html +51 -0
  52. data/docs/css/common.css +1 -0
  53. data/docs/css/full_list.css +58 -0
  54. data/docs/css/style.css +496 -0
  55. data/docs/file.COPYING.html +81 -0
  56. data/docs/file.MIT-LICENSE.html +85 -0
  57. data/docs/file.README.html +418 -0
  58. data/docs/file.RELEASE.html +875 -0
  59. data/docs/file_list.html +71 -0
  60. data/docs/frames.html +17 -0
  61. data/docs/index.html +418 -0
  62. data/docs/js/app.js +292 -0
  63. data/docs/js/full_list.js +216 -0
  64. data/docs/js/jquery.js +4 -0
  65. data/docs/method_list.html +571 -0
  66. data/docs/top-level-namespace.html +118 -0
  67. data/lib/mocha/inspect.rb +1 -1
  68. data/lib/mocha/version.rb +1 -1
  69. data/mocha.gemspec +2 -3
  70. data/test/unit/object_inspect_test.rb +10 -0
  71. data/yard-templates/default/layout/html/google_analytics.erb +6 -9
  72. metadata +68 -36
@@ -0,0 +1,267 @@
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
+ &mdash; Mocha 1.8.0
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> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span>
41
+ &raquo;
42
+ <span class="title">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.
90
+ non-mock) objects.</p>
91
+
92
+
93
+ </div>
94
+ </div>
95
+ <div class="tags">
96
+
97
+
98
+ </div>
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+ <h2>
107
+ Instance Method Summary
108
+ <small><a href="#" class="summary_toggle">collapse</a></small>
109
+ </h2>
110
+
111
+ <ul class="summary">
112
+
113
+ <li class="public ">
114
+ <span class="summary_signature">
115
+
116
+ <a href="#any_instance-instance_method" title="#any_instance (instance method)">#<strong>any_instance</strong> &#x21d2; Mock </a>
117
+
118
+
119
+
120
+ </span>
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+ <span class="summary_desc"><div class='inline'>
131
+ <p>A mock object which will detect calls to any instance of this class.</p>
132
+ </div></span>
133
+
134
+ </li>
135
+
136
+
137
+ </ul>
138
+
139
+
140
+
141
+
142
+ <div id="instance_method_details" class="method_details_list">
143
+ <h2>Instance Method Details</h2>
144
+
145
+
146
+ <div class="method_details first">
147
+ <h3 class="signature first" id="any_instance-instance_method">
148
+
149
+ #<strong>any_instance</strong> &#x21d2; <tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>
150
+
151
+
152
+
153
+
154
+
155
+ </h3><div class="docstring">
156
+ <div class="discussion">
157
+
158
+ <p>Returns a mock object which will detect calls to any instance of this
159
+ class.</p>
160
+
161
+
162
+ </div>
163
+ </div>
164
+ <div class="tags">
165
+
166
+ <div class="examples">
167
+ <p class="tag_title">Examples:</p>
168
+
169
+
170
+ <p class="example_title"><div class='inline'>
171
+ <p>Return false to invocation of <tt>Product#save</tt> for any instance of
172
+ <code>Product</code>.</p>
173
+ </div></p>
174
+
175
+ <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>
176
+ <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>
177
+ <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>
178
+ <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>
179
+ <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>
180
+
181
+ </div>
182
+
183
+ <p class="tag_title">Returns:</p>
184
+ <ul class="return">
185
+
186
+ <li>
187
+
188
+
189
+ <span class='type'>(<tt><span class='object_link'><a href="Mock.html" title="Mocha::Mock (class)">Mock</a></span></tt>)</span>
190
+
191
+
192
+
193
+ &mdash;
194
+ <div class='inline'>
195
+ <p>a mock object which will detect calls to any instance of this class.</p>
196
+ </div>
197
+
198
+ </li>
199
+
200
+ </ul>
201
+ <p class="tag_title">Raises:</p>
202
+ <ul class="raise">
203
+
204
+ <li>
205
+
206
+
207
+ <span class='type'>(<tt><span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span></tt>)</span>
208
+
209
+
210
+
211
+ &mdash;
212
+ <div class='inline'>
213
+ <p>if attempting to stub method which is not allowed.</p>
214
+ </div>
215
+
216
+ </li>
217
+
218
+ </ul>
219
+
220
+ </div><table class="source_code">
221
+ <tr>
222
+ <td>
223
+ <pre class="lines">
224
+
225
+
226
+ 53
227
+ 54
228
+ 55
229
+ 56
230
+ 57
231
+ 58</pre>
232
+ </td>
233
+ <td>
234
+ <pre class="code"><span class="info file"># File 'lib/mocha/class_methods.rb', line 53</span>
235
+
236
+ <span class='kw'>def</span> <span class='id identifier rubyid_any_instance'>any_instance</span>
237
+ <span class='kw'>if</span> <span class='id identifier rubyid_frozen?'>frozen?</span>
238
+ <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'>&quot;</span><span class='tstring_content'>can&#39;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'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span><span class='rparen'>)</span>
239
+ <span class='kw'>end</span>
240
+ <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>
241
+ <span class='kw'>end</span></pre>
242
+ </td>
243
+ </tr>
244
+ </table>
245
+ </div>
246
+
247
+ </div>
248
+
249
+ <script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
250
+ <script>
251
+ window.dataLayer = window.dataLayer || [];
252
+ function gtag(){dataLayer.push(arguments);}
253
+ gtag('js', new Date());
254
+
255
+ gtag('config', 'UA-625523-7');
256
+ </script>
257
+ </div>
258
+
259
+ <div id="footer">
260
+ Generated on Tue Jan 15 17:13:05 2019 by
261
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
262
+ 0.9.16 (ruby-2.5.3).
263
+ </div>
264
+
265
+ </div>
266
+ </body>
267
+ </html>
@@ -0,0 +1,626 @@
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
+ &mdash; Mocha 1.8.0
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> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span>
41
+ &raquo;
42
+ <span class="title">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 allows you to determine what should happen under certain
106
+ circumstances. In each scenario, Mocha can be configured to <span class='object_link'><a href="#allow-class_method" title="Mocha::Configuration.allow (method)">do nothing</a></span>, <span class='object_link'><a href="#warn_when-class_method" title="Mocha::Configuration.warn_when (method)">display a warning message</a></span>, or <span class='object_link'><a href="#prevent-class_method" title="Mocha::Configuration.prevent (method)">raise an exception</a></span>. The relevant scenario is identified using one of the following
107
+ symbols:</p>
108
+ <ul><li>
109
+ <p><code>:stubbing_method_unnecessarily</code> This is useful for identifying
110
+ unused stubs. Unused stubs are often accidentally introduced when code is
111
+ <a href="http://martinfowler.com/bliki/DefinitionOfRefactoring.html" target="_parent" title="refactored">refactored</a>.
112
+ Allowed by default.</p>
113
+ </li><li>
114
+ <p><code>:stubbing_non_existent_method</code> - This is useful if you want to
115
+ ensure that methods you&#39;re mocking really exist. A common criticism of
116
+ unit tests with mock objects is that such a test may (incorrectly) pass
117
+ when an equivalent non-mocking test would (correctly) fail. While you
118
+ should always have some integration tests, particularly for critical
119
+ business functionality, this Mocha configuration setting should catch
120
+ scenarios when mocked methods and real methods have become misaligned.
121
+ Allowed by default.</p>
122
+ </li><li>
123
+ <p><code>:stubbing_non_public_method</code> - Many people think that it&#39;s
124
+ good practice only to mock public methods. This is one way to prevent your
125
+ tests being too tightly coupled to the internal implementation of a class.
126
+ Such tests tend to be very brittle and not much use when refactoring.
127
+ Allowed by default.</p>
128
+ </li><li>
129
+ <p><code>:stubbing_method_on_non_mock_object</code> - If you like the idea of
130
+ <a href="http://www.jmock.org/oopsla2004.pdf" target="_parent" title="mocking roles not objects">mocking roles not objects</a> and
131
+ <a href="http://www.mockobjects.com/2007/04/test-smell-mocking-concrete-classes.html" target="_parent" title="you don&amp;#39;t like stubbing concrete classes">you don&#39;t like stubbing concrete classes</a>, this is the setting for you.
132
+ However, while this restriction makes a lot of sense in Java with its
133
+ <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
134
+ represented as Modules. Allowed by default.</p>
135
+ </li><li>
136
+ <p><code>:stubbing_method_on_nil</code> - This is usually done accidentally,
137
+ but there might be rare cases where it is intended. Prevented by default.</p>
138
+ </li></ul>
139
+
140
+ <p>Typically the configuration would be set globally in a
141
+ <code>test_helper.rb</code> or <code>spec_helper.rb</code> file. However,
142
+ it can also be temporarily overridden locally using the block syntax of the
143
+ relevant method. In the latter case, the original configuration settings
144
+ are restored when the block is exited.</p>
145
+
146
+
147
+ </div>
148
+ </div>
149
+ <div class="tags">
150
+
151
+ <div class="examples">
152
+ <p class="tag_title">Examples:</p>
153
+
154
+
155
+ <p class="example_title"><div class='inline'>
156
+ <p>Preventing unnecessary stubbing of a method</p>
157
+ </div></p>
158
+
159
+ <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'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_prevent'><span class='object_link'><a href="#prevent-class_method" title="Mocha::Configuration.prevent (method)">prevent</a></span></span><span class='lparen'>(</span><span class='symbol'>:stubbing_method_unnecessarily</span><span class='rparen'>)</span>
160
+
161
+ <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'>&#39;</span><span class='tstring_content'>example</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
162
+ <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>
163
+ <span class='comment'># =&gt; Mocha::StubbingError: stubbing method unnecessarily:
164
+ </span><span class='comment'># =&gt; #&lt;Mock:example&gt;.unused_stub(any_parameters)</span></code></pre>
165
+
166
+
167
+ <p class="example_title"><div class='inline'>
168
+ <p>Preventing stubbing of a method on a non-mock object</p>
169
+ </div></p>
170
+
171
+ <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'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_prevent'><span class='object_link'><a href="#prevent-class_method" title="Mocha::Configuration.prevent (method)">prevent</a></span></span><span class='lparen'>(</span><span class='symbol'>:stubbing_method_on_non_mock_object</span><span class='rparen'>)</span>
172
+
173
+ <span class='kw'>class</span> <span class='const'>Example</span>
174
+ <span class='kw'>def</span> <span class='id identifier rubyid_example_method'>example_method</span><span class='semicolon'>;</span> <span class='kw'>end</span>
175
+ <span class='kw'>end</span>
176
+
177
+ <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>
178
+ <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>
179
+ <span class='comment'># =&gt; Mocha::StubbingError: stubbing method on non-mock object:
180
+ </span><span class='comment'># =&gt; #&lt;Example:0x593620&gt;.example_method</span></code></pre>
181
+
182
+
183
+ <p class="example_title"><div class='inline'>
184
+ <p>Preventing stubbing of a non-existent method</p>
185
+ </div></p>
186
+
187
+ <pre class="example code"><code>
188
+ <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'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_prevent'><span class='object_link'><a href="#prevent-class_method" title="Mocha::Configuration.prevent (method)">prevent</a></span></span><span class='lparen'>(</span><span class='symbol'>:stubbing_non_existent_method</span><span class='rparen'>)</span>
189
+
190
+ <span class='kw'>class</span> <span class='const'>Example</span>
191
+ <span class='kw'>end</span>
192
+
193
+ <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>
194
+ <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>
195
+ <span class='comment'># =&gt; Mocha::StubbingError: stubbing non-existent method:
196
+ </span><span class='comment'># =&gt; #&lt;Example:0x593760&gt;.method_that_doesnt_exist</span></code></pre>
197
+
198
+
199
+ <p class="example_title"><div class='inline'>
200
+ <p>Preventing stubbing of a non-public method</p>
201
+ </div></p>
202
+
203
+ <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'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_prevent'><span class='object_link'><a href="#prevent-class_method" title="Mocha::Configuration.prevent (method)">prevent</a></span></span><span class='lparen'>(</span><span class='symbol'>:stubbing_non_public_method</span><span class='rparen'>)</span>
204
+
205
+ <span class='kw'>class</span> <span class='const'>Example</span>
206
+ <span class='kw'>def</span> <span class='id identifier rubyid_internal_method'>internal_method</span><span class='semicolon'>;</span> <span class='kw'>end</span>
207
+ <span class='id identifier rubyid_private'>private</span> <span class='symbol'>:internal_method</span>
208
+ <span class='kw'>end</span>
209
+
210
+ <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>
211
+ <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>
212
+ <span class='comment'># =&gt; Mocha::StubbingError: stubbing non-public method:
213
+ </span><span class='comment'># =&gt; #&lt;Example:0x593530&gt;.internal_method</span></code></pre>
214
+
215
+
216
+ <p class="example_title"><div class='inline'>
217
+ <p>Temporarily allowing stubbing of a non-existent method</p>
218
+ </div></p>
219
+
220
+ <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'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_prevent'><span class='object_link'><a href="#prevent-class_method" title="Mocha::Configuration.prevent (method)">prevent</a></span></span><span class='lparen'>(</span><span class='symbol'>:stubbing_non_public_method</span><span class='rparen'>)</span>
221
+
222
+ <span class='kw'>class</span> <span class='const'>Example</span>
223
+ <span class='kw'>end</span>
224
+
225
+ <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'>Configuration</span><span class='period'>.</span><span class='id identifier rubyid_allow'><span class='object_link'><a href="#allow-class_method" title="Mocha::Configuration.allow (method)">allow</a></span></span><span class='lparen'>(</span><span class='symbol'>:stubbing_non_existent_method</span><span class='rparen'>)</span> <span class='kw'>do</span>
226
+ <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>
227
+ <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>
228
+ <span class='comment'># =&gt; no exception raised
229
+ </span><span class='kw'>end</span></code></pre>
230
+
231
+ </div>
232
+
233
+
234
+ </div>
235
+
236
+ <h2>
237
+ Constant Summary
238
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
239
+ </h2>
240
+
241
+ <dl class="constants">
242
+
243
+ <dt id="DEFAULTS-constant" class="">DEFAULTS =
244
+
245
+ </dt>
246
+ <dd><pre class="code"><span class='lbrace'>{</span>
247
+ <span class='symbol'>:stubbing_method_unnecessarily</span> <span class='op'>=&gt;</span> <span class='symbol'>:allow</span><span class='comma'>,</span>
248
+ <span class='symbol'>:stubbing_method_on_non_mock_object</span> <span class='op'>=&gt;</span> <span class='symbol'>:allow</span><span class='comma'>,</span>
249
+ <span class='symbol'>:stubbing_non_existent_method</span> <span class='op'>=&gt;</span> <span class='symbol'>:allow</span><span class='comma'>,</span>
250
+ <span class='symbol'>:stubbing_non_public_method</span> <span class='op'>=&gt;</span> <span class='symbol'>:allow</span><span class='comma'>,</span>
251
+ <span class='symbol'>:stubbing_method_on_nil</span> <span class='op'>=&gt;</span> <span class='symbol'>:prevent</span>
252
+ <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
253
+
254
+ </dl>
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+ <h2>
265
+ Class Method Summary
266
+ <small><a href="#" class="summary_toggle">collapse</a></small>
267
+ </h2>
268
+
269
+ <ul class="summary">
270
+
271
+ <li class="public ">
272
+ <span class="summary_signature">
273
+
274
+ <a href="#allow-class_method" title="allow (class method)">.<strong>allow</strong>(action) { ... } &#x21d2; Object </a>
275
+
276
+
277
+
278
+ </span>
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+ <span class="summary_desc"><div class='inline'>
289
+ <p>Allow the specified <code>action</code>.</p>
290
+ </div></span>
291
+
292
+ </li>
293
+
294
+
295
+ <li class="public ">
296
+ <span class="summary_signature">
297
+
298
+ <a href="#prevent-class_method" title="prevent (class method)">.<strong>prevent</strong>(action) { ... } &#x21d2; Object </a>
299
+
300
+
301
+
302
+ </span>
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+ <span class="summary_desc"><div class='inline'>
313
+ <p>Raise a <span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span> if if the specified <code>action</code> is
314
+ attempted.</p>
315
+ </div></span>
316
+
317
+ </li>
318
+
319
+
320
+ <li class="public ">
321
+ <span class="summary_signature">
322
+
323
+ <a href="#warn_when-class_method" title="warn_when (class method)">.<strong>warn_when</strong>(action) { ... } &#x21d2; Object </a>
324
+
325
+
326
+
327
+ </span>
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+ <span class="summary_desc"><div class='inline'>
338
+ <p>Warn if the specified <code>action</code> is attempted.</p>
339
+ </div></span>
340
+
341
+ </li>
342
+
343
+
344
+ </ul>
345
+
346
+
347
+
348
+
349
+ <div id="class_method_details" class="method_details_list">
350
+ <h2>Class Method Details</h2>
351
+
352
+
353
+ <div class="method_details first">
354
+ <h3 class="signature first" id="allow-class_method">
355
+
356
+ .<strong>allow</strong>(action) { ... } &#x21d2; <tt><span class='object_link'>Object</span></tt>
357
+
358
+
359
+
360
+
361
+
362
+ </h3><div class="docstring">
363
+ <div class="discussion">
364
+
365
+ <p>Allow the specified <code>action</code>.</p>
366
+
367
+
368
+ </div>
369
+ </div>
370
+ <div class="tags">
371
+ <p class="tag_title">Parameters:</p>
372
+ <ul class="param">
373
+
374
+ <li>
375
+
376
+ <span class='name'>action</span>
377
+
378
+
379
+ <span class='type'>(<tt>Symbol</tt>)</span>
380
+
381
+
382
+
383
+ &mdash;
384
+ <div class='inline'>
385
+ <p>one of <code>:stubbing_method_unnecessarily</code>,
386
+ <code>:stubbing_method_on_non_mock_object</code>,
387
+ <code>:stubbing_non_existent_method</code>,
388
+ <code>:stubbing_non_public_method</code>,
389
+ <code>:stubbing_method_on_nil</code>.</p>
390
+ </div>
391
+
392
+ </li>
393
+
394
+ </ul>
395
+
396
+ <p class="tag_title">Yields:</p>
397
+ <ul class="yield">
398
+
399
+ <li>
400
+
401
+
402
+ <span class='type'></span>
403
+
404
+
405
+
406
+
407
+ <div class='inline'>
408
+ <p>optional block during which the configuration change will be changed before
409
+ being returned to its original value at the end of the block.</p>
410
+ </div>
411
+
412
+ </li>
413
+
414
+ </ul>
415
+
416
+ </div><table class="source_code">
417
+ <tr>
418
+ <td>
419
+ <pre class="lines">
420
+
421
+
422
+ 82
423
+ 83
424
+ 84</pre>
425
+ </td>
426
+ <td>
427
+ <pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 82</span>
428
+
429
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
430
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span>
431
+ <span class='kw'>end</span></pre>
432
+ </td>
433
+ </tr>
434
+ </table>
435
+ </div>
436
+
437
+ <div class="method_details ">
438
+ <h3 class="signature " id="prevent-class_method">
439
+
440
+ .<strong>prevent</strong>(action) { ... } &#x21d2; <tt><span class='object_link'>Object</span></tt>
441
+
442
+
443
+
444
+
445
+
446
+ </h3><div class="docstring">
447
+ <div class="discussion">
448
+
449
+ <p>Raise a <span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span> if if the specified <code>action</code> is
450
+ attempted.</p>
451
+
452
+
453
+ </div>
454
+ </div>
455
+ <div class="tags">
456
+ <p class="tag_title">Parameters:</p>
457
+ <ul class="param">
458
+
459
+ <li>
460
+
461
+ <span class='name'>action</span>
462
+
463
+
464
+ <span class='type'>(<tt>Symbol</tt>)</span>
465
+
466
+
467
+
468
+ &mdash;
469
+ <div class='inline'>
470
+ <p>one of <code>:stubbing_method_unnecessarily</code>,
471
+ <code>:stubbing_method_on_non_mock_object</code>,
472
+ <code>:stubbing_non_existent_method</code>,
473
+ <code>:stubbing_non_public_method</code>,
474
+ <code>:stubbing_method_on_nil</code>.</p>
475
+ </div>
476
+
477
+ </li>
478
+
479
+ </ul>
480
+
481
+ <p class="tag_title">Yields:</p>
482
+ <ul class="yield">
483
+
484
+ <li>
485
+
486
+
487
+ <span class='type'></span>
488
+
489
+
490
+
491
+
492
+ <div class='inline'>
493
+ <p>optional block during which the configuration change will be changed before
494
+ being returned to its original value at the end of the block.</p>
495
+ </div>
496
+
497
+ </li>
498
+
499
+ </ul>
500
+
501
+ </div><table class="source_code">
502
+ <tr>
503
+ <td>
504
+ <pre class="lines">
505
+
506
+
507
+ 108
508
+ 109
509
+ 110</pre>
510
+ </td>
511
+ <td>
512
+ <pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 108</span>
513
+
514
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
515
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span>
516
+ <span class='kw'>end</span></pre>
517
+ </td>
518
+ </tr>
519
+ </table>
520
+ </div>
521
+
522
+ <div class="method_details ">
523
+ <h3 class="signature " id="warn_when-class_method">
524
+
525
+ .<strong>warn_when</strong>(action) { ... } &#x21d2; <tt><span class='object_link'>Object</span></tt>
526
+
527
+
528
+
529
+
530
+
531
+ </h3><div class="docstring">
532
+ <div class="discussion">
533
+
534
+ <p>Warn if the specified <code>action</code> is attempted.</p>
535
+
536
+
537
+ </div>
538
+ </div>
539
+ <div class="tags">
540
+ <p class="tag_title">Parameters:</p>
541
+ <ul class="param">
542
+
543
+ <li>
544
+
545
+ <span class='name'>action</span>
546
+
547
+
548
+ <span class='type'>(<tt>Symbol</tt>)</span>
549
+
550
+
551
+
552
+ &mdash;
553
+ <div class='inline'>
554
+ <p>one of <code>:stubbing_method_unnecessarily</code>,
555
+ <code>:stubbing_method_on_non_mock_object</code>,
556
+ <code>:stubbing_non_existent_method</code>,
557
+ <code>:stubbing_non_public_method</code>,
558
+ <code>:stubbing_method_on_nil</code>.</p>
559
+ </div>
560
+
561
+ </li>
562
+
563
+ </ul>
564
+
565
+ <p class="tag_title">Yields:</p>
566
+ <ul class="yield">
567
+
568
+ <li>
569
+
570
+
571
+ <span class='type'></span>
572
+
573
+
574
+
575
+
576
+ <div class='inline'>
577
+ <p>optional block during which the configuration change will be changed before
578
+ being returned to its original value at the end of the block.</p>
579
+ </div>
580
+
581
+ </li>
582
+
583
+ </ul>
584
+
585
+ </div><table class="source_code">
586
+ <tr>
587
+ <td>
588
+ <pre class="lines">
589
+
590
+
591
+ 95
592
+ 96
593
+ 97</pre>
594
+ </td>
595
+ <td>
596
+ <pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 95</span>
597
+
598
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
599
+ <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'>&amp;</span><span class='id identifier rubyid_block'>block</span>
600
+ <span class='kw'>end</span></pre>
601
+ </td>
602
+ </tr>
603
+ </table>
604
+ </div>
605
+
606
+ </div>
607
+
608
+ <script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script>
609
+ <script>
610
+ window.dataLayer = window.dataLayer || [];
611
+ function gtag(){dataLayer.push(arguments);}
612
+ gtag('js', new Date());
613
+
614
+ gtag('config', 'UA-625523-7');
615
+ </script>
616
+ </div>
617
+
618
+ <div id="footer">
619
+ Generated on Tue Jan 15 17:13:06 2019 by
620
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
621
+ 0.9.16 (ruby-2.5.3).
622
+ </div>
623
+
624
+ </div>
625
+ </body>
626
+ </html>