[rspec-users] Class method not being stubbed

Rick DeNatale rick.denatale at gmail.com
Sun May 24 13:10:49 EDT 2009

On Sun, May 24, 2009 at 12:25 PM, Nick Hoffman <nick at deadorange.com> wrote:
> Hi guys. I'm setting an expectation on a class method. For some
> reason, the method isn't being stubbed, and the expectation isn't
> seeing the call.
> In KeywordListsController#create, I call the private method
> #create_keywords_and_associate, which calls AdSenseHeavenParser#parse
> .
> Thus, some of my specs set an expectation on AdSenseHeavenParser#parse
> . However, that expectation isn't stubbing out #parse .

That's because it isn't a class method, it's an instance method, so instead of:

=> [], :errors => []})

You should have
=> [], :errors => []})

Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

More information about the rspec-users mailing list