I have a model `contact` that `has_many :locations, through: :relationships`, as well as `has_many :teams, through: :contacts_teams`. 

A contact **must** have an associated `team` and `location` in order to pass validations. In other words: a new `contact` must have an associated `relationship` record and an associated `contacts_team` record. Below are the models:

```
#models/contact.rb
class Contact < ActiveRecord::Base
  has_many :contacts_teams
  has_many :teams, through: :contacts

  has_many :relationships, dependent: :destroy
  has_many :locations, through: :relationships

  accepts_nested_attributes_for :contacts_teams, allow_destroy: true

  # upon create, validate that at least one associated team and one associated location exist
  validate :at_least_one_contacts_team
  validate :at_least_one_relationship

  private

  def at_least_one_contacts_team
    return errors.add :base, "Must have at least one Team" unless contacts_teams.length > 0
  end

  def at_least_one_relationship
    return errors.add :base, "Must have at least one Location" unless relationships.length > 0
  end
end

#models/contacts_team.rb
class ContactsTeam < ActiveRecord::Base
  belongs_to :contact
  belongs_to :team
end

#models/team.rb
class Team < ActiveRecord::Base
  has_many :contacts_teams
  has_many :contacts, through: :contacts_teams
end

#models/relationship.rb
class Relationship < ActiveRecord::Base
  belongs_to :contact
  belongs_to :location
end

#models/location.rb
class Location < ActiveRecord::Base
  has_many :relationships
  has_many :contacts, through: :relationships
end

```

For testing: with [factory\_girl](https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md) I want to create a `contact` factory that is able to successfully create a `contact` record. Since each `contact` record requires an associated `contacts_team` record and `relationship` record: when I create the `contact` record is should create those as well. Likewise: the `contacts_team` record should have an existing `team` it is associated to, and the `relation` record should have an existing `location` it is associated to. So essentially it should create a `location` and a `team` record as well.

**How can I create a contact record with a factory, which in effect creates an associated `contacts_team` record and a `relationship` record?**

Here are my current factories:

```
FactoryGirl.define do
  factory :contact do
    first_name "Homer"
    last_name "Simpson"
    title "Nuclear Saftey Inspector"
  end
end

FactoryGirl.define do
  factory :contacts_team do
  end
end

FactoryGirl.define do
  factory :team do
    name "Safety Inspection Team"
  end
end

FactoryGirl.define do
  factory :relationship do
  end
end

FactoryGirl.define do
  factory :location do
    name "Safety Location"
  end
end

```

If it is difficult/not possible to do this with factory\_girl: how can I do it with straight rspec? The issue is that I can't create a `contacts_team` record or a `relationship` record, because the `contact` it is associated to doesn't exist yet! And I can't create a `contact` record because an associated `contacts_team` record or a `relationship` record doesn't exist yet. It seems like I'm trapped, but there has to be a way to do this that is not sloppy.