From: Richard Conroy Date: 2010-12-02T05:35:22+09:00 Subject: Re: mocking in rspec --00032557335a5b9ceb04965f3e60 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Dec 1, 2010 at 7:05 PM, Ruby Pasaulyje wrote: > > Is the Mocha cheat sheet much help? > > http://cheat.errtheblog.com/s/mocha/ > > No. There are simple use of mocha in sheet, but in my case i need to use > mocha for method of object which wasn't received by parameters. > > You are in a bit of a no mans land when it comes to mocking then. I would consider breaking up that initializer so that the decision can be tested seperately. Alternatively you might be able to use 'any_instance': DataMatrix.any_instance.stubs(:form_matrix) DataMatrix.any_instance.expects(:get_data_from_yaml).with(String, 'whatever') DataMatrix.new String, 'whatever' You will need a lot of tests, to cover that decision process. I would be tempted to break up that initializer or refactor it somehow. -- http://richardconroy.blogspot.com | http://twitter.com/RichardConroy --00032557335a5b9ceb04965f3e60--