我正在尝试配置 FactoryGirl 以使用我的 Cucumber 测试。我在 env.rb 中添加了以下几行
require 'factory_girl'
Dir.glob(File.join(File.dirname(__FILE__), '../../spec/factories/*.rb')).each {|f| require f }
当我运行“黄瓜功能”时,没有问题。我现在添加一个名为teacher.rb
to的文件spec/factories
并在其中添加以下内容:
FactoryGirl.define do
factory :teacher do
first_name "John"
last_name "Smith"
end
end
现在,当我跑步时,cucumber features
我得到:
uninitialized constant FactoryGirl (NameError)
我显然错过了一些东西,但它是什么?如何让 Cucumber 与 Factory Girl 合作?
谢谢!