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:

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.

On 10/18/07, Steve [email protected] wrote:

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

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 C. 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=797

Submitted. Request #14868

On 10/18/07, Keith McDonnell [email protected] 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?

On Oct 21, 2007, at 3:35 PM, Bryan H. wrote:

both the dev and test databases should they exist.

WDYT?

How are in-memory databases (sqlite3) going to work with that?

Scott