我试图运行bundle exec rspec但是我在调用spec_helper.rb时遇到了以下错误
template.rb:8:in `<class:Template>': uninitialized constant ActiveSupport::Autoload (NameError)
这是我的spec_helper.rb文件:
require 'rubygems' require 'rspec/rails' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment",__FILE__) RSpec.configure do |config| config.infer_spec_type_from_file_location! end
解决方法
在将我的Rspec文件的顺序切换到以下后,我不再获得未初始化的常量错误:
require File.expand_path("../../config/environment",__FILE__) require 'rspec/rails' require 'capybara/rspec' require 'capybara/poltergeist' Capybara.register_driver :poltergeist do |app| Capybara::Poltergeist::Driver.new(app,{:js_errors=> false}) end RSpec.configure do |config| config.infer_spec_type_from_file_location!