FactoryGirl 和工厂内的变量
如果我想做类似
FactoryGirl.define do
factory :leaf do
end
factory :tree do
l = []
leaves do
l << Factory.build(:leaf)
//some app logic here
l
end
root l.first
end
end
“我应该如何编写它才能使其工作”之类的事情该怎么办?
也许有人有一个关于使用 FactoryGirl 的非常复杂和不平凡的示例的链接?
谢谢。
What if I want to do something like
FactoryGirl.define do
factory :leaf do
end
factory :tree do
l = []
leaves do
l << Factory.build(:leaf)
//some app logic here
l
end
root l.first
end
end
How should I write this to make it work?
And maybe somebody have a link with really complex and untrivial examples of using FactoryGirl?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不能 100% 确定我已遵循您的要求,但这行得通吗?
I'm not 100% sure I've followed what you're asking but would this work?