[mocha-developer] .class call to the mock object (or any existing methods)

James Mead jamesmead44 at gmail.com
Thu Nov 23 05:30:27 EST 2006

On 22/11/06, Kurman Karabukaev <kkarabuk at thoughtworks.com> wrote:

> I run into problem trying to set expectations for the mockobject.classmethod, I had to undefine a method before I could set some expectation. Is
> there any better way of doing it?
> object = mock()
> ....
> klass = class <<object; self; end
> klass.send(:undef_method, "class")  # I had to do this because Mocha
> utilizes "method_missing(symbol, *arguments, &block) " method.
> object.expects(:class).returns(SomeClass)
> ...

This is a known problem. There isn't currently a better way. I hope to
release a new version shortly which will allow you to mock methods defined
in Object, etc.

And thanks for such a nice library.

I'm glad you like it.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mocha-developer/attachments/20061123/7986fd91/attachment.html 

More information about the mocha-developer mailing list