[rspec-users] rspec 1.3.2, Rails 2.3.14 - plugins not loading

Jens-Christian Fischer jcfischer at gmail.com
Mon Oct 24 04:12:22 EDT 2011


Thanks for all the hints. I'm pretty sure however, that Bundler ist
NOT the issue. Both boot.rb and config/preinitializer.rb are as
expected and the app itself starts fine both with script/server or
script/console.

However, as soon as rspec is loaded (when running the tests), then the
plugins aren't loaded anymore. A wild guess is that Rspec causes the
loading of plugins to fail in mysterious ways, but I don't enough of
either the Rails 2.3 booting process nor the Rspec magic to pinpoint
the location where I should put my finger on.

Any further ideas that I could look into?

thanks
jc

On 21 Okt., 22:18, Lenny Marks <le... at aps.org> wrote:
> On Oct 21, 2011, at 11:05 AM, Andrew Premdas wrote:
>
>
>
>
>
>
>
>
>
> > On 21 October 2011 10:26, Matt Wynne <m... at mattwynne.net> wrote:
>
> >> On 18 Oct 2011, at 15:02, Jens-Christian Fischer wrote:
>
> >>> Hi there
>
> >>> I have a weird situation. I have inherited a project in Rails 1.2.3
> >>> that has been upgraded to Rails 2.3.14 (and is running). I have
> >>> installed Cucumber and Rspec to start to write features/tests for the
> >>> new code that needs to be written. In my Gemfile, these Gems are
> >>> loaded:
>
> >>> group :test do
> >>>  gem 'rspec-rails', '~> 1.3.4', :require => 'spec/rails'
> >>>  gem 'rspec', '~> 1.3.2', :require => 'spec'
> >>>  gem "capybara", "0.3.9"
> >>>  gem "cucumber", "0.9.4"
> >>>  gem "cucumber-rails", "0.3.2"
> >>>  gem 'database_cleaner'
> >>> end
>
> >>> When I run the specs (bundle exec spec spec), I get error messages
> >>> because the plugins of the application aren't loaded.
>
> >>> Indeed, if I bundle the gems in "group :test, :development do ", then
> >>> script/server and script/console fail to start as well because the
> >>> plugins aren't loaded.
>
> >>> Anyone seen this problem or can give me a hint of why the plugins
> >>> suddenly aren't loaded (and where I should poke to find the cause)?
>
> >>> thanks
> >>> Jens-Christian
>
> >> My guess is that, because this is an older Rails app, it doesn't use Bundler as you'd expect. In a Rails 3 app, your config/application.rb will have something like this near the top:
>
> >>    Bundler.require(:default, Rails.env) if defined?(Bundler)
>
> >> That's the magic that tells Bundler to require all the plugins for the test environment when you run the tests. You'll need to stick something like that into your Rails 1 app.
>
> >> One other problem you'll probably hit: Capybara won't work with Rails apps that old, so you'll need to use Webrat for integration testing instead.
>
> > The op said the app had been upgraded to 2.3.14 which supports
> > capybara (has rack). The Rails 2.3.12 that (for my sins) I'm currently
> > working on has some code near the bottom of config/boot.rb to load
> > bundler.
>
> > class Rails::Boot
> >  def run
> >    load_initializer
>
> >    Rails::Initializer.class_eval do
> >      def load_gems
> >        @bundler_loaded ||= begin
> >          result = Bundler.require :default
> >          Bundler.require(Rails.env) unless Rails.env.test?
> >          result
> >        end
> >      end
> >    end
>
> >    Rails::Initializer.run(:set_load_path)
> >  end
> > end
>
> > HTH
>
> If Bundler is the issue, you have to have followed these instructions(probably where the snippet above came from) to get things set up with Rails 2.3
>
> http://gembundler.com/rails23.html
>
> -lenny
>
>
>
>
>
>
>
>
>
>
>
> > All best
>
> > Andrew
>
> >> cheers,
> >> Matt
>
> >> --
> >> Freelance programmer & coach
> >> Author,http://pragprog.com/book/hwcuc/the-cucumber-book(with Aslak Hellesøy)
> >> Founder,http://relishapp.com
> >> +44(0)7974430184 |http://twitter.com/mattwynne
>
> >> _______________________________________________
> >> rspec-users mailing list
> >> rspec-us... at rubyforge.org
> >>http://rubyforge.org/mailman/listinfo/rspec-users
>
> > --
> > ------------------------
> > Andrew Premdas
> > blog.andrew.premdas.org
> > _______________________________________________
> > rspec-users mailing list
> > rspec-us... at rubyforge.org
> >http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list