# Machinist - having problems stubbing an after\_create filter

**URL:** <https://www.ruby-forum.com/t/machinist-having-problems-stubbing-an-after-create-filter/172444>\
**Category:** Rails\
**Created:** [July 21, 2009, 5:50pm UTC](https://www.ruby-forum.com/t/machinist-having-problems-stubbing-an-after-create-filter/172444 "2009-07-21T17:50:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [July 21, 2009, 5:50pm UTC](https://www.ruby-forum.com/t/machinist-having-problems-stubbing-an-after-create-filter/172444/1 "2009-07-21T17:50:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [July 21, 2009, 11:10pm UTC](https://www.ruby-forum.com/t/machinist-having-problems-stubbing-an-after-create-filter/172444/2 "2009-07-21T23:10:43Z")

</div>

Hey Max,

Try:

instance = YourModel.make\_unsaved

then stub the after\_create method and save the object.

Regards,  
Gustav P.

On Tue, Jul 21, 2009 at 5:50 PM, Max W. \<

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [July 22, 2009, 10:17am UTC](https://www.ruby-forum.com/t/machinist-having-problems-stubbing-an-after-create-filter/172444/3 "2009-07-22T10:17:57Z")

</div>

Gustav P. wrote:

> Hey Max,
> 
> Try:
> 
> instance = YourModel.make\_unsaved
> 
> then stub the after\_create method and save the object.
> 
> Regards,  
> Gustav P.
> 
> On Tue, Jul 21, 2009 at 5:50 PM, Max W. \<

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
