Skip to content

Instantly share code, notes, and snippets.

@opahk
Forked from dolzenko/factory_girl_debugging.rb
Created March 15, 2012 12:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opahk/2043980 to your computer and use it in GitHub Desktop.
Save opahk/2043980 to your computer and use it in GitHub Desktop.
Commands to debug Factory Girl from console
require 'factory_girl_rails'
require 'rspec'
require 'rspec-rails'
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)
Dir[Rails.root.join('spec/factories/*.rb')].each { |f| load f } # => loads factories again
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment