Yet a little post here… maybe I should gather more information and experience and write bigger post… But that will do for now… I think that in the end, I’ll try to find time to write a big article about TDD on rails, with my whole experience… I’ll just let it documented here.
Next step for my TDD application: using fixtures. Fixtures permit you to populate you database before running some tests. For example, you want to see if your User.find_admin stuff works the way you want, then you’ll just populate your database with a couple of Admin users and check if your method retrieves them from the database correctly.
Rails ships with its out of the box fixtures solution called fixtures. But reading some articles, search through the github projects and learning how the default fixtures implementation works made me realize that it can be a pain… And there is some fixtures replacement, here is a non exhaustive list:
- fixjour
- replacefixtures
- machinist
- object_daddy
- factory_girl
- …
And much more. That disconcerting, so much options. I quickly read the github (if github hosted) readme file and even before reading this prediction I choosed factory_girl because of its simplicity.
What do I mean with simplicity? INHO you should have a good idea of what the plugin/gem/code is doing giving a quick look at the github project home. Fixtures are something quite simple and the fixture replacement should quite simples too. And factory_girl caught my attention excatly because of this: clear, clean, easy to understand and to use.