I have a Rails 3 project with the following in my Gemfile…
group :development, :test do
gem 'factory_girl_rails', '~> 1.1.beta1'
end
I also have several factory definitions in spec/factories.rb which my tests are using successfully. I would like to use these factories to populate my development database from time to time.
Is there anyway I can get Rail’s db:fixtures:load rake task to load the factories defined in spec/factories.rb instead of the Yaml fixtures in test/fixtures? If not, is there another rake task in factory_girl_rails or Rails that would load the data generated by my factory definitions?
Pretty sure the best approach is to just write my own rake task to accomplish this but wanted to check here first.
An alternative way could be to make your
seeds.rbfile load this for you.Just prepend the factories with
if Rails.env == "test"