If you’re using RSpec and FactoryGirl to automate testing for your Rails app, you probably know that when creating a factory for a model that has association you can simply specify the factory of the associated model. For example, suppose your Contact model has associations with Phone and Store models: