[mocha-developer] mocking missing methods

Jay Fields jay at jayfields.com
Fri Apr 27 17:20:27 EDT 2007


> In the case of just Sheep, it
> could ask for it's public_class_methods. In the case of
> instance_of(Sheep) it would have to ask for something else - or you'd
> have to override public_class_methods on the object returned by
> instance_of(Sheep) to return the sheep's public_instance_methods -
> which just doesn't seem right to me.

How about:

# instance methods
sheep = mock
sheep.restricted_to Sheep.instance_methods

or

# class methods
sheep = mock
sheep.restricted_to Sheep.singleton_methods

It's a bit more verbose, but more readable in my opinion.  Also, I'm  
not sold on responds_to or restricted_to.  I don't find that either  
one conveys the intent I'm looking for.

Thoughts?

Jay


More information about the mocha-developer mailing list