I am looking for DBMS my test suite. Trying to create a tag that represents the specific values โโof the has_many relationship in the parent factory. Ideally, these values โโwill be created from a separate factory.
I want to do something like this:
factory :room do
trait :bathroom do
type :bathroom
end
end
factory :house do
trait :one_bathroom do
association, :rooms, factory: [:room, :bathroom]
end
end
The above should work if the relationship between the house and the room was from 1 to 1. But the House and the room have a relationship from one to many, so there are many rooms in the House. Based on this example, I would like to create a house in which there were many rooms with one bathroom.
Any ideas?
source
share