FactoryGirl: Defining associations
Sonntag, 17. April 2011, 22:00 Uhr | roberto@vasquez-angel.de |Assume you have projects that belongs to a customer. You can define a factory like that:
Factory.define(:customer) do |customer| customer.email "customer@example.com" customer.password "foobar" end Factory.define(:project do |project| project.name "Example project" project.description "This is an example project" project.targeted_at DateTime.now.advance(:days => 7) project.association :customer, :factory => :customer end