[rspec-users] bundler and config/initializers/* not loading

David Chelimsky dchelimsky at gmail.com
Tue Aug 24 20:14:49 EDT 2010


On Aug 24, 2010, at 12:34 PM, Phillip Koebbe wrote:

> I am trying to use Bundler on a Rails 2.3.8 project and am having a problem when trying to run my specs. This application was on 2.3.5 until yesterday, and I switched it to 2.3.8 and all specs passed. But after adding Bundler (0.9.26),

Bundler-1.0 is in the release candidate phase now, and is far superior to 0.9. I would not waste my time with 0.9 if I were you. Might even avoid this problem.

HTH,
David

> rake spec fails because (it appears) files in config/initializers aren't being loaded. Yet the application works when running script/server.
> 
> When I issue
> 
> $ rake spec
> 
> I get
> 
> uninitialized constant Web::BaseHelper::AuthenticationMethods (NameError)
> 
> because of
> 
> module Web::BaseHelper
>    include AuthenticationMethods
>    ...
> end
> 
> where AuthenticationMethods is defined in config/initializers/authentication_methods.rb. If I change web/base_helper.rb to
> 
> require "#{Rails.root}/config/initializers/authentication_methods" unless defined? AuthenticationMethods
> 
> module Web::BaseHelper
>    include AuthenticationMethods
>    ...
> end
> 
> the error is no longer reported.
> 
> I added Bundler by following the instructions at the Bundler page[1].
> I have also tried $ bundle exec rake spec, with the same result.
> I have been searching Google all morning without finding a resolution.
> I am using rspec 1.3.0 / rspec-rails 1.3.2, even before adding Bundler.
> This is on Mac OS X 10.6.4 and ruby 1.8.7-p174 (Snow Leopard stock).
> 
> I read Rick DeNatale's post[2] regarding Bundler, rspec, and rake, and while I haven't made the changes he describes, I did try forcing the environment by
> 
> $ rake spec RAILS_ENV=test
> 
> with the same result. I didn't incorporate Rick's changes yet because I wanted to check here first to see if there is any other information available.
> 
> Can anyone offer insight, words of wisdom, encouragement, or a solution? If this isn't a problem specific to rspec, I apologize. I was trying to think of some way to test something else, but the few things that came to mind succeeded (well, didn't generate any errors anyway).
> 
> Thanks,
> Phillip
> 
> [1] http://gembundler.com/rails23.html
> [2] http://talklikeaduck.denhaven2.com/2010/06/25/making-rspec-rake-and-bundler-play-well-together
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list