I found the following comment on a blog from @ryanb in 2012, and to this day it is still a spot on, comprehensive list of everything I see people do wrong with factories to make their lives unintentionally harder:
While factories can get you in trouble, the key is to use them correctly. Here are some suggestions.
- The base factory should be just enough to get validations passing and never contain specific data that is used by a test.
- If you need an association, make a separate factory for it (such as comment_with_article) but keep the base factories free of associations unless they are required to make a valid record.
- Don't attempt to get fancy, such as building has_many associations with factories. Any factory overly complex should be moved up into the test so it is clear what it is doing.