Max Williams
2009-Jul-21 15:50 UTC
Machinist - having problems stubbing an after_create filter
Hi all I''m moving to using Machinist in my rspec tests and am having a problem with an after_create callback method that i need to stub out. It seems like calling ClassName.make will trigger this callback before i''ve had the chance to stub it. Can i stub it in my blueprint for that class? Or, can i stub the method for all instances of the class before i call ClassName.make? -- Posted via http://www.ruby-forum.com/.
Gustav Paul
2009-Jul-21 21:06 UTC
Re: Machinist - having problems stubbing an after_create filter
Hey Max, Try: instance = YourModel.make_unsaved then stub the after_create method and save the object. Regards, Gustav Paul On Tue, Jul 21, 2009 at 5:50 PM, Max Williams < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi all > > I''m moving to using Machinist in my rspec tests and am having a problem > with an after_create callback method that i need to stub out. It seems > like calling ClassName.make will trigger this callback before i''ve had > the chance to stub it. > > Can i stub it in my blueprint for that class? Or, can i stub the method > for all instances of the class before i call ClassName.make? > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Max Williams
2009-Jul-22 08:17 UTC
Re: Machinist - having problems stubbing an after_create filter
Gustav Paul wrote:> Hey Max, > > Try: > > instance = YourModel.make_unsaved > > then stub the after_create method and save the object. > > Regards, > Gustav Paul > > On Tue, Jul 21, 2009 at 5:50 PM, Max Williams <aha! If only there was an rdoc for the version of machinist i have installed i could have found that myself. Thanks a lot! max -- Posted via http://www.ruby-forum.com/.