Every so often I’ll run a test suite and it will have a large number of failures. After debugging it’s normally something as simple as the test schema being out of date. I then run bin/rake db:test:prepare and everything is fine.
If I run my development environment and my schema is out of date, it throws an error and forces me to run bin/rake db:migrate. Should we be doing the same thing when we’re running tests? Or at the very least maybe throwing a warning that the test schema is ‘out of date’?
On one of the first apps I was building (a few years ago) I remember spending a few hours tracking down why my test was failing. I was new to ‘TDD’ and I thought it was something I was doing wrong. I called a friend and he asked ‘did you run db:test:prepare?’ and that solved my problem. I don’t run into this issue as much anymore, but I think it might prevent some frustration by new rails users.
I’m trying to think of why we wouldn’t be doing this and my mind is coming up blank. Let me know your thoughts!
Thanks,
Ryan