Ruby on rails Rails/Factory Girl:未初始化常量FactoryGirl(NameError)
我安装了Ruby on rails Rails/Factory Girl:未初始化常量FactoryGirl(NameError),ruby-on-rails,rspec,factory-bot,rspec-rails,Ruby On Rails,Rspec,Factory Bot,Rspec Rails,我安装了factory\u girlgem,当我运行测试时,我得到一个错误: `块:未初始化的常量FactoryGirl(NameError) 这是我的spec\u helper.rb RSpec.configure do|config| config.include FactoryGirl::Syntax::Methods config.expect_with:rspec do| expections| expections.include\u chain\u子句\u in\u custom\
factory\u girl
gem,当我运行测试时,我得到一个错误:
`块:未初始化的常量FactoryGirl(NameError)
这是我的spec\u helper.rb
RSpec.configure do|config|
config.include FactoryGirl::Syntax::Methods
config.expect_with:rspec do| expections|
expections.include\u chain\u子句\u in\u custom\u matcher\u descriptions=true
结束
config.mock_with:rspec do|mock|
mocks.verify_partial_doubles=true
结束
结束
如何修复它?在
spec/spec\u helper.rb
中,尝试添加
FactoryGirl.find\u定义
在
要求“工厂女孩轨道”
或者确保您遵循指南。这一定是您的答案 应在spec/support/factory_.rb中添加所需的内容
我只是把这个放在这里给像我这样笨手笨脚的人。一切都很好,但我在一个地方打电话给
FactoryGirl
,当时我只安装了FactoryBot
。新手错误。希望能有所帮助。您能从Gemfile
粘贴任何相关条目吗?这是您的完整的spec\u helper.rb
?这是Rails项目吗?谢谢Joe,我的问题解决了