Test database and migrations

Hi,

I’d like to have the results of a migration file that prepopulates my
development database available for testing. So, right now, after the
usual rake migration, I can access my prepopulated data via script/
console, but not in my unit tests. I’ve reviewed comments on this
subject but the custom rake tasks do not work or attempting a fix with
RAILS_ENV=test rake db:migrate as a command does not help either. Any
suggestion on how I can get the results of my migration available in
the test environment?

Thanks,

Grar

On Apr 10, 2:30 pm, Grary [email protected] wrote:

The test database is filled with the data from your fixture files -
running migrations against it accomplish nothing because it is wiped
at the start of the test run. Your best bet is probably to write
something that will dump yml from your database. You should consider
using db/seeds.rb to seed your database - migrations are not intended
to fufill that need.

Fred

Frederick,

Thanks. So, my desire to have pre-populated (whether from seeding or
otherwise) databases available in testing is unusual? I would have
expected a basic interest in having any and all development data,
e.g., zip code data, available for testing purposes, but my takeaway
from your response is that testing is typically performed on a limited
subset of development/production data that has been supplied from
fixtures. Can you please confirm?

Thanks,

Grar

On Apr 10, 9:52 am, Frederick C. [email protected]

On Apr 10, 3:17 pm, Grary [email protected] wrote:

Frederick,

Thanks. So, my desire to have pre-populated (whether from seeding or
otherwise) databases available in testing is unusual? I would have
expected a basic interest in having any and all development data,
e.g., zip code data, available for testing purposes, but my takeaway
from your response is that testing is typically performed on a limited
subset of development/production data that has been supplied from
fixtures. Can you please confirm?

Correct (although there’s no constraint I’m aware of on the size of
your fixture data). You want test runs to be consistent - having the
dataset your tests run against change just because you’ve been messing
around in development would be a bad thing. More and more people are
actually skipping fixtures and using stuff like factory_girl.

Fred