doc/Caricature/Expectations.html in caricature-0.5.0 vs doc/Caricature/Expectations.html in caricature-0.6.0

- old
+ new

@@ -59,13 +59,13 @@ <h3 class="section-header">Methods</h3> <ul class="link-list"> <li><a href="#M000016">::new</a></li> - <li><a href="#M000017">#<<</a></li> + <li><a href="#M000018">#add_expectation</a></li> - <li><a href="#M000019">#find</a></li> + <li><a href="#M000020">#find</a></li> </ul> </div> @@ -223,11 +223,12 @@ <div class="method-source-code" id="new-source"> <pre> <span class="ruby-comment cmt"># File lib/caricature/expectation.rb, line 8</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span> - <span class="ruby-ivar">@inner</span> = [] + <span class="ruby-ivar">@instance_expectations</span> = [] + <span class="ruby-ivar">@class_expectations</span> = [] <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -239,17 +240,17 @@ <div id="public-instance-method-details" class="method-section section"> <h3 class="section-header">Public Instance Methods</h3> - <div id="--method" class="method-detail "> - <a name="M000017"></a> + <div id="add-expectation-method" class="method-detail "> + <a name="M000018"></a> <div class="method-heading"> - <span class="method-name">&lt;&lt;</span><span - class="method-args">(expectation)</span> + <span class="method-name">add_expectation</span><span + class="method-args">(expectation, mode=:instance)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> @@ -260,31 +261,32 @@ </p> <div class="method-source-code" - id="--source"> + id="add-expectation-source"> <pre> -<span class="ruby-comment cmt"># File lib/caricature/expectation.rb, line 13</span> - <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;&lt;</span>(<span class="ruby-identifier">expectation</span>) - <span class="ruby-ivar">@inner</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">expectation</span> +<span class="ruby-comment cmt"># File lib/caricature/expectation.rb, line 14</span> + <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_expectation</span>(<span class="ruby-identifier">expectation</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-identifier">:instance</span>) + <span class="ruby-ivar">@instance_expectations</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">expectation</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:class</span> + <span class="ruby-ivar">@class_expectations</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">expectation</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:class</span> <span class="ruby-keyword kw">end</span></pre> </div> </div> </div> <div id="find-method" class="method-detail "> - <a name="M000019"></a> + <a name="M000020"></a> <div class="method-heading"> <span class="method-name">find</span><span - class="method-args">(method_name, *args)</span> + class="method-args">(method_name, mode=:instance, *args)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> @@ -302,12 +304,13 @@ <div class="method-source-code" id="find-source"> <pre> -<span class="ruby-comment cmt"># File lib/caricature/expectation.rb, line 22</span> - <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find</span>(<span class="ruby-identifier">method_name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) - <span class="ruby-identifier">candidates</span> = <span class="ruby-ivar">@inner</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">exp</span><span class="ruby-operator">|</span> <span class="ruby-identifier">exp</span>.<span class="ruby-identifier">method_name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">method_name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_sym</span> } +<span class="ruby-comment cmt"># File lib/caricature/expectation.rb, line 24</span> + <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find</span>(<span class="ruby-identifier">method_name</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-identifier">:instance</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>) + <span class="ruby-identifier">expectations</span> = <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:class</span> <span class="ruby-operator">?</span> <span class="ruby-ivar">@class_expectations</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@instance_expectations</span> + <span class="ruby-identifier">candidates</span> = <span class="ruby-identifier">expectations</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">exp</span><span class="ruby-operator">|</span> <span class="ruby-identifier">exp</span>.<span class="ruby-identifier">method_name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">method_name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_sym</span> } <span class="ruby-identifier">is_single</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:any</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">candidates</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">candidates</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">any_args?</span>) <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">candidates</span>.<span class="ruby-identifier">first</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">is_single</span> <span class="ruby-identifier">second_pass</span> = <span class="ruby-identifier">candidates</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">exp</span><span class="ruby-operator">|</span> <span class="ruby-identifier">exp</span>.<span class="ruby-identifier">args</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">args</span> } <span class="ruby-identifier">second_pass</span>.<span class="ruby-identifier">first</span>