Forum: Ruby on Rails Functional testing - don't create schema each time

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Obelix (Guest)
on 2009-03-03 00:23
(Received via mailing list)
Setting up the data for my rails server is non trivial, it includes
schema creation, seeding the database with seed data, running indexing
using ferret.

I want to write functional tests that use the seed data and indices.

However, each time I run the functional tests, the db schema gets
dropped and re-created.  Is there a way to preserve existing schema
and not re-create it each time?

thanks
Phlip (Guest)
on 2009-03-03 03:15
(Received via mailing list)
Obelix wrote:

> Setting up the data for my rails server is non trivial, it includes
> schema creation, seeding the database with seed data, running indexing
> using ferret.
>
> I want to write functional tests that use the seed data and indices.
>
> However, each time I run the functional tests, the db schema gets
> dropped and re-created.  Is there a way to preserve existing schema
> and not re-create it each time?

Then it wouldn't be a test.

You need to test by running each step in the setup for the test for the
subsequent step. Test seeding by asserting the DB is empty (or by
emptying your
fixtures out!), call the seed method, and assert the database is seeded.
Test
indexing by seeding the database, asserting ferret is unindexed, calling
the
indexer, and asserting ferret can find data. And so on.

Test isolation is very important, and ActiveRecord will fight
you to preserve it. AR will think that you have simply neglected to tear
down
some database detail, and will diligently tear it down for you!

--
   Phlip
   http://www.zeroplayer.com/
Obelix (Guest)
on 2009-03-03 04:48
(Received via mailing list)
Thanks.

I guess we disagree on what I want to test :).

It was a simple solution of creating my own rake tasks, instead of
using the pre-built rake tasks.
This topic is locked and can not be replied to.