Build A Hash Of Model Attributes
Last updated
Was this helpful?
Last updated
Was this helpful?
Have you ever found yourself creating an ActiveRecord
object with 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.