[mocha-developer] Mocking objects to test Rails Controllers
Rick Moynihan
rick at calicojack.co.uk
Thu May 29 12:41:52 EDT 2008
Andrew Vit wrote:
> I think Rick was asking how to test from a controller. Assuming that
> the controller intantiates the Person object so you can't setup with
> Person.new inside your test, you can do:
>
> Person.any_instance.expects(:send_sms)
Thanks for this Andrew. You were right about what I was asking, but
Rob's answer gave me enough courage to dive in, and find it pretty much
just worked as expected.
I had my code mocked and tested (to some degree) within 5 minutes.
Yay Mocha! :-)
R.
More information about the mocha-developer
mailing list