Complex Associations with factory_girl
factory_girl is great for DRYing up test code and making tests isolated and maintainable. What it's not so great at is any association more complicated than
belongs_to. I found a nice trick on Stack Overflow for
The Factory.after_ hooks appear to be the only way to do this successfully.
It's a shame, because it makes it really painful to use factories. What used to be a one-line call to create whatever you need becomes writing your own factories that call