Rspec is using my development DB

后端 未结 5 1051
心在旅途
心在旅途 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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-05 13:36

    Relates to Rails 4.2.1 which is the latest stable version as of this post

    Im still trying to solve this. However as a "stop-gap" you can prepend your rspec commands with an environment declaration "RAILS_ENV=test".

    For example: to run a test you would write:

    RAILS_ENV=test rspec path/to/test_spec.rb

    You could alias rspec as "RAILS_ENV=test rspec" but that would just be hiding the problem and as such I personally haven't done this ... yet.

    Ill be sure to update this thread with a solution as soon as I find one as none of the above as helped me at all.

提交回复
热议问题