-
-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Labels
Description
In the FactoryBot docs they give a simple example on overriding associations by passing an existing one into the create command:
FactoryBot.define do
factory :author do
name { 'Taylor' }
end
factory :post do
author
end
end
eunji = build(:author, name: 'Eunji')
post = build(:post, author: eunji)
My attempt to recreate this in Cypress:
cy.appFactories([["build", "author", { name: "Eunji" }]]).then(
([author]) => {
cy.appFactories([["build", "post", { author }]]);
}
);
The command to build the post fails because author is returned as json and is not actually an instance of Author which throws an Author expected, got {...} which is an instance of Hash error in FactoryBot. Any guidance on using the results from a build command in a new build call?