Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add my seed data to my test database using rake db:seed?

I'm using Factory Girl to populate my seed data and adding it to the db in seed.rb.

I'm then running my tests using Cucumber.

I have a price table that contains seed data that I want in all my environments.

I want rake db:seed to add it to my dev and test db's and for cucumber to be able to use that test seed. Then I'll add that seed data in prod also.

How can I ensure that my seed data is added to both dev and test db's?

rake db:seed #only adds it only to my dev database
like image 336
Jamis Charles Avatar asked Jan 22 '11 14:01

Jamis Charles


2 Answers

You can try something like this:

rake db:seed RAILS_ENV=test --trace
rake db:seed RAILS_ENV=production --trace
like image 92
Christian Avatar answered Oct 27 '22 14:10

Christian


Check out this answer from a similiar post.

I really think it's better to use factories to fill test database. And if you need seed data during your tests add it as a before :all block in spec_helper/test_helper.

like image 31
Mirko Avatar answered Oct 27 '22 15:10

Mirko