<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> Module: Mocha — Mocha 1.11.1 </title> <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" /> <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" /> <script type="text/javascript" charset="utf-8"> pathId = "Mocha"; relpath = ''; </script> <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script> <script type="text/javascript" charset="utf-8" src="js/app.js"></script> </head> <body> <div class="nav_wrap"> <iframe id="nav" src="class_list.html?1"></iframe> <div id="resizer"></div> </div> <div id="main" tabindex="-1"> <div id="header"> <div id="menu"> <a href="_index.html">Index (M)</a> » <span class="title">Mocha</span> </div> <div id="search"> <a class="full_list_link" id="class_list_link" href="class_list.html"> <svg width="24" height="24"> <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect> <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect> <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect> </svg> </a> </div> <div class="clear"></div> </div> <div id="content"><h1>Module: Mocha </h1> <div class="box_info"> <dl> <dt>Defined in:</dt> <dd>lib/mocha/api.rb<span class="defines">,<br /> lib/mocha/hooks.rb,<br /> lib/mocha/mock.rb,<br /> lib/mocha/expectation.rb,<br /> lib/mocha/object_methods.rb,<br /> lib/mocha/class_methods.rb,<br /> lib/mocha/parameter_matchers.rb,<br /> lib/mocha/parameter_matchers/not.rb,<br /> lib/mocha/parameter_matchers/base.rb,<br /> lib/mocha/parameter_matchers/is_a.rb,<br /> lib/mocha/parameter_matchers/all_of.rb,<br /> lib/mocha/parameter_matchers/any_of.rb,<br /> lib/mocha/parameter_matchers/equals.rb,<br /> lib/mocha/parameter_matchers/has_key.rb,<br /> lib/mocha/parameter_matchers/kind_of.rb,<br /> lib/mocha/parameter_matchers/anything.rb,<br /> lib/mocha/parameter_matchers/includes.rb,<br /> lib/mocha/parameter_matchers/has_entry.rb,<br /> lib/mocha/parameter_matchers/has_value.rb,<br /> lib/mocha/parameter_matchers/optionally.rb,<br /> lib/mocha/parameter_matchers/has_entries.rb,<br /> lib/mocha/parameter_matchers/instance_of.rb,<br /> lib/mocha/parameter_matchers/responds_with.rb,<br /> lib/mocha/parameter_matchers/any_parameters.rb,<br /> lib/mocha/parameter_matchers/equivalent_uri.rb,<br /> lib/mocha/parameter_matchers/regexp_matches.rb,<br /> lib/mocha/parameter_matchers/yaml_equivalent.rb,<br /> lib/mocha/parameter_matchers/instance_methods.rb,<br /> lib/mocha/state_machine.rb,<br /> lib/mocha/sequence.rb,<br /> lib/mocha/configuration.rb,<br /> lib/mocha/expectation_error_factory.rb,<br /> lib/mocha/expectation_error.rb,<br /> lib/mocha/stubbing_error.rb,<br /> lib/mocha/integration/test_unit/adapter.rb,<br /> lib/mocha/integration/mini_test/adapter.rb</span> </dd> </dl> </div> <h2>Defined Under Namespace</h2> <p class="children"> <strong class="modules">Modules:</strong> <span class='object_link'><a href="Mocha/API.html" title="Mocha::API (module)">API</a></span>, <span class='object_link'><a href="Mocha/ClassMethods.html" title="Mocha::ClassMethods (module)">ClassMethods</a></span>, <span class='object_link'><a href="Mocha/Hooks.html" title="Mocha::Hooks (module)">Hooks</a></span>, <span class='object_link'><a href="Mocha/Integration.html" title="Mocha::Integration (module)">Integration</a></span>, <span class='object_link'><a href="Mocha/ObjectMethods.html" title="Mocha::ObjectMethods (module)">ObjectMethods</a></span>, <span class='object_link'><a href="Mocha/ParameterMatchers.html" title="Mocha::ParameterMatchers (module)">ParameterMatchers</a></span> <strong class="classes">Classes:</strong> <span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span>, <span class='object_link'><a href="Mocha/Expectation.html" title="Mocha::Expectation (class)">Expectation</a></span>, <span class='object_link'><a href="Mocha/ExpectationError.html" title="Mocha::ExpectationError (class)">ExpectationError</a></span>, <span class='object_link'><a href="Mocha/ExpectationErrorFactory.html" title="Mocha::ExpectationErrorFactory (class)">ExpectationErrorFactory</a></span>, <span class='object_link'><a href="Mocha/Mock.html" title="Mocha::Mock (class)">Mock</a></span>, <span class='object_link'><a href="Mocha/Sequence.html" title="Mocha::Sequence (class)">Sequence</a></span>, <span class='object_link'><a href="Mocha/StateMachine.html" title="Mocha::StateMachine (class)">StateMachine</a></span>, <span class='object_link'><a href="Mocha/StubbingError.html" title="Mocha::StubbingError (class)">StubbingError</a></span> </p> <h2> Class Method Summary <small><a href="#" class="summary_toggle">collapse</a></small> </h2> <ul class="summary"> <li class="public "> <span class="summary_signature"> <a href="#configure-class_method" title="configure (class method)">.<strong>configure</strong> {|configuration| ... } ⇒ Object </a> </span> <span class="summary_desc"><div class='inline'> <p>Allows setting of configuration options.</p> </div></span> </li> </ul> <div id="class_method_details" class="method_details_list"> <h2>Class Method Details</h2> <div class="method_details first"> <h3 class="signature first" id="configure-class_method"> .<strong>configure</strong> {|configuration| ... } ⇒ <tt><span class='object_link'>Object</span></tt> </h3><div class="docstring"> <div class="discussion"> <p>Allows setting of configuration options. See <span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span> for the available options.</p> <p>Typically the configuration is set globally in a <code>test_helper.rb</code> or <code>spec_helper.rb</code> file.</p> </div> </div> <div class="tags"> <div class="examples"> <p class="tag_title">Examples:</p> <p class="example_title"><div class='inline'> <p>Setting multiple configuration options</p> </div></p> <pre class="example code"><code><span class='const'><span class='object_link'><a href="" title="Mocha (module)">Mocha</a></span></span><span class='period'>.</span><span class='id identifier rubyid_configure'>configure</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span> <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> <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> <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> <span class='kw'>end</span></code></pre> </div> <p class="tag_title">Yield Parameters:</p> <ul class="yieldparam"> <li> <span class='name'>configuration</span> <span class='type'>(<tt><span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span></tt>)</span> — <div class='inline'> <p>the configuration for modification</p> </div> </li> </ul> <p class="tag_title">See Also:</p> <ul class="see"> <li><span class='object_link'><a href="Mocha/Configuration.html" title="Mocha::Configuration (class)">Configuration</a></span></li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> 17 18 19</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/mocha/configuration.rb', line 17</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_configure'>configure</span> <span class='kw'>yield</span> <span class='id identifier rubyid_configuration'>configuration</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> </div> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-625523-7"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-625523-7'); </script> </div> <div id="footer"> Generated on Tue Dec 17 12:49:35 2019 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.20 (ruby-2.6.5). </div> </div> </body> </html>