With RSpec, how to seed the database on load?
In spec_helper.rb or rails_helper.rb:
RSpec.configure do |config|
config.before(:suite) do
Rails.application.load_seed # loading seeds
end
end
However Scott's solution surely works for you, I believe the better way to solve your problem was to put the code responsible for seeding your test database within RSpec's configure block:
I use SeedFu and in my spec_helper I have:
RSpec.configure do |config|
# some other configuration code ...
config.before(:suite) do
# ...
SeedFu.seed
# ...
end
# some other configuration code ...
end
Try, something like this
rake db:seed RAILS_ENV=test
You can get a list of all rake commands doing
rake -T
If this is test data, you may want to look at putting it into fixtures which will be loaded on the start of the tests.