Rails + Spork + Minitest + Autotest and models
-
23-06-2021 - |
Question
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?
La solution
You need to run the migration in the test environment as well.
rake db:migrate RAILS_ENV=test
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow