I am new to factory_girl and trying to figure out how to efficiently generate a factory for the following models:
class Company < ActiveRecord::Base has_and_belongs_to_many :tags end class Tags < ActiveRecord::Base has_and_belongs_to_many :companies validates :type , :inclusion => { :in => %w(market location) } end
I reviewed previous answers to StackOverflow (including this one ), however most of them are outdated and / or do not have the correct answer to the question. Is there anyone who can help identify the factories for these two objects with Factorygirl?
Update
Here is what I have found so far
FactoryGirl.define do factory :tag do id 448 trait :market do type "market" end trait :location do type "location" end name "software" end factory :company do id 1234 name "Apple Inc." factory :company_with_tags do
source share