Why is the test DB not wiped upon entering a test case?

Hello Group.

I might be misunderstanding, but this does not make sense to me at all.

The reason there is a test database in the first place is that it gives
you a reliable state at the beginning of each
TestCase/test/context/spec. To me, this implies that when I do not load
fixtures at all, I get an empty DB (this IS a boundary condition, and I
have to test it).

Also between different model’s tests, the DB is never cleaned, given I
have no fixtures statements.

How can I ensure I have a DB that is clean except for the structure in
a TestCase/test/context/spec? Model.delete_all in the setup method?
What if I need my fixtures later in the test case? Model.delete_all in
the test methods themselves? Another test case? This all looks like
workarounds to me.

I’d be happy to be proven wrong, but this does look like a design error
to me. Wouldn’t it be more concise to just wipe the test DB upon
entering a TestCase/context?

Timm Gebhart

P.S.: This is my first post to this group. I am a web developer from
Germany, and found RoR to be a perfect match for me about 3 months ago.
So please excuse my ignorance and grammar errors.

I believe you need to implement the setup and teardown methods in a test
case. Otherwise the tests don’t clear out the database. Those methods
be automatically called before and after a test case.

Here’s an absolutely fabulous blog post that lists testing resources.


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