2013-04-14 2 views
2

Я в настоящее время в главе 7 Учебник Hartl, и каждый раз, когда я бегунеопределенный метод `infer_base_class_for_anonymous_controllers =» для # <RSpec :: Основной :: Конфигурация: 0x007f7fb3a62b80> (NoMethodError)

расслоение Exec RSpec спецификации/

следующие результаты:

/Users/siciliana/sample_app/spec/spec_helper.rb:31:in `block in <top (required)>': undefined method `infer_base_class_for_anonymous_controllers=' for #<RSpec::Core::Configuration:0x007f7fb3a62b80> (NoMethodError) 
     from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core.rb:79:in `configure' 
     from /Users/siciliana/sample_app/spec/spec_helper.rb:11:in `<top (required)>' 
     from /Users/siciliana/sample_app/spec/models/user_spec.rb:12:in `require' 
     from /Users/siciliana/sample_app/spec/models/user_spec.rb:12:in `<top (required)>' 
     from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load' 
     from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files' 
     from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map' 
     from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files' 
     from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run' 
     from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process' 
     from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run' 
     from /usr/local/rvm/gems/ruby-2.0.0-p0/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun' 

Может кто-то пожалуйста объяснить, что происходит здесь к абсолютному новичку?

spec_helper.rb:

# This file is copied to spec/ when you run 'rails generate rspec:install' 
ENV["RAILS_ENV"] ||= 'test' 
require File.expand_path("../../config/environment", __FILE__) 
require 'rspec/rails' 
require 'rspec/autorun' 

# 
RSpec.configure do |config| 
    # ## Mock Framework 
    # 
    # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: 
    # 
    # config.mock_with :mocha 
    # config.mock_with :flexmock 
    # config.mock_with :rr 

    # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 
    config.fixture_path = "#{::Rails.root}/spec/fixtures" 

    # If you're not using ActiveRecord, or you'd prefer not to run each of your 
    # examples within a transaction, remove the following line or assign false 
    # instead of true. 
    config.use_transactional_fixtures = true 

    # If true, the base class of anonymous controllers will be inferred 
    # automatically. This will be the default behavior in future versions of 
    # rspec-rails. 
    config.infer_base_class_for_anonymous_controllers = false 

    # Run specs in random order to surface order dependencies. If you find an 
    # order dependency and want to debug it, you can fix the order by providing 
    # the seed, which is printed after each run. 
    #  --seed 1234 
    config.order = "random" 

end 
+0

Пожалуйста, покажите свой файл spec_helper –

+0

Добавлено выше .. спасибо за вашу помощь! –

+1

Вы недавно обновили rspec? Я только что обновил до 2.6 и начал иметь эту же проблему – tir38

ответ

0

я получаю ту же ошибку (хотя и не следуя учебник).

Я считаю, что эта установка требует 'rspec/rails'

Мое решение было переместить линию

config.infer_base_class_for_anonymous_controllers = # whatever 

От spec_helper.rb к rails_helper.rb.

Смежные вопросы