There are currently no answers to this question with Factory Girl 4.1 (what can I find) - how do you set up many, many relationships inside the factory?
For example, I have Students and Classrooms , which are in many ways using the connection table, so far I have had the following setting:
factory :classroom do name "Foo Class" ... end factory :student do name "John Doe" ... end factory :student_with_classroom, :parent => :student do after(:build) {|student| student.classrooms << classroom} end
However, this leads to:
NameError: undefined local variable or method `classroom' for #<FactoryGirl::SyntaxRunner>
My attempt was guesses for the most part, as I was unlucky to find any non-obsolete syntax for this.
source share