With RSpec, how to seed the database on load?

后端 未结 6 1464
一个人的身影
一个人的身影 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:38

    In spec_helper.rb or rails_helper.rb:

    RSpec.configure do |config|
      config.before(:suite) do
        Rails.application.load_seed # loading seeds
      end
    end
    

提交回复
热议问题