Doz
Doz

Reputation: 7149

undefined method infer_base_class_for_anonymous_controllers

OK new on RoR, and trying to run spork on a skeleton app and get the error below:

Using RSpec, Rails
Preloading Rails environment
Loading Spork.prefork block...
undefined method `infer_base_class_for_anonymous_controllers=' for #<RSpec::Core::Configuration:0x007fe0b5672850> (NoMethodError)
/Users/doronkatz/Development/Rails/tuts/MySecondRailsApp/spec/spec_helper.rb:38:in `block (2 levels) in <top (required)>'
/Users/doronkatz/.rvm/gems/ruby-2.0.0-p353/gems/rspec-core-2.14.7/lib/rspec/core.rb:120:in `configure'
/Users/doronkatz/Development/Rails/tuts/MySecondRailsApp/spec/spec_helper.rb:18:in `block in <top (required)>'
/Users/doronkatz/.rvm/gems/ruby-2.0.0-p353/gems/spork-1.0.0rc4/lib/spork.rb:24:in `prefork'
/Users/doronkatz/Development/Rails/tuts/MySecondRailsApp/spec/spec_helper.rb:4:in `<top (required)>'
/Users/doronkatz/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/Users/doronkatz/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
/Users/doronkatz/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/Users/doronkatz/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'

My GemFile is as follows:

 gem 'rails', '4.0.2'

 # Use postgresql as the database for Active Record
 gem 'pg'


 ....
 group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
 gem 'sdoc', require: false
end

group :development, :test do
 gem 'capybara',     '2.1.0'
 gem 'rspec-rails'
 gem 'activeadmin', github: 'gregbell/active_admin'
 gem 'database_cleaner'
 gem 'spork-rails', '4.0.0'
 gem 'guard-spork', '1.5.0'
 gem 'childprocess', '0.3.6'

end

And my spec_helper:

 RSpec.configure do |config|
   ....
 config.infer_base_class_for_anonymous_controllers = false
 config.order = "random"
 config.include Capybara::DSL

Upvotes: 0

Views: 842

Answers (2)

australis
australis

Reputation: 481

I had this issue for something else, and to resolve it I moved

config.infer_base_class_for_anonymous_controllers

from spec_helper.rb to rails_helper.rb

(Also answered here)

Upvotes: 0

Peter Alfvin
Peter Alfvin

Reputation: 29419

The infer_base_class_for_anonymous_controllers method is provided by rspec-rails. My guess is that you are not requiring it prior to calling RSpec.configure.

Upvotes: 2

Related Questions