Fixtures, factories, ... etc don't execute the real create()
method. For instance, when an user is created, I generate a Preference object for him. But with fixtures I have to do it manually.
So could I do it with a script like all of my `User.create(:name => 'joe')? Or is there a popular gem who do that?
Thanks.
Factory Girl is a drop-in replacement for fixtures which allows associations that can be use as-is or can be overriden in your unit tests. It is pure ruby and as you can fine-tune at runtime the way objects are instantiated it is much more flexible than fixtures IMHO. By the way using Factory Girl with a mock framework (such as Mocha) avoids database hits therefore allow (much) faster tests.