With RSpec, how to seed the database on load?

后端 未结 6 1428
一个人的身影
一个人的身影 2021-01-30 03:28

I\'m using rspec for testing w my rails 3 app. I need to seed the database before the tests start. How can I seed the database with the following:

/db/seeds.rb

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 03:52

    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.

提交回复
热议问题