Cleaning up after stories

do I have to manually clear out the database after a story runs?
Seems like the data the story left is still in there.

Joe

On Wed, 19 Mar 2008, Joe Van D. 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.

On 3/20/08, Tero T. [email protected] wrote:

On Wed, 19 Mar 2008, Joe Van D. 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/

On Thu, Mar 20, 2008 at 4:02 AM, Rick DeNatale [email protected]
wrote:

database BEFORE running tests.
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.

Seems like the tables should get cleared before and after the tests?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs