[mocha-developer] Expect with "real world" returns?
Zach Moazeni
zach.lists at gmail.com
Wed May 21 16:32:38 EDT 2008
On May 21, 2008, at 10:56 AM, Carl Mercier wrote:
> I wish Mocha supported this "out of the box" with this syntax:
>
> User.expects(:find).with(1) # returns the "real" row from the
> database
> User.expects(:find).with(1).returns(mocked_row) # returns a fake row
In my opinion, I don't find that useful. If I want the real row from
the database to brought in, I wouldn't use mocking. I only use
expects / stubs when I want to alter and/or assert behavior.
> and to have something explicitly return nil (without running the
> real code):
> Foo.expects(:bar).returns(nil)
I'm too lazy to check right now, but I thought that was the current
behavior.
Foo.expects(:bar)
Foo.bar => nil
More information about the mocha-developer
mailing list