使用Ruby gem并尝试在RSpec中使用FactoryBot.
我有这个support/factory_bot.rb:
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
config.before(:suite) do
FactoryBot.find_definitions
end
end
Run Code Online (Sandbox Code Playgroud)
并在spec_helper.rb:
require 'support/factory_bot'
Run Code Online (Sandbox Code Playgroud)
当我尝试运行spec rake任务时,我收到此错误:
support/factory_bot.rb:2:in `block in <top (required)>': uninitialized constant FactoryBot (NameError)
Run Code Online (Sandbox Code Playgroud)
我错过了什么?当我使用旧的factory_girl gem时,这常常工作正常,但它已经打破了重命名为factory_bot.谢谢!!