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,693
- 5
- 25
- 42

- 2,845
- 3
- 35
- 63
-
1not a direct answer to your question, but you might also check out miniskirt: http://www.stephencelis.com/2010/01/11/miniskirt.html ... as a factory_girl user, I like how this simple lib approaches factories with better syntax and less weight. – foz Jan 25 '10 at 17:26
-
41machinist? factory girl? miniskirt? what kind of forum did I stumble into? – Dónal Boyle Jan 25 '10 at 20:50
-
7@DonalBoyle you could be impressed more if you will know that there is also a [factory_boy](https://github.com/dnerdy/factory_boy) :) – galymzhan Mar 05 '11 at 18:11
3 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.

- 57,819
- 63
- 187
- 237

- 235,892
- 13
- 95
- 104
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.

- 9,060
- 5
- 45
- 53

- 1,087
- 1
- 8
- 11
-
7Just noticed in [this screencast](http://railscasts.com/episodes/158-factories-not-fixtures-revised) that you can use `FactoryGirl.build` if you don't want to hit the database. Probably a new feature. – jrhorn424 Apr 01 '12 at 01:15
-
1FactoryGirl.build actually hists the database for associated objects. FactoryGirl.build_stubbed creates objects without hitting the database. – Kristiina Dec 13 '13 at 14:45
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.

- 4,480
- 3
- 23
- 32