Forum: Ruby on Rails From development DB to test DB during tests

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Eb2c5bf45b4a4749a19d5a1401855d90?d=identicon&s=25 nuno (Guest)
on 2007-04-16 14:34
Hello, even after several months of Rails development I'm still facing
few problems with unit testing.

1) Inserting records during migration

My migration.rb is
def self.up
 create_table :rubriques do |t|
  t.column "libelle", :string
  t.column "rubrique_id", :integer
  t.column "visible", :boolean

 Rubrique.create(:libelle => 'root', :rubrique_id => nil, :visible =>

Problem is : the 'root' record is never inserted in the test database
even when using rake db:migrate RAILS_ENV="test" or rake test:purge and
then rake test:units

Why ? No idea

2) Second common problem :
I use fixtures which are loaded accordingly during unit testing. But
when running functional tests which don't use any :fixtures statement,
it's common to have the fixtures datas still loaded in the test
The only solution I found was adding delete_existing_fixtures() in the
setup() method... No the 'right' way in my point of view...

Any help appreciated, thank you !
83ca41657a99b65d99889abe712ba5e2?d=identicon&s=25 Jason Roelofs (Guest)
on 2007-04-16 14:49
(Received via mailing list)
rake test:units / test:functionals blasts the test database away and
rebuilds the schema from the development database (aka, no data). This
*not* use migrations; it uses db/schema.rb. If you want data in the test
you need to either use fixtures or manually create the data in your
(basically the same thing, when you think about it).

This topic is locked and can not be replied to.