Forum: RSpec bundler and config/initializers/* not loading

Posted by Phillip Koebbe (pkoebbe)
on 2010-08-24 19:56
(Received via mailing list)
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] http://gembundler.com/rails23.html
[2]
http://talklikeaduck.denhaven2.com/2010/06/25/making-rspec-rake-and-bundler-play-well-together
Posted by David Chelimsky (Guest)
on 2010-08-25 02:15
(Received via mailing list)
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
Posted by Phillip Koebbe (pkoebbe)
on 2010-08-25 03:09
(Received via mailing list)
On 2010-08-24 7:14 PM, David Chelimsky wrote:
> 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
>

Thanks for the suggestion, David. I uninstalled 0.9.26 and installed
1.0.0.rc.6 and have the same problem. I'm going to post this to the
bundler list. I don't believe it to be an RSpec problem, but started
here wondering if it was specific to testing or the test environment.
But if no one else is having any problems, it must be something else.

Peace,
Phillip
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.