[rspec-users] Class method not being stubbed

Rick DeNatale rick.denatale at gmail.com
Sun May 24 15:25:56 EDT 2009

On Sun, May 24, 2009 at 2:24 PM, Nick Hoffman <nick at deadorange.com> wrote:
> On Sun, May 24, 2009 at 2:13 PM, Fernando Perez <lists at ruby-forum.com> wrote:
>>> Hi Fernando. In this case, I don't think it's a matter of using the
>>> debugger.
>> I suspect a problem in: require 'lib/adsense_heaven_parser', the code
>> maybe never gets out of this require statement. The debugger would allow
>> you to immediately clear things out.
> Hi Fernando. I'm not sure what you mean by "the code never gets out of
> this require statement".
> However, that doesn't really matter. The call to #require shouldn't
> happen, because the method is supposed to be stubbed out.

No that's what confused me.

class KeywordListsController < ApplicationController
  def create_keywords_and_associate(keyword_list_contents, keyword_list)
    puts '*** create_keywords_and_associate ***'
    require 'lib/adsense_heaven_parser'
    parsed_list = AdSenseHeavenParser.parse keyword_list_contents

The controller method has the require and then calls parse.

One thing which strikes me is that if Rails naming conventions were
being followed:

 1) the file name be lib/ad_sense_heaven_parser not lib/adsense_heaven_parser
 2) the require wouldn't be needed since it would be autoloaded.

Perhaps the problem lies there somewhere.

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