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
When setting up test data with FactoryBot, it can be cumbersome and repetitive to check if a record exists before creating it.
For instance, in our current test setup, we have to manually use find_by followed by create if the record is not found.
I believe that is somewhat intended. Sharing data between test runs is usually a code smell, either in the runtime code or your testing code.
Assuming you have some level of cleanup strategy, why not just create a new token each time? is the name a hardcoded value in your runtime code? if the object is highly complex and/or for instance, provided by an external service, have you thought of using mocks?
I get what you are asking for here, but passive (ab)use of a Find_or_create (in a test suite for actor objects) often leads to flaky test suites.
Problem this feature will solve
When setting up test data with FactoryBot, it can be cumbersome and repetitive to check if a record exists before creating it.
For instance, in our current test setup, we have to manually use find_by followed by create if the record is not found.
Desired solution
Alternatives considered
Additional context
The text was updated successfully, but these errors were encountered: