[mocha-developer] mock framework ethics question

David Chelimsky dchelimsky at gmail.com
Wed Aug 22 10:46:44 EDT 2007

Hi James, Jim, and everyone else who's listening.

I've been investigating an interesting bug related to mocks and rails
AssociationProxies. See
for details.

The crux is that if you do this (rspec mock syntax):


and the implementation does this:


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


  actual == expected || expected == actual

or ... neither?

I have arguments for all three - I'd like to hear your thoughts.


More information about the mocha-developer mailing list