Reputation: 3716
I want to have the Seeds.rb file run a method in a file from the Rails.root.join('spec')
directory which will fill the database with data generated by FactoryGirl. Lets call this file "helpers.rb" with the method "seed_data"
Edit:
require Rails.root.join('spec','helpers.rb')
links the file. source
This method I want to use in a before(:all) do seed_data end
to seed the test database and rake db:seed
for development/production databases with the same effect.
Upvotes: 3
Views: 2550
Reputation: 3716
require Rails.root.join('spec','helpers.rb')
require 'rubygems' #so it can load gems
require 'factory_girl_rails' #so it can run in development
seed_data
def seed_data
Factory.create(:user)
end
Upvotes: 3