gpt4 book ai didi

ruby-on-rails - Rails/工厂女孩 : Uninitialized constant FactoryGirl (NameError)

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

我安装了 factory_girl gem,当我运行测试时出现错误:

`block in ': uninitialized constant FactoryGirl (NameError)

这是我的spec_helper.rb

RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
end

如何修复?

最佳答案

spec/spec_helper.rb中,尝试添加

FactoryGirl.find_definitions

require 'factory_girl_rails'

或确保您关注 factory_bot's Getting Started指导。

关于ruby-on-rails - Rails/工厂女孩 : Uninitialized constant FactoryGirl (NameError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27545598/

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