Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
86
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

RSpecでテストデータベースの準備

bundle exec rspec spec/

を実行すると、以下のエラーが発生する。

~vendor/bundler/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:379:in `check_pending!': Migrations are pending; run 'rake db:migrate RAILS_ENV=test' to resolve this issue. (ActiveRecord::PendingMigrationError)

テストデータベースが無いかららしい。
以下を実行し、テストデータベースを準備する。

bundle exec rake db:test:prepare

以前はこれだけでOKだったらしいが、Rails4だと以下も実行しないと解消されない。

bundle exec rake db:migrate RAILS_ENV=test

参考URL
Ruby on Rails Tutorial News - Preparing the test database


補足

最初に以下を実行しておけば、ハマらなかったっぽい。

bundle exec rake db:create:all

・・・読み飛ばしてた・・・orz

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
86
Help us understand the problem. What are the problem?