What's the difference with Factory Girl?

80 views
Skip to first unread message

Pablo Olmos de Aguilera Corradini

unread,
Jul 2, 2014, 5:18:58 PM7/2/14
to fabrica...@googlegroups.com
I really don't want to start a flame war, I really don't. I have been using FG for a while and I like it, swimming through Discourse source code, I found that they picked Fabrication, but it looks really similar.

I have also searched google only finding a question on stack overflow[1], but it doesn't help too much.

Until now, the only big difference it seems that have specific support for mongoid (which I use, so it seems by itself nice), the syntax also looks similar, and it would be great if you can enlightenment me about its differences :) (specially why Paul decided to build a new gem instead picking an exisiting one).

Regards!

[1]http://stackoverflow.com/questions/12179107/comparing-factory-girl-with-fabrication

Paul Elliott

unread,
Jul 2, 2014, 5:48:38 PM7/2/14
to fabrica...@googlegroups.com
Hey Pablo,

That is a perfectly valid question and I'll do my best to answer it. To be honest, I haven't used FactoryGirl in many years so I can't tell you exactly what the differences between the two gems are. I can tell you about some of the cool things Fabrication does though.

- You can generate anything at all. In Fabrication, you can specify the class name to the fabricator definition and that class can be anything at all, even an OpenStruct. In that case, you can produce anything you feel like on the fly. That gives it a very high degree of flexibility.
- Actively tested against lots of versions of the popular ORMs. I work around the bugs and variations in different versions of ORMs so you don't have to worry about it. Check the Appraisal file to see the details.
- Transients! You can specify transients in a fabricator, which are virtual attributes that you can set in the definition or at fabricate time and they are only accessible within the context of the fabricator. They are NOT set on the final produced object. You can leverage that in a lot of different ways and I have found them very useful.
- Block syntax at fabricate time. When you call Fabricate(:whatever), you can pass it an attributes hash as well as a block. The block syntax affords you all the same goodness that you have when you are defining a Fabricator.
- Pairs well with cucumber. Fabrication is cucumber-aware and comes out of the box with some handy step definitions and knowledge of the cucumber world. When it is running in a cucumber suite, it remembers what has been fabricated and uses that information for parenting in the generated steps.
- Lazy loading of fabricators. You don't need a fabrication-rails gem because of some design decisions I made early on. Fabricators are not actually loaded unless you try to fabricate something and the whole gem is autoloaded, so it doesn't add any baggage unless you actually use it. Feel free to include it in any environment.
- Actively maintained. I try to respond to issues and questions as quickly as I can and if it is during US Eastern waking hours then I can usually get to it pretty quickly. I am always happy to read over your fabricators and rewrite them with my intimate knowledge of the gem. If you ever get stuck, send what you're working on to this list and I've got your back.

That is a short list of things off the top of my head. If you dig deep, there are a lot of other great things it does, too.

As for why I wrote it, it was because I was exploring some new ideas in the fixture replacement space and didn't want to do that in their playground. It wasn't because I was unhappy with Factory Girl or thoughbot...they are great people. If you ever see me at a conference, I would be happy to discuss all this in greater detail :)


-- Paul


--
You received this message because you are subscribed to the Google Groups "fabrication" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabricationge...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages