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
I'd like to safely bypass the creation of a factory when no overrides or traits were specified. Ultimately, the idea is to reduce the number of records created after a test setup by defaulting to a fixture when no special attributes are required.
Note: This problem may already have been solved, and I need to learn about the solution. See the "Additional Context" section for questions.
Is there a way to access these values safely and not monkey patch or tinker with private APIs?
Is there an existing approach to prevent the creation of a record when no arguments are passed other than the name of the factory?
Any input would be appreciated about that issue, except maybe feedback about how bad the idea is; I already know that 😂
The number of records created in specs with factories is known to have issues.
Any change helping developers with this issue would be significant, especially when dealing with legacy codebases.
EDIT: Maybe using a custom strategy and redefining the #association would be good enough as often the number of records created are from linked associations.
The text was updated successfully, but these errors were encountered:
Problem this feature will solve
I'd like to safely bypass the creation of a factory when no overrides or traits were specified. Ultimately, the idea is to reduce the number of records created after a test setup by defaulting to a fixture when no special attributes are required.
Note: This problem may already have been solved, and I need to learn about the solution. See the "Additional Context" section for questions.
Something along these lines:
The formats could fit exactly the ones used in
FactoryBot::FactoryRunner
initializationDesired solution
It seems that exposing these methods to the evaluator could be a solution?
Note: Naming can change as the evaluator already has
@overrides
variable, but unless mistaken is for all the record attributes.Alternatives considered
Custom FactoryBot::FactoryRunner with hook?
I can access these exact values by monkey patching
FactoryBot::FactoryRunner
which doesn't feel right.The FactoryRunner could be registered/injected like strategies with some hooks?
Additional context
I guess it relates to some extent to #1681
Questions
Any input would be appreciated about that issue, except maybe feedback about how bad the idea is; I already know that 😂
The number of records created in specs with factories is known to have issues.
Any change helping developers with this issue would be significant, especially when dealing with legacy codebases.
EDIT: Maybe using a custom strategy and redefining the
#association
would be good enough as often the number of records created are from linked associations.The text was updated successfully, but these errors were encountered: