rspec and config/initializers/* not loading

2,589 views
Skip to first unread message

Phillip Koebbe

unread,
Aug 24, 2010, 9:22:22 PM8/24/10
to ruby-b...@googlegroups.com
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

or

$ bundle exec 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 on the Bundler and Rails
2.3 page [1].
I have searched via Google quite a lot 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 have upgraded to Bundler 1.0.0.rc.6 and still have the problem.

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 with

$ rake spec RAILS_ENV=test

and encountered 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?

Thanks,
Phillip

[1] http://gembundler.com/rails23.html
[2]
http://talklikeaduck.denhaven2.com/2010/06/25/making-rspec-rake-and-bundler-play-well-together

Donovan Bray

unread,
Aug 24, 2010, 9:28:19 PM8/24/10
to ruby-b...@googlegroups.com
Make sure you are including rspec-rails in :development as well as :test if you are using groups in the gemfile

> --
> You received this message because you are subscribed to the Google Groups "ruby-bundler" group.
> To post to this group, send email to ruby-b...@googlegroups.com.
> To unsubscribe from this group, send email to ruby-bundler...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ruby-bundler?hl=en.
>

Phillip Koebbe

unread,
Aug 24, 2010, 9:36:02 PM8/24/10
to ruby-b...@googlegroups.com
On 2010-08-24 8:28 PM, Donovan Bray wrote:
> Make sure you are including rspec-rails in :development as well as :test if you are using groups in the gemfile

Thanks for the suggestion, Donovan. My Gemfile looks like this:

source 'http://gemcutter.org'

# bundler requires these gems in all environments
gem 'rails', '2.3.8'
gem 'pg', '0.9.0'
gem 'crack', '0.1.7'
gem 'httparty', '0.6.0'
gem 'libxml-ruby', '1.1.4'
gem 'happymapper', '0.3.1'
gem 'haml', '3.0.12'
gem 'pdf-reader', '0.8.5', :require => 'pdf/reader'
gem 'Ascii85', '1.0.0', :require => 'ascii85'

group :production do
gem 'exceptional', '2.0.25'
end

group :development, :test do
gem 'rspec', '1.3.0'
gem 'rspec-rails', '1.3.2'
gem 'remarkable_rails', '3.1.13'
gem 'database_cleaner', '0.5.2'
gem 'wirble', '0.1.3'
gem 'ruby-debug', '0.10.3'
gem 'mongrel', '1.1.5'
end

and I still have the problem.

Peace,
Phillip

subimage

unread,
May 29, 2012, 4:53:11 AM5/29/12
to ruby-b...@googlegroups.com
Phillip did you ever solve this issue? Trying to move to bundler on a 2.3.14 app and running into the exact same issue.

subimage

unread,
May 29, 2012, 4:57:28 AM5/29/12
to ruby-b...@googlegroups.com
I'm running into the same thing on a Rails 2.3.14 app. Any solution?


On Tuesday, August 24, 2010 6:36:02 PM UTC-7, Phillip Koebbe wrote:

Phillip Koebbe

unread,
May 29, 2012, 7:57:48 AM5/29/12
to ruby-b...@googlegroups.com

On May 29, 2012, at 3:53 AM, subimage wrote:

> Phillip did you ever solve this issue? Trying to move to bundler on a 2.3.14 app and running into the exact same issue.

No, I don't think I did. I was working on two Rails 2.3.x projects at that time, and from the Git history it seems that one project didn't get Bundler at all while the other got it a year later. It is my guess, then, that the problem I was experiencing in this thread was in the project that still does not have bundler, and I cannot now even remember what the problem was.

Phillip

HannesBenson

unread,
Aug 1, 2012, 2:05:07 AM8/1/12
to ruby-b...@googlegroups.com
Has anybody made any progress with this? I am in exactly the same position.
Reply all
Reply to author
Forward
0 new messages