On Rails 4.0.0.rc1, Ruby 2.0.0, after I run a migration, I see the following error when I try to run a test through rspec
:
/Users/peeja/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0.rc1/lib/active_record/migration.rb:376:in `check_pending!': Migrations are pending; run 'rake db:migrate RAILS_ENV=test' to resolve this issue. (ActiveRecord::PendingMigrationError)
That doesn't seem right. No one migrates their test database, do they? They db:test:prepare
it, which—to be fair—I've forgotten to do. So I run rake db:test:prepare
and run my rspec
command again…and see the same error.
If I actually rake db:migrate RAILS_ENV=test
, the error does in fact go away.
What's going on? Is this new in Rails 4?
rake db:test:prepare
works? – itsnikolayrake db:test:prepare
does not work even ifschema.rb
is up to date. Only migrating the test database works. – Krisrake db:migrate RAILS_ENV=test
solved it for me. – rubyandcoffeeActiveRecord::Migration.maintain_test_schema!
just beforeRSpec.configure
block inrails_helper.rb
Docs: relishapp.com/rspec/rspec-rails/docs/… – Suraj