On 3/20/08, Tero Tilus <[EMAIL PROTECTED]> wrote:
> On Wed, 19 Mar 2008, Joe Van Dyk wrote:
>  > do I have to manually clear out the database after a story runs?
>
>
> I'm wondering the same, but with specs.  Database gets dirty and
>  tests start to fail when i repeatedly do rake spec.

>From what I've seen, the test infrastructure (which RSpec takes from
the Rails Test::Unit based code) relies on fixtures to initialize the
database BEFORE running tests.

The setup code clears any tables for which fixtures are declared, then
loads those fixtures.

It's a little counterintuitive that the tables don't get cleared AFTER
the test, but I guess it makes sense in that without clearing before
loading those tables wouldn't be in a known state at the beginning of
the test.

What I've done is to have fixtures with a single record for tables I
want to 'clear'.   Alternatively you can do something like:

       MyModel.delete_all

For any tables you want to clear, in the before block for tests, or in
the xxx_story.rb for stories.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to