SBaronda.com a little place I like to call home.


FactoryBot Tips

Jul. 30, 2020

Using FactoryBot bots outside of Rails Projects is as simple as

rails c -e test
include FactoryBot::Syntax::Methods
FactoryBot.find_definitions
FactoryBot.definition_file_paths << 'new/path/to/factories' # only needed if default paths don't suffice
create(:my_cool_factory)

I use this quite a bit to analyze the SQL that gets called and to validate my factories in isolation.


comments powered by Disqus