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), 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] Gem Bundler – Manage your Ruby gems
[2]
http://talklikeaduck.denhaven2.com/2010/06/25/making-rspec-rake-and-bundler-play-well-together