You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello guys, I'trying DRY my code with traits but I can't understand how to use traits in callbacks. Code below represents what i'm trying to do and obviously - doesn't works. Or maybe i'm using wrong approach?
FactoryGirl.definedotrait:abc_tdoabctrue#lots of vars goes hereendtrait:abc_fdoabcfalse#lots of vars goes hereendfactory:test,:class=>Testdotransientdosome_varfalseend#some traits hereafter(:build)do |obj,evaluator|
ifevaluator.some_varabc_telseabc_fendendendend
The text was updated successfully, but these errors were encountered:
@ofetisov traits are unusable in callbacks - imagine it as a named block to refer to some attributes you'd assign in the factory itself.
If you're attempting to conditionally apply a trait, my recommendation would be to do so from the call site (where you call create(:thing, :trait_1)) instead of in the factory itself.
Hello guys, I'trying DRY my code with traits but I can't understand how to use traits in callbacks. Code below represents what i'm trying to do and obviously - doesn't works. Or maybe i'm using wrong approach?
The text was updated successfully, but these errors were encountered: