Search code examples
ruby-on-railsautotestsporkminitest

Rails + Spork + Minitest + Autotest and models


I installed Rails + Spork + Minitest + Autotest as shown by S. Christoffer Eliesen in how-to-combine-autotest-and-spork-in-rails-testing and it works great for tests that doesn't involve the database. It doesn't work if I add a model though:

rails g scaffold post name:string
rake db:migrate

It then gives me the following error:

ActiveRecord::StatementInvalid: Could not find table 'posts'

How can I make it "see" the database/table changes?


Solution

  • You need to run the migration in the test environment as well.

    rake db:migrate RAILS_ENV=test