1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Rspec】railsでテスト用のDB作成

Posted at

railsでテスト用のDBを作成します。

database.ymlにtest用のDBを記述します。

database.yml
default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: sample_development

test:
  <<: *default
  database: sample_test

test環境を指定して、migrationしてあげます。

$ bundle exec rake db:migrate RAILS_ENV=test

以上です。

参考: https://qiita.com/tocomi/items/2dba0de52eefdcf33fd7

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?