Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 251
Alexey Poimtsev Avatar asked Jan 25 '10 09:01

Alexey Poimtsev


2 Answers

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.

like image 81
Ryan McGeary Avatar answered Nov 04 '22 07:11

Ryan McGeary


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.

like image 29
MetalElf0 Avatar answered Nov 04 '22 06:11

MetalElf0