简体   繁体   中英

Machinist vs FactoryGirl - pros and cons

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?

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.

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.

我之前没有使用机械师,但我可以说factory_girl非常容易使用,扩展和撕掉任何类型的项目必须使用的以导轨为中心的东西。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM