"uninitialized constant" when running RSpec tests with Rails 2.3.8 and the Bundler

I just modified the Rails 2.3.8 project to load gems using the Bundler, and not the default for the Rails 2.3 loading mechanism. I followed the official instructions , and the site works great in development. I use RVM to manage gems, and a specific gemset is loaded for the application.

However, the RSpec test suite does not work. I tried to run both the entire set and single tests using various commands:

autospec # My usual way of running tests
rake spec
spec .
spec spec/models/comment_spec.rb # Trying a single spec file in isolation
ruby spec/models/comment_spec.rb

I also tried running everything with a prefix bundle exec. Everything returns the same error:

/Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant InheritedResources::Base (NameError)
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `const_missing_not_from_s3_library'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
    from /Users/casper/Projects/cf/darebusters/app/controllers/admin/base_controller.rb:1
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:158:in `require'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:158:in `require'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:265:in `require_or_load'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:224:in `depend_on'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:136:in `require_dependency'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/rails-2.3.8/lib/initializer.rb:414:in `load_application_classes'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/rails-2.3.8/lib/initializer.rb:413:in `each'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/rails-2.3.8/lib/initializer.rb:413:in `load_application_classes'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/rails-2.3.8/lib/initializer.rb:411:in `each'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/rails-2.3.8/lib/initializer.rb:411:in `load_application_classes'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/rails-2.3.8/lib/initializer.rb:197:in `process'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/rails-2.3.8/lib/initializer.rb:113:in `send'
    from /Users/casper/.rvm/gems/ruby-1.8.7-p248@darebusters/gems/rails-2.3.8/lib/initializer.rb:113:in `run'
    from /Users/casper/Projects/cf/darebusters/config/environment.rb:9
    from /Users/casper/Projects/cf/darebusters/spec/spec_helper.rb:5:in `require'
    from /Users/casper/Projects/cf/darebusters/spec/spec_helper.rb:5
    from spec/models/comment_spec.rb:1:in `require'
    from spec/models/comment_spec.rb:1

, Inherited Resources - , , Inherited Resources - , .

, , , /activesupport-2.3.8/lib/active_support/dependencies.rb:158 /app/controllers/admin/base_controller . , . gem 'inherited_resources' Gemfile, . , , , Inherited Resources. " ".

Gemfile spec_helper.rb.

+3
3

, Bundler 1.0.3, Rspec-Rails 1.3.3 Rails 2.3.8, _rails. , Remarkable-Rails rspec/rails, .

: require = > nil Gemfile spec_helper , - .

+2

, , .

1.3.0 rspec rspec-rails, . rspec-rails changelog, , 1.3.0 . rspec-rails 1.3.2 .

+1

To fix this problem, I changed it using the Gemfile:

gem 'rspec-rails', '~> 1.3.2', :require => 'spec/rails'

to

gem 'rspec-rails', '~> 1.3.2'

and added the following to my spec helper

require 'spec/rails'
+1
source

Source: https://habr.com/ru/post/1755475/


All Articles