Rspec is using my development DB

后端 未结 5 1021
心在旅途
心在旅途 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 14:00

    I had this issue and felt that moving things from rails_helper.rb to spec_helper.rb wasn't addressing the core issue. Why was rspec loading spec_helper before and/or without rails_helper.rb?? Then it dawned on me to check .rspec and lo and behold it was improperly set to:

    --require spec_helper
    

    Change that to

    --require rails_helper
    

    and it might just fix your issue without having to move stuff from rails_helper to spec_helper.

提交回复
热议问题