我正在尝试测试我的 factoryGirl 工厂:
#spec/factories/post.rb
FactoryGirl.define do
factory :post do |p|
p.title "Title"
p.body "Body"
end
end
FactoryGirl.factories.map(&:name).each do |factory_name|
describe "The #{factory_name} factory" do
it 'is valid' do
build(factory_name).should be_valid
end
end
end
按照这个
但我有这个错误:
in `block in <top (required)>': uninitialized constant Factory (NameError)