title: Cleanly Setting up multiple models in FactoryGirl for a test/spec
body: <p>I have been picking up on Rails best practices and learning to write good tests for my rails application.</p>
  
  <p>I am using rspec + FactoryGirl to test at the moment.</p>
  
  <p>For a while I was writing basic model and controller specs which usually required to set up only a couple of models and associations.</p>
  
  <p>Now I have a Model with a complex algorithm which does a lot of calculations based on different models.</p>
  
  <p>To test this method, I almost need all the models of my app to exists in test database with all associated relationships built between them.</p>
  
  <p>Now things are getting overwhelming. I need to keep track if all factories are correctly referencing each other. Also I need to verify if all factories have been created properly.
  Also a lot of FactoryGirl.create(:model) calls in my before(:each) method.</p>
  
  <p>I have a feeling that I am not doing things right. What is the best way to go about this situation? Most books and examples only cover only the very basic cases.</p>
  
  <p>Any pointers ideas and approches are welcomed.(Hope this question is not too wide in scope)</p>
  
  <p><strong>Example:</strong></p>
  
  <p>My application has multiple <code>projects</code>. Each project has_many <code>indexes</code> , <code>companies</code> and <code>mastertags</code>. Each company has_many <code>channels</code>. Every channel has_many <code>channel_tag_weights</code> across different <code>mastertags</code>. Also every channel has_many <code>Rawdatas</code>.</p>
  
  <p>This could be an example of a minimum model setup required.</p>