Rspec is using my development DB

后端 未结 5 932
心在旅途
心在旅途 2021-02-05 13:32

I\'m using Rspec for testing. However, it uses my development DB instead of my test DB. How can this occur?

I simply use rspec to run my tests: don:my_project_root

5条回答
  •  余生分开走
    2021-02-05 13:44

    I don't know if any of you is still having the issue, but for me moving

    ENV["RAILS_ENV"] ||= 'test'
    

    from rails_helper.rb to the top of spec_helper.rb fixed it. spec_helper.rb does a few things before loading rails_helper.rb, and something probably touches the database during that time.

提交回复
热议问题