I do that sort of thing pretty often.<br><br>I would just point out that you should avoid calling that mocking, since there are no expectations in place and therefore no verification of the specific way the code being specified interacts with the MigrationGraph. According to the definitions in <a href="http://martinfowler.com/articles/mocksArentStubs.html">http://martinfowler.com/articles/mocksArentStubs.html</a> (which are apparently from <a href="http://xunitpatterns.com/">http://xunitpatterns.com/</a> but I haven&#39;t read it), your hash is a &#39;fake&#39; MigrationGraph.<br>
<br>-hume.<br><br><br><div class="gmail_quote">On Sun, May 18, 2008 at 5:13 AM, Ashley Moran &lt;<a href="mailto:ashley.moran@patchspace.co.uk">ashley.moran@patchspace.co.uk</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi<br>
<br>
I&#39;ve been doing this a while now. &nbsp;If I have a class that responds to :[], and all I&#39;m interested in stubbing is that method, then instead of using a mock I just create a hash. &nbsp;(Similarly, you could create an array when you are testing an Enumerable object.)<br>

<br>
Example from code I just worked on, where uses MigrationGraph#[] looks up graph vertices by name:<br>
<br>
 &nbsp;@migration_graph = {<br>
 &nbsp; &nbsp;# &quot;name&quot; =&gt; vertex<br>
 &nbsp; &nbsp;&quot;changeset 1 migration 1&quot; =&gt; @migration_a,<br>
 &nbsp; &nbsp;&quot;changeset 1 migration 2&quot; =&gt; @migration_b,<br>
 &nbsp; &nbsp;&quot;changeset 2 migration 1&quot; =&gt; @migration_c,<br>
 &nbsp; &nbsp;&quot;changeset 2 migration 2&quot; =&gt; @migration_d<br>
 &nbsp;}<br>
<br>
What I&#39;m really interested in is what happens to (some of) the four migrations, not the migration graph itself.<br>
<br>
I just wondered if anyone else did this. &nbsp;Generally doing unusual things is a sign something is amiss.<br>
<br>
Ashley<br>
<br>
<br>
-- <br>
<a href="http://www.patchspace.co.uk/" target="_blank">http://www.patchspace.co.uk/</a><br>
<a href="http://aviewfromafar.net/" target="_blank">http://aviewfromafar.net/</a><br>
<br>
<br>
<br>
_______________________________________________<br>
rspec-users mailing list<br>
<a href="mailto:rspec-users@rubyforge.org" target="_blank">rspec-users@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a><br>
</blockquote></div><br>