title: FactoryGirl with a product model : Rspec tell me that "Trait not registered"
body: <p>Hi magical community !</p>
  
  <p>Still a newbie with basic question for those who have time ;-)</p>
  
  <p>I created a User model and a Product model like this (thanks to @grotori):</p>
  
  
  
  <pre class="lang-rb prettyprint-override"><code>class User
    has_many :owned_products, class_name: "Product", foreign_key: "owner_id"
    has_many :borrowed_products, class_name: "Product", foreign_key: "borrower_id"
  end
  
  class Product
      belongs_to :owner, class_name: "User", foreign_key: "owner_id"
      belongs_to :borrower, class_name: "User", foreign_key: "borrower_id"
  end
  </code></pre>
  
  <p>Then I used FactoryGirl to create a factories.rb like this :</p>
  
  <pre class="lang-rb prettyprint-override"><code>FactoryGirl.define do
  
    factory :user do
      sequence(:name) { |n| "Person #{n}" }
      sequence(:email) { |n| "Person_#{n}@example.com" }
      password "kaboum"
      password_confirmation "kaboum"
    end
  
    factory :product do
      name "Product"
      owner
      borrower
    end
  end
  </code></pre>
  
  <p>In order to test the <code>dependent: :destroy</code> condition like this :</p>
  
  <pre class="lang-rb prettyprint-override"><code>describe User do
  
    before do
      @user = User.new(name: "Example User",
                          email: "user@example.com",
                          password: "kaboum",
                          password_confirmation: "kaboum")
    end
  
    describe "product associations" do
      before { @user.save }
      let!(:product) { FactoryGirl.create(:product, owner: @user) }
  
      it "should destroy associated product" do
        product_to_be_destroyed = @user.owned_products.first
        @user.destroy
        expect(product_to_be_destroyed).not_to be_empty
        expect(Product.where(id: product_to_be_destroyed.id)).to be_empty
      end
    end
  end
  </code></pre>
  
  <p>Rspec give me the answer <code>ArgumentError: Trait not registered: owner</code>.</p>
  
  <p>I searched <a href="https://stackoverflow.com/questions/14188273/rspec-gives-error-trait-not-registered-name">already answered questions</a> on stackoverflow but I couldn't fix my problem. One solution would be to assign a default value to my "owner" or "borrower" fields in my factories.rb, but I don't want that, which is possible accordingly to the <a href="https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md" rel="nofollow noreferrer">FactoryGirl help</a>.</p>
  
  <p>Any help will be gratefully received :-)</p>