Last Updated: November 18, 2020
·
11.8K
· jamesgecko

Load FactoryGirl in Rails console

Simple, yet used rarely enough to be forgettable.

$ rails c
...
[1] pry(main)> require 'factory_girl'
=> true
[2] pry(main)> FactoryGirl.find_definitions
...
[3] pry(main)> FactoryGirl.create :my_thing

Magic!

2 Responses
Add your response

Wow! The rails + rspec error codes are a mess. This tip is really useful!!!

over 1 year ago ·

To avoid appending FactoryGirl at the beginning of every create, also run:

[4] pry(main)> include FactoryGirl::Syntax::Methods
over 1 year ago ·