Keith McDonnell
2007-Oct-18 14:51 UTC
[rspec-users] spec:models depends on development db:migration
For those interested .... rake spec:models seems to clone the test database from development. If your dev db is empty, the models task fails mysteriously. Anyway, to make sure your dev db is at the current migration version, I added this dependency in lib/tasks task ''spec:models'' => ''db:migrate'' Now the dev db is migrated up with each test pass. Keith
On Thu, 18 Oct 2007 15:51:37 +0100, Keith McDonnell wrote:> For those interested .... > > rake spec:models seems to clone the test database from development. If > your dev db is empty, the models task fails mysteriously. > > Anyway, to make sure your dev db is at the current migration version, I > added this dependency in lib/tasks > > task ''spec:models'' => ''db:migrate'' > > Now the dev db is migrated up with each test pass. > > KeithYeah, I was just about to post about this. This seems like incorrect behavior. Especially if you''re really doing behavior driven design. You''re going to be writing your tests and using the test environment first before you actually go through and use the dev env. When specs are run it should run all migrations for the test db, not just as far as dev has gone.
David Chelimsky
2007-Oct-18 16:30 UTC
[rspec-users] spec:models depends on development db:migration
On 10/18/07, Steve <vertebrate at gmail.com> wrote:> On Thu, 18 Oct 2007 15:51:37 +0100, Keith McDonnell wrote: > > > For those interested .... > > > > rake spec:models seems to clone the test database from development. If > > your dev db is empty, the models task fails mysteriously. > > > > Anyway, to make sure your dev db is at the current migration version, I > > added this dependency in lib/tasks > > > > task ''spec:models'' => ''db:migrate'' > > > > Now the dev db is migrated up with each test pass. > > > > Keith > > Yeah, I was just about to post about this. This seems like incorrect > behavior. Especially if you''re really doing behavior driven design. You''re > going to be writing your tests and using the test environment first before > you actually go through and use the dev env. When specs are run it should > run all migrations for the test db, not just as far as dev has gone.Please submit a feature request: http://rubyforge.org/tracker/?group_id=797
Keith McDonnell
2007-Oct-18 18:24 UTC
[rspec-users] spec:models depends on development db:migration
Hi David, If you give me some direction I''ll try & submit a patch. Keith
On Thu, 18 Oct 2007 11:30:03 -0500, David Chelimsky wrote:>> Yeah, I was just about to post about this. This seems like incorrect >> behavior. Especially if you''re really doing behavior driven design. You''re >> going to be writing your tests and using the test environment first before >> you actually go through and use the dev env. When specs are run it should >> run all migrations for the test db, not just as far as dev has gone. > > Please submit a feature request: http://rubyforge.org/tracker/?group_id=797Submitted. Request #14868
Bryan Helmkamp
2007-Oct-21 19:35 UTC
[rspec-users] spec:models depends on development db:migration
On 10/18/07, Keith McDonnell <keith at dancingtext.com> wrote:> rake spec:models seems to clone the test database from development. If > your dev db is empty, the models task fails mysteriously. > > Anyway, to make sure your dev db is at the current migration version, I > added this dependency in lib/tasks > > task ''spec:models'' => ''db:migrate'' > > Now the dev db is migrated up with each test pass.In my projects I actually go out of my way to remove the DB clone task as a dependency for spec tasks. The reason is pure speed. It shaves a few seconds off every run at the expense of having to manually run RAILS_ENV=test rake db:migrate after schema changes. Perhaps we should consider a change to remove the dependency in RSpec core but provide specific error messaging should the problem occur. And it would be simple enough to have the db:migrate rake task migrate both the dev and test databases should they exist. WDYT? -- Bryan Helmkamp http://brynary.com -- My blog
Scott Taylor
2007-Oct-21 21:41 UTC
[rspec-users] spec:models depends on development db:migration
On Oct 21, 2007, at 3:35 PM, Bryan Helmkamp wrote:> On 10/18/07, Keith McDonnell <keith at dancingtext.com> wrote: >> rake spec:models seems to clone the test database from >> development. If >> your dev db is empty, the models task fails mysteriously. >> >> Anyway, to make sure your dev db is at the current migration >> version, I >> added this dependency in lib/tasks >> >> task ''spec:models'' => ''db:migrate'' >> >> Now the dev db is migrated up with each test pass. > > In my projects I actually go out of my way to remove the DB clone task > as a dependency for spec tasks. The reason is pure speed. It shaves a > few seconds off every run at the expense of having to manually run > RAILS_ENV=test rake db:migrate after schema changes. > > Perhaps we should consider a change to remove the dependency in RSpec > core but provide specific error messaging should the problem occur. > And it would be simple enough to have the db:migrate rake task migrate > both the dev and test databases should they exist. > > WDYT?How are in-memory databases (sqlite3) going to work with that? Scott