Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Zombie Population Explosion – A Lesson in Factorygirl Creation (joingrouper.com)
7 points by zimkies on Feb 19, 2015 | hide | past | favorite | 2 comments


Is this an ActiveRecord thing? We use FactoryGirl and DataMapper at our site and we can just use the build hooks all over. When DataMapper saves an object it saves the entire tree, which means that when FactoryGirl creates the object the process looks like this:

    1. Instantiate a new, unsaved User
    2. Instantiate a new, unsaved Weapon and assign to the User
    3. Save the user
    4. Save cascades and saves the Weapon


Unintended side-effects like these are why I prefer to stick to normal fixtures. They get the job done and save me from adding another dependency to my projects. Fixtures are also pretty straightforward and keep me from learning yet another DSL. I'm sure FactoryGirl has valid usecases but it's not for me.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: