ruby-on-rails – Rspec / Rails:未初始化的常量ActiveSupport :: Autoload(NameError)

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Rspec / Rails:未初始化的常量ActiveSupport :: Autoload(NameError)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图运行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!
原文链接:https://www.f2er.com/ruby/268143.html

猜你在找的Ruby相关文章