Build A Hash Of Model Attributes
Have you ever found yourself creating an ActiveRecord
object with FactoryBot with the sole purpose of turning it into a hash of attributes?
FactoryBot has a built-in method for doing this:
It also accepts any traits for that factory:
This is a handy way of build a base set of attributes when testing an API endpoint.
Last updated