I do that sort of thing pretty often.

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
http://martinfowler.com/articles/mocksArentStubs.html (which are apparently
from http://xunitpatterns.com/ but I haven't read it), your hash is a 'fake'
MigrationGraph.

-hume.


On Sun, May 18, 2008 at 5:13 AM, Ashley Moran <[EMAIL PROTECTED]>
wrote:

> Hi
>
> I've been doing this a while now.  If I have a class that responds to :[],
> and all I'm interested in stubbing is that method, then instead of using a
> mock I just create a hash.  (Similarly, you could create an array when you
> are testing an Enumerable object.)
>
> Example from code I just worked on, where uses MigrationGraph#[] looks up
> graph vertices by name:
>
>  @migration_graph = {
>    # "name" => vertex
>    "changeset 1 migration 1" => @migration_a,
>    "changeset 1 migration 2" => @migration_b,
>    "changeset 2 migration 1" => @migration_c,
>    "changeset 2 migration 2" => @migration_d
>  }
>
> What I'm really interested in is what happens to (some of) the four
> migrations, not the migration graph itself.
>
> I just wondered if anyone else did this.  Generally doing unusual things is
> a sign something is amiss.
>
> Ashley
>
>
> --
> http://www.patchspace.co.uk/
> http://aviewfromafar.net/
>
>
>
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to