机械师 vs FactoryGirl - 优缺点
我正在与factory_girl一起工作,但正在寻找机械师宝石。您能告诉我 - 迁移到机械师有哪些优点和缺点吗?您比较过这些库吗?
I'm working with factory_girl, but looking at the machinist gem. Could you tell me please - what are the pros and cons of migrating to machinist? Have you compared those libs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Machinist 实际上深受 factory_girl,但有所不同,因为机械师的作者想要不同的语法。从那时起,factory_girl添加了不同的语法层来模拟其他工厂库(包括机械师的“蓝图”语法)。换句话说,两者非常相似,只是默认语法不同。就我个人而言,我使用factory_girl。
Machinist was actually heavily inspired by factory_girl, but varied because machinist's author wanted a different syntax. Since then, factory_girl added different syntax layers to simulate other factory libraries (including machinist's "blueprint" syntax). In other words, both are extremely similar, just with a different default syntax. Personally, I use factory_girl.
实际上,Machinist 比 Factory Girl 有一个很大的优势:它不会访问数据库来获取关联对象。看这里:
机械师 vs 工厂女孩:机械师获胜!仍然
不确定 Machinist 如何处理这个问题,但无论如何,它可能会为您的测试库带来巨大的性能提升。
Actually, Machinist has a big advantage over Factory Girl: it doesn't hit the DB for associated objects. Look here:
Machinist vs Factory Girl: Machinist win!
Still not sure about how Machinist handles this, but anyhow it could be a huge performance boost for your test base.
我以前没有使用过 machinist,但我可以说,factory_girl 非常易于使用、扩展和消除任何以轨道为中心的特性,它必须在任何类型的项目中使用。
I've not used machinist before, but I can say factory_girl is quite easy to use, extend and rip out any rails-centricness it has to be used in any type of project.