mocha 0.11.3 → 0.11.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/README.rdoc +3 -3
  2. data/RELEASE.rdoc +3 -0
  3. data/Rakefile +1 -3
  4. data/lib/mocha/version.rb +1 -1
  5. data/mocha.gemspec +1 -1
  6. metadata +12 -67
  7. data/doc/.nojekyll +0 -0
  8. data/doc/Mocha.html +0 -112
  9. data/doc/Mocha/API.html +0 -898
  10. data/doc/Mocha/ClassMethods.html +0 -246
  11. data/doc/Mocha/Configuration.html +0 -471
  12. data/doc/Mocha/Expectation.html +0 -2570
  13. data/doc/Mocha/Mock.html +0 -830
  14. data/doc/Mocha/ObjectMethods.html +0 -668
  15. data/doc/Mocha/ParameterMatchers.html +0 -2715
  16. data/doc/Mocha/ParameterMatchers/AllOf.html +0 -137
  17. data/doc/Mocha/ParameterMatchers/AnyOf.html +0 -137
  18. data/doc/Mocha/ParameterMatchers/AnyParameters.html +0 -136
  19. data/doc/Mocha/ParameterMatchers/Anything.html +0 -136
  20. data/doc/Mocha/ParameterMatchers/Base.html +0 -419
  21. data/doc/Mocha/ParameterMatchers/Equals.html +0 -137
  22. data/doc/Mocha/ParameterMatchers/HasEntries.html +0 -137
  23. data/doc/Mocha/ParameterMatchers/HasEntry.html +0 -137
  24. data/doc/Mocha/ParameterMatchers/HasKey.html +0 -137
  25. data/doc/Mocha/ParameterMatchers/HasValue.html +0 -137
  26. data/doc/Mocha/ParameterMatchers/Includes.html +0 -137
  27. data/doc/Mocha/ParameterMatchers/InstanceOf.html +0 -137
  28. data/doc/Mocha/ParameterMatchers/IsA.html +0 -136
  29. data/doc/Mocha/ParameterMatchers/KindOf.html +0 -137
  30. data/doc/Mocha/ParameterMatchers/Not.html +0 -137
  31. data/doc/Mocha/ParameterMatchers/Optionally.html +0 -136
  32. data/doc/Mocha/ParameterMatchers/QueryStringMatches.html +0 -136
  33. data/doc/Mocha/ParameterMatchers/RegexpMatches.html +0 -137
  34. data/doc/Mocha/ParameterMatchers/RespondsWith.html +0 -137
  35. data/doc/Mocha/ParameterMatchers/YamlEquivalent.html +0 -137
  36. data/doc/Mocha/Sequence.html +0 -133
  37. data/doc/Mocha/StateMachine.html +0 -510
  38. data/doc/Mocha/StateMachine/State.html +0 -125
  39. data/doc/Mocha/StateMachine/StatePredicate.html +0 -125
  40. data/doc/Mocha/StubbingError.html +0 -134
  41. data/doc/Mocha/UnexpectedInvocation.html +0 -124
  42. data/doc/_index.html +0 -481
  43. data/doc/class_list.html +0 -47
  44. data/doc/css/common.css +0 -1
  45. data/doc/css/full_list.css +0 -55
  46. data/doc/css/style.css +0 -322
  47. data/doc/file.COPYING.html +0 -72
  48. data/doc/file.MIT-LICENSE.html +0 -86
  49. data/doc/file.README.html +0 -153
  50. data/doc/file.RELEASE.html +0 -954
  51. data/doc/file.misc.html +0 -108
  52. data/doc/file.mocha.html +0 -90
  53. data/doc/file.stubba.html +0 -129
  54. data/doc/file_list.html +0 -67
  55. data/doc/frames.html +0 -13
  56. data/doc/index.html +0 -153
  57. data/doc/js/app.js +0 -205
  58. data/doc/js/full_list.js +0 -173
  59. data/doc/js/jquery.js +0 -16
  60. data/doc/method_list.html +0 -510
  61. data/doc/top-level-namespace.html +0 -105
@@ -1,668 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
- <title>
7
- Module: Mocha::ObjectMethods
8
-
9
- &mdash; Mocha 0.11.3
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
-
15
- <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
-
17
- <script type="text/javascript" charset="utf-8">
18
- relpath = '..';
19
- if (relpath != '') relpath += '/';
20
- </script>
21
-
22
- <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
23
-
24
- <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
25
-
26
-
27
- </head>
28
- <body>
29
- <script type="text/javascript" charset="utf-8">
30
- if (window.top.frames.main) document.body.className = 'frames';
31
- </script>
32
-
33
- <div id="header">
34
- <div id="menu">
35
-
36
- <a href="../_index.html">Index (O)</a> &raquo;
37
- <span class='title'><span class='object_link'><a href="../Mocha.html" title="Mocha (module)">Mocha</a></span></span>
38
- &raquo;
39
- <span class="title">ObjectMethods</span>
40
-
41
-
42
- <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
- </div>
44
-
45
- <div id="search">
46
-
47
- <a id="class_list_link" href="#">Class List</a>
48
-
49
- <a id="method_list_link" href="#">Method List</a>
50
-
51
- <a id="file_list_link" href="#">File List</a>
52
-
53
- </div>
54
- <div class="clear"></div>
55
- </div>
56
-
57
- <iframe id="search_frame"></iframe>
58
-
59
- <div id="content"><h1>Module: Mocha::ObjectMethods
60
-
61
-
62
-
63
- </h1>
64
-
65
- <dl class="box">
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
- <dt class="r1 last">Defined in:</dt>
75
- <dd class="r1 last">lib/mocha/object.rb<span class="defines">,<br />
76
- lib/mocha/parameter_matchers/object.rb</span>
77
- </dd>
78
-
79
- </dl>
80
- <div class="clear"></div>
81
-
82
- <h2>Overview</h2><div class="docstring">
83
- <div class="discussion">
84
-
85
- <p>Methods added to all objects to allow mocking and stubbing on real (i.e.
86
- non-mock) objects.</p>
87
-
88
- <p>Both <span class='object_link'><a href="#expects-instance_method" title="Mocha::ObjectMethods#expects (method)">#expects</a></span> and <span class='object_link'><a href="#stubs-instance_method" title="Mocha::ObjectMethods#stubs (method)">#stubs</a></span> return an <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span> which can be further
89
- modified by methods on <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</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="#expects-instance_method" title="#expects (instance method)">- (Expectation) <strong>expects</strong>(expected_methods_vs_return_values) </a>
116
-
117
-
118
-
119
- </span>
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
- <span class="summary_desc"><div class='inline'>
129
- <p>Adds an expectation that the specified method must be called exactly once
130
- with any parameters.</p>
131
- </div></span>
132
-
133
- </li>
134
-
135
-
136
- <li class="public ">
137
- <span class="summary_signature">
138
-
139
- <a href="#stubs-instance_method" title="#stubs (instance method)">- (Expectation) <strong>stubs</strong>(stubbed_methods_vs_return_values) </a>
140
-
141
-
142
-
143
- </span>
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
- <span class="summary_desc"><div class='inline'>
153
- <p>Adds an expectation that the specified method may be called any number of
154
- times with any parameters.</p>
155
- </div></span>
156
-
157
- </li>
158
-
159
-
160
- <li class="public ">
161
- <span class="summary_signature">
162
-
163
- <a href="#unstub-instance_method" title="#unstub (instance method)">- (Object) <strong>unstub</strong>(*method_names) </a>
164
-
165
-
166
-
167
- </span>
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
- <span class="summary_desc"><div class='inline'>
177
- <p>Removes the specified stubbed methods (added by calls to <span class='object_link'><a href="#expects-instance_method" title="Mocha::ObjectMethods#expects (method)">#expects</a></span> or
178
- <span class='object_link'><a href="#stubs-instance_method" title="Mocha::ObjectMethods#stubs (method)">#stubs</a></span>) and all expectations associated with them.</p>
179
- </div></span>
180
-
181
- </li>
182
-
183
-
184
- </ul>
185
-
186
-
187
-
188
-
189
- <div id="instance_method_details" class="method_details_list">
190
- <h2>Instance Method Details</h2>
191
-
192
-
193
- <div class="method_details first">
194
- <p class="signature first" id="expects-instance_method">
195
-
196
-
197
- <span class="overload">- (<tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt>) <strong>expects</strong>(method_name) </span>
198
-
199
- <span class="overload">- (<tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt>) <strong>expects</strong>(expected_methods_vs_return_values) </span>
200
-
201
-
202
-
203
-
204
- </p><div class="docstring">
205
- <div class="discussion">
206
-
207
- <p>Adds an expectation that the specified method must be called exactly once
208
- with any parameters.</p>
209
-
210
- <p>The original implementation of the method is replaced during the test and
211
- then restored at the end of the test.</p>
212
-
213
-
214
- </div>
215
- </div>
216
- <div class="tags">
217
-
218
- <div class="examples">
219
- <h3>Examples:</h3>
220
-
221
- <h4><div class='inline'>
222
- <p>Setting up an expectation on a non-mock object.</p>
223
- </div></h4>
224
- <pre class="example code"><span class='id identifier rubyid_product'>product</span> <span class='op'>=</span> <span class='const'>Product</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
225
- <span class='id identifier rubyid_product'>product</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</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'>true</span><span class='rparen'>)</span>
226
- <span class='id identifier rubyid_assert_equal'>assert_equal</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_product'>product</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span></pre>
227
-
228
- <h4><div class='inline'>
229
- <p>Setting up multiple expectations on a non-mock object.</p>
230
- </div></h4>
231
- <pre class="example code"><span class='id identifier rubyid_product'>product</span> <span class='op'>=</span> <span class='const'>Product</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
232
- <span class='id identifier rubyid_product'>product</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:valid?</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:save</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='rparen'>)</span>
233
-
234
- <span class='comment'># exactly equivalent to
235
- </span>
236
- <span class='id identifier rubyid_product'>product</span> <span class='op'>=</span> <span class='const'>Product</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
237
- <span class='id identifier rubyid_product'>product</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='symbol'>:valid?</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span>
238
- <span class='id identifier rubyid_product'>product</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</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'>true</span><span class='rparen'>)</span></pre>
239
-
240
- </div>
241
- <h3>Parameters:</h3>
242
- <ul class="param">
243
-
244
- <li>
245
-
246
- <span class='name'>method_name</span>
247
-
248
-
249
- <span class='type'>(<tt>Symbol</tt>, <tt>String</tt>)</span>
250
-
251
-
252
-
253
- &mdash;
254
- <div class='inline'>
255
- <p>name of expected method</p>
256
- </div>
257
-
258
- </li>
259
-
260
- <li>
261
-
262
- <span class='name'>expected_methods_vs_return_values</span>
263
-
264
-
265
- <span class='type'>(<tt>Hash</tt>)</span>
266
-
267
-
268
-
269
- &mdash;
270
- <div class='inline'>
271
- <p>expected method name symbols as keys and corresponding return values as
272
- values - these expectations are setup as if <span class='object_link'><a href="#expects-instance_method" title="Mocha::ObjectMethods#expects (method)">#expects</a></span> were called multiple
273
- times.</p>
274
- </div>
275
-
276
- </li>
277
-
278
- </ul>
279
-
280
- <h3>Returns:</h3>
281
- <ul class="return">
282
-
283
- <li>
284
-
285
-
286
- <span class='type'>(<tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt>)</span>
287
-
288
-
289
-
290
- &mdash;
291
- <div class='inline'>
292
- <p>last-built expectation which can be further modified by methods on
293
- <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</p>
294
- </div>
295
-
296
- </li>
297
-
298
- </ul>
299
- <h3>Raises:</h3>
300
- <ul class="raise">
301
-
302
- <li>
303
-
304
-
305
- <span class='type'>(<tt><span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span></tt>)</span>
306
-
307
-
308
-
309
- &mdash;
310
- <div class='inline'>
311
- <p>if attempting to stub method which is not allowed.</p>
312
- </div>
313
-
314
- </li>
315
-
316
- </ul>
317
-
318
- <h3>See Also:</h3>
319
- <ul class="see">
320
-
321
- <li><span class='object_link'><a href="Mock.html#expects-instance_method" title="Mocha::Mock#expects (method)">Mock#expects</a></span></li>
322
-
323
- </ul>
324
-
325
- </div><table class="source_code">
326
- <tr>
327
- <td>
328
- <pre class="lines">
329
-
330
-
331
- 66
332
- 67
333
- 68
334
- 69
335
- 70
336
- 71
337
- 72
338
- 73
339
- 74
340
- 75
341
- 76
342
- 77
343
- 78
344
- 79
345
- 80
346
- 81
347
- 82
348
- 83
349
- 84
350
- 85</pre>
351
- </td>
352
- <td>
353
- <pre class="code"><span class="info file"># File 'lib/mocha/object.rb', line 66</span>
354
-
355
- <span class='kw'>def</span> <span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='id identifier rubyid_expected_methods_vs_return_values'>expected_methods_vs_return_values</span><span class='rparen'>)</span>
356
- <span class='kw'>if</span> <span class='id identifier rubyid_expected_methods_vs_return_values'>expected_methods_vs_return_values</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>the[^a-z]*spanish[^a-z]*inquisition</span><span class='regexp_end'>/i</span></span>
357
- <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Mocha</span><span class='op'>::</span><span class='const'>ExpectationError</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'>NOBODY EXPECTS THE SPANISH INQUISITION!</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
358
- <span class='kw'>end</span>
359
- <span class='kw'>if</span> <span class='id identifier rubyid_frozen?'>frozen?</span>
360
- <span class='id identifier rubyid_raise'>raise</span> <span class='const'>StubbingError</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't stub method on frozen object: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_mocha_inspect'>mocha_inspect</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span><span class='rparen'>)</span>
361
- <span class='kw'>end</span>
362
- <span class='id identifier rubyid_expectation'>expectation</span> <span class='op'>=</span> <span class='kw'>nil</span>
363
- <span class='id identifier rubyid_mockery'>mockery</span> <span class='op'>=</span> <span class='const'>Mocha</span><span class='op'>::</span><span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
364
- <span class='id identifier rubyid_iterator'>iterator</span> <span class='op'>=</span> <span class='const'>ArgumentIterator</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_expected_methods_vs_return_values'>expected_methods_vs_return_values</span><span class='rparen'>)</span>
365
- <span class='id identifier rubyid_iterator'>iterator</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='op'>|</span>
366
- <span class='id identifier rubyid_method_name'>method_name</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
367
- <span class='id identifier rubyid_mockery'>mockery</span><span class='period'>.</span><span class='id identifier rubyid_on_stubbing'>on_stubbing</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_method_name'>method_name</span><span class='rparen'>)</span>
368
- <span class='id identifier rubyid_method'>method</span> <span class='op'>=</span> <span class='id identifier rubyid_stubba_method'>stubba_method</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_stubba_object'>stubba_object</span><span class='comma'>,</span> <span class='id identifier rubyid_method_name'>method_name</span><span class='rparen'>)</span>
369
- <span class='id identifier rubyid_mockery'>mockery</span><span class='period'>.</span><span class='id identifier rubyid_stubba'>stubba</span><span class='period'>.</span><span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
370
- <span class='id identifier rubyid_expectation'>expectation</span> <span class='op'>=</span> <span class='id identifier rubyid_mocha'>mocha</span><span class='period'>.</span><span class='id identifier rubyid_expects'>expects</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name'>method_name</span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span><span class='rparen'>)</span>
371
- <span class='id identifier rubyid_expectation'>expectation</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>&gt;</span> <span class='int'>0</span>
372
- <span class='rbrace'>}</span>
373
- <span class='id identifier rubyid_expectation'>expectation</span>
374
- <span class='kw'>end</span></pre>
375
- </td>
376
- </tr>
377
- </table>
378
- </div>
379
-
380
- <div class="method_details ">
381
- <p class="signature " id="stubs-instance_method">
382
-
383
-
384
- <span class="overload">- (<tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt>) <strong>stubs</strong>(method_name) </span>
385
-
386
- <span class="overload">- (<tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt>) <strong>stubs</strong>(stubbed_methods_vs_return_values) </span>
387
-
388
-
389
-
390
-
391
- </p><div class="docstring">
392
- <div class="discussion">
393
-
394
- <p>Adds an expectation that the specified method may be called any number of
395
- times with any parameters.</p>
396
-
397
-
398
- </div>
399
- </div>
400
- <div class="tags">
401
-
402
- <div class="examples">
403
- <h3>Examples:</h3>
404
-
405
- <h4><div class='inline'>
406
- <p>Setting up a stubbed methods on a non-mock object.</p>
407
- </div></h4>
408
- <pre class="example code"><span class='id identifier rubyid_product'>product</span> <span class='op'>=</span> <span class='const'>Product</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
409
- <span class='id identifier rubyid_product'>product</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'>true</span><span class='rparen'>)</span>
410
- <span class='id identifier rubyid_assert_equal'>assert_equal</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_product'>product</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span></pre>
411
-
412
- <h4><div class='inline'>
413
- <p>Setting up multiple stubbed methods on a non-mock object.</p>
414
- </div></h4>
415
- <pre class="example code"><span class='id identifier rubyid_product'>product</span> <span class='op'>=</span> <span class='const'>Product</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
416
- <span class='id identifier rubyid_product'>product</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:valid?</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='symbol'>:save</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='rparen'>)</span>
417
-
418
- <span class='comment'># exactly equivalent to
419
- </span>
420
- <span class='id identifier rubyid_product'>product</span> <span class='op'>=</span> <span class='const'>Product</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
421
- <span class='id identifier rubyid_product'>product</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:valid?</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='kw'>true</span><span class='rparen'>)</span>
422
- <span class='id identifier rubyid_product'>product</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'>true</span><span class='rparen'>)</span></pre>
423
-
424
- </div>
425
- <h3>Parameters:</h3>
426
- <ul class="param">
427
-
428
- <li>
429
-
430
- <span class='name'>method_name</span>
431
-
432
-
433
- <span class='type'>(<tt>Symbol</tt>, <tt>String</tt>)</span>
434
-
435
-
436
-
437
- &mdash;
438
- <div class='inline'>
439
- <p>name of stubbed method</p>
440
- </div>
441
-
442
- </li>
443
-
444
- <li>
445
-
446
- <span class='name'>stubbed_methods_vs_return_values</span>
447
-
448
-
449
- <span class='type'>(<tt>Hash</tt>)</span>
450
-
451
-
452
-
453
- &mdash;
454
- <div class='inline'>
455
- <p>stubbed method name symbols as keys and corresponding return values as
456
- values - these stubbed methods are setup as if <span class='object_link'><a href="#stubs-instance_method" title="Mocha::ObjectMethods#stubs (method)">#stubs</a></span> were called
457
- multiple times.</p>
458
- </div>
459
-
460
- </li>
461
-
462
- </ul>
463
-
464
- <h3>Returns:</h3>
465
- <ul class="return">
466
-
467
- <li>
468
-
469
-
470
- <span class='type'>(<tt><span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span></tt>)</span>
471
-
472
-
473
-
474
- &mdash;
475
- <div class='inline'>
476
- <p>last-built expectation which can be further modified by methods on
477
- <span class='object_link'><a href="Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>.</p>
478
- </div>
479
-
480
- </li>
481
-
482
- </ul>
483
- <h3>Raises:</h3>
484
- <ul class="raise">
485
-
486
- <li>
487
-
488
-
489
- <span class='type'>(<tt><span class='object_link'><a href="StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span></tt>)</span>
490
-
491
-
492
-
493
- &mdash;
494
- <div class='inline'>
495
- <p>if attempting to stub method which is not allowed.</p>
496
- </div>
497
-
498
- </li>
499
-
500
- </ul>
501
-
502
- <h3>See Also:</h3>
503
- <ul class="see">
504
-
505
- <li><span class='object_link'><a href="Mock.html#stubs-instance_method" title="Mocha::Mock#stubs (method)">Mock#stubs</a></span></li>
506
-
507
- </ul>
508
-
509
- </div><table class="source_code">
510
- <tr>
511
- <td>
512
- <pre class="lines">
513
-
514
-
515
- 113
516
- 114
517
- 115
518
- 116
519
- 117
520
- 118
521
- 119
522
- 120
523
- 121
524
- 122
525
- 123
526
- 124
527
- 125
528
- 126
529
- 127
530
- 128
531
- 129</pre>
532
- </td>
533
- <td>
534
- <pre class="code"><span class="info file"># File 'lib/mocha/object.rb', line 113</span>
535
-
536
- <span class='kw'>def</span> <span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_stubbed_methods_vs_return_values'>stubbed_methods_vs_return_values</span><span class='rparen'>)</span>
537
- <span class='kw'>if</span> <span class='id identifier rubyid_frozen?'>frozen?</span>
538
- <span class='id identifier rubyid_raise'>raise</span> <span class='const'>StubbingError</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't stub method on frozen object: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_mocha_inspect'>mocha_inspect</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span><span class='rparen'>)</span>
539
- <span class='kw'>end</span>
540
- <span class='id identifier rubyid_expectation'>expectation</span> <span class='op'>=</span> <span class='kw'>nil</span>
541
- <span class='id identifier rubyid_mockery'>mockery</span> <span class='op'>=</span> <span class='const'>Mocha</span><span class='op'>::</span><span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
542
- <span class='id identifier rubyid_iterator'>iterator</span> <span class='op'>=</span> <span class='const'>ArgumentIterator</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_stubbed_methods_vs_return_values'>stubbed_methods_vs_return_values</span><span class='rparen'>)</span>
543
- <span class='id identifier rubyid_iterator'>iterator</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='op'>|</span>
544
- <span class='id identifier rubyid_method_name'>method_name</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span>
545
- <span class='id identifier rubyid_mockery'>mockery</span><span class='period'>.</span><span class='id identifier rubyid_on_stubbing'>on_stubbing</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_method_name'>method_name</span><span class='rparen'>)</span>
546
- <span class='id identifier rubyid_method'>method</span> <span class='op'>=</span> <span class='id identifier rubyid_stubba_method'>stubba_method</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_stubba_object'>stubba_object</span><span class='comma'>,</span> <span class='id identifier rubyid_method_name'>method_name</span><span class='rparen'>)</span>
547
- <span class='id identifier rubyid_mockery'>mockery</span><span class='period'>.</span><span class='id identifier rubyid_stubba'>stubba</span><span class='period'>.</span><span class='id identifier rubyid_stub'>stub</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
548
- <span class='id identifier rubyid_expectation'>expectation</span> <span class='op'>=</span> <span class='id identifier rubyid_mocha'>mocha</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='id identifier rubyid_method_name'>method_name</span><span class='comma'>,</span> <span class='id identifier rubyid_caller'>caller</span><span class='rparen'>)</span>
549
- <span class='id identifier rubyid_expectation'>expectation</span><span class='period'>.</span><span class='id identifier rubyid_returns'>returns</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>&gt;</span> <span class='int'>0</span>
550
- <span class='rbrace'>}</span>
551
- <span class='id identifier rubyid_expectation'>expectation</span>
552
- <span class='kw'>end</span></pre>
553
- </td>
554
- </tr>
555
- </table>
556
- </div>
557
-
558
- <div class="method_details ">
559
- <p class="signature " id="unstub-instance_method">
560
-
561
- - (<tt><span class='object_link'><a href="../Object.html" title="Object (class)">Object</a></span></tt>) <strong>unstub</strong>(*method_names)
562
-
563
-
564
-
565
- </p><div class="docstring">
566
- <div class="discussion">
567
-
568
- <p>Removes the specified stubbed methods (added by calls to <span class='object_link'><a href="#expects-instance_method" title="Mocha::ObjectMethods#expects (method)">#expects</a></span> or
569
- <span class='object_link'><a href="#stubs-instance_method" title="Mocha::ObjectMethods#stubs (method)">#stubs</a></span>) and all expectations associated with them.</p>
570
-
571
- <p>Restores the original behaviour of the methods before they were stubbed.</p>
572
-
573
- <p>WARNING: If you <span class='object_link'><a href="#unstub-instance_method" title="Mocha::ObjectMethods#unstub (method)">#unstub</a></span> a method which still has unsatisfied
574
- expectations, you may be removing the only way those expectations can be
575
- satisfied. Use <span class='object_link'><a href="#unstub-instance_method" title="Mocha::ObjectMethods#unstub (method)">#unstub</a></span> with care.</p>
576
-
577
-
578
- </div>
579
- </div>
580
- <div class="tags">
581
-
582
- <div class="examples">
583
- <h3>Examples:</h3>
584
-
585
- <h4><div class='inline'>
586
- <p>Stubbing and unstubbing a method on a real (non-mock) object.</p>
587
- </div></h4>
588
- <pre class="example code"><span class='id identifier rubyid_multiplier'>multiplier</span> <span class='op'>=</span> <span class='const'>Multiplier</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
589
- <span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_double'>double</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span> <span class='comment'># =&gt; 4
590
- </span><span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_stubs'>stubs</span><span class='lparen'>(</span><span class='symbol'>:double</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_raises'>raises</span> <span class='comment'># new behaviour defined
591
- </span><span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_double'>double</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span> <span class='comment'># =&gt; raises exception
592
- </span><span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='symbol'>:double</span><span class='rparen'>)</span> <span class='comment'># original behaviour restored
593
- </span><span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_double'>double</span><span class='lparen'>(</span><span class='int'>2</span><span class='rparen'>)</span> <span class='comment'># =&gt; 4</span></pre>
594
-
595
- <h4><div class='inline'>
596
- <p>Unstubbing multiple methods on a real (non-mock) object.</p>
597
- </div></h4>
598
- <pre class="example code"><span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='symbol'>:double</span><span class='comma'>,</span> <span class='symbol'>:triple</span><span class='rparen'>)</span>
599
-
600
- <span class='comment'># exactly equivalent to
601
- </span>
602
- <span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='symbol'>:double</span><span class='rparen'>)</span>
603
- <span class='id identifier rubyid_multiplier'>multiplier</span><span class='period'>.</span><span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='symbol'>:triple</span><span class='rparen'>)</span></pre>
604
-
605
- </div>
606
- <h3>Parameters:</h3>
607
- <ul class="param">
608
-
609
- <li>
610
-
611
- <span class='name'>method_names</span>
612
-
613
-
614
- <span class='type'>(<tt>Array&lt;Symbol&gt;</tt>)</span>
615
-
616
-
617
-
618
- &mdash;
619
- <div class='inline'>
620
- <p>names of methods to unstub.</p>
621
- </div>
622
-
623
- </li>
624
-
625
- </ul>
626
-
627
-
628
- </div><table class="source_code">
629
- <tr>
630
- <td>
631
- <pre class="lines">
632
-
633
-
634
- 154
635
- 155
636
- 156
637
- 157
638
- 158
639
- 159
640
- 160</pre>
641
- </td>
642
- <td>
643
- <pre class="code"><span class="info file"># File 'lib/mocha/object.rb', line 154</span>
644
-
645
- <span class='kw'>def</span> <span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_method_names'>method_names</span><span class='rparen'>)</span>
646
- <span class='id identifier rubyid_mockery'>mockery</span> <span class='op'>=</span> <span class='const'>Mocha</span><span class='op'>::</span><span class='const'>Mockery</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
647
- <span class='id identifier rubyid_method_names'>method_names</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_method_name'>method_name</span><span class='op'>|</span>
648
- <span class='id identifier rubyid_method'>method</span> <span class='op'>=</span> <span class='id identifier rubyid_stubba_method'>stubba_method</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_stubba_object'>stubba_object</span><span class='comma'>,</span> <span class='id identifier rubyid_method_name'>method_name</span><span class='rparen'>)</span>
649
- <span class='id identifier rubyid_mockery'>mockery</span><span class='period'>.</span><span class='id identifier rubyid_stubba'>stubba</span><span class='period'>.</span><span class='id identifier rubyid_unstub'>unstub</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
650
- <span class='kw'>end</span>
651
- <span class='kw'>end</span></pre>
652
- </td>
653
- </tr>
654
- </table>
655
- </div>
656
-
657
- </div>
658
-
659
- </div>
660
-
661
- <div id="footer">
662
- Generated on Wed Apr 25 16:51:30 2012 by
663
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
664
- 0.7.5 (ruby-1.9.3).
665
- </div>
666
-
667
- </body>
668
- </html>