How do you stub out callbacks?

Hi there,

I’m trying to write a spec for and existing model. It has an
after_create callback which I’d like to stub out. Any quick solution to
this?

Many thanks

Rob L.

On Thu, Aug 14, 2008 at 9:53 AM, Rob L.
[email protected] wrote:

Hi there,

I’m trying to write a spec for and existing model. It has an after_create
callback which I’d like to stub out. Any quick solution to this?

My first question is why do you want to stub it out? My second
question is what spec are you wanting to stub it out in?


Zach D.
http://www.continuousthinking.com

Don’t stub out callbacks, rather spec the behavior of the model,
which might mean stubbing out methods (in a different model?) called
by the callback.

Rob L. wrote:

rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

What you may want to do is move the after_create into an observer and
then disconnect your observers during most of your specs. You can do
this with Pat M.'s plugin:

http://github.com/pat-maddox/no-peeping-toms/tree/master

-Ben