How do I prepare test database(s) for Rails rspec tests without running rake spec?

后端 未结 6 1784
無奈伤痛
無奈伤痛 2020-12-04 14:28

After significant troubleshooting, I figured out that I needed to run rake spec once (I can abort with control-c) before I can run rspec directly (e.g. on a sub

6条回答
  •  不知归路
    2020-12-04 14:37

    I started by dropping my test database rake db:drop RAILS_ENV=test

    when trying to create a new test database I ran into an issue because my user account was not the same as the account that owns the databases so I created the database in PostgreSQL instead.

    type psql in the command prompt and then run the below to create a test database that uses an account other than your own. CREATE DATABASE your_database_name OWNER your_db_owner;

    then run your migrations in the test environment. rake db:migrate RAILS_ENV=test

提交回复
热议问题