Hi have this special use case, in which I have to define a factory in one file without a certain parameter, and then insert it in the factory definition later. This is a case where I am importing factory definitions from an external dependency (gem, plugin, whtv) and I need to extend it in my project. Something like:
# external def
FactoryGirl.define do
factory :user do
email "[email protected]"
end
end
# proj def
FactoryGirl.define do
factory :user do
password "qwerty"
end
end
this code doesn't work, cuz factory girl thinks I'm redefining the factory. But what I'd really want would be extending it. Is this possible?
Ups... seems I found the answer. Next time, have to check the documentation a bit furtherer... Here's the answer for anyone interested:
# external def
FactoryGirl.define do
factory :user do
email "[email protected]"
end
end
# proj def
FactoryGirl.modify do
factory :user do
password "qwerty"
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With