Defining factories
Options (transients)
Transient attributes will not get passed to the model, but will be available in after-create hooks. Nested Factories
Traits
Trait helps you to remove duplication. |
Building factories
Associations
Dependent attributes
Attributes can be based on the values of other attributes. Aliases
Aliases allow to use named associations more easily. |
Cheatography
https://cheatography.com
FactoryBot Cheat Sheet by Ash Angell
FactoryBot is a fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance.
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets