gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 12:40:59 26 4
gpt4 key购买 nike

我正在尝试运行 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!

关于ruby-on-rails - Rspec/Rails:未初始化的常量 ActiveSupport::Autoload (NameError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24875626/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com