运行$ rspec spec时未初始化的常量ApplicationController(NameError)

时间:2014-07-11 09:45:14

标签: ruby-on-rails-4 rspec-rails spree

我正在尝试在rails 4.1中使用rspec for tdd。我在rails中使用spree commerce和refinery cms gem。但是当我运行$ rspec spec时,它会给我以下错误。

uninitialized constant ApplicationController (NameError)
from /home/zapbuild/.rvm/gems/ruby-2.1.2/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/bundler/gems/spree-refinery-authentication-f9168bd7fe97/lib/spree_refinery_authentication/engine.rb:1:in `<top (required)>'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/bundler/gems/spree-refinery-authentication-f9168bd7fe97/lib/spree-refinerycms-authentication.rb:1:in `<top (required)>'
from /home/zapbuild/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `require'
from /home/zapbuild/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/zapbuild/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `each'
from /home/zapbuild/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/zapbuild/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `each'
from /home/zapbuild/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `require'
from /home/zapbuild/.rvm/gems/ruby-2.1.2@global/gems/bundler-1.6.2/lib/bundler.rb:132:in `require'
from /var/www/ws_groupbuy/config/application.rb:7:in `<top (required)>'
from /var/www/ws_groupbuy/config/environment.rb:2:in `require'
from /var/www/ws_groupbuy/config/environment.rb:2:in `<top (required)>'
from /var/www/ws_groupbuy/spec/spec_helper.rb:3:in `require'
from /var/www/ws_groupbuy/spec/spec_helper.rb:3:in `<top (required)>'
from /var/www/ws_groupbuy/spec/models/spree/product_spec.rb:1:in `require'
from /var/www/ws_groupbuy/spec/models/spree/product_spec.rb:1:in `<top (required)>'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `load'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `block in load_spec_files'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `each'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `load_spec_files'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.99.1/lib/rspec/core/command_line.rb:18:in `run'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:103:in `run'
from /home/zapbuild/.rvm/gems/ruby-2.1.2/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:17:in `block in autorun'

我的spec_helper是:

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require "capybara/rspec"
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
config.order = "random"
config.infer_spec_type_from_file_location!

0 个答案:

没有答案