public
Last active

Commands to debug Factory Girl from console

  • Download Gist
factory_girl_debugging.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12
require 'factory_girl_rails'
require 'rspec'
require 'rspec-rails'
require 'rspec/mocks/standalone' # => if factories need stubs (for remote services for example)
 
include FactoryGirl::Syntax::Methods # make FG methods available at top level, so you can do `> create :user`
 
def reload_factories!
FactoryGirl.instance_variable_set(:@factories, nil) # => clear loaded factories/sequences
# FactoryGirl.instance_variable_set(:@sequences, nil)
load Rails.root.join('spec/factories.rb') # => loads factories again
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.