Machinist vs FactoryGirl - pros and cons

冷暖自知 提交于 2019-12-04 08:48:01

问题


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?


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/2131357/machinist-vs-factorygirl-pros-and-cons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!