[mocha-developer] mock framework ethics question

James Mead jamesmead44 at gmail.com
Fri Sep 21 12:20:19 EDT 2007


Hi David,

This is probably too late for you, but I'm inclined towards the third
"neither" option. This is because I prefer to stub the association method
itself which means I can use a standard mock for the model rather than an
rspec mock_model or whatever you call it.

Cheers, James.

On 22/08/2007, David Chelimsky <dchelimsky at gmail.com> wrote:
>
> Hi James, Jim, and everyone else who's listening.
>
> I've been investigating an interesting bug related to mocks and rails
> AssociationProxies. See
> http://rubyforge.org/tracker/?func=detail&atid=3149&aid=12547&group_id=797
> for details.
>
> The crux is that if you do this (rspec mock syntax):
>
>   obj.should_receive(:msg).with(mock_of_a_model)
>
> and the implementation does this:
>
>   obj.msg(containing_model.association_proxy)
>
> the expectation fails. This is because the comparison that rspec mocks
> make is:
>
>   expected == actual
>
> which, in this case ends up being:
>
>   mock_of_a_model == association_proxy
>
> As it turns out, mocha and flexmock do this the same way, which means
> that this will fail in any of the three frameworks.
>
> So here's the mock-ethics question of the week:
>
> Should the comparison be changed to:
>
>   actual == expected
>
> or
>
>   actual == expected || expected == actual
>
> or ... neither?
>
> I have arguments for all three - I'd like to hear your thoughts.
>
> Cheers,
> David
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer
>



-- 
James.
http://blog.floehopper.org
http://tumble.floehopper.org


More information about the mocha-developer mailing list