Teardown not cleaning the BD?


#1

Hi,

I am a bit confused, I have a few functionnal tests were I add/delete
records on top of the ones provided in the fixture and it seems like the
records are surviving the teardown. Isnt teardown supposed to be ran
after each test? So if I have something like:

def teardown
Client.delete_all
Concept.delete_all
Variation.delete_all
ClientVariation.delete_all
end

All the records from my DB should be deleted…

Well, when I run my test, I get a faillure on a test that is supposed to
make sure that a specific record is deleted. When I look at the DB, the
record is still there.

The test goes like this:

def test_delete_concept
#make sure the concept record is present
assert_not_nil Concept.find(concepts(:entreprise).id)
#make sure the variations record is present
assert_not_nil Variation.find_by_concept_id
(concepts(:entreprise).id)
#find a client_variation
first_variation = Variation.find_by_concept_id
(concepts(:entreprise).id, :limit => 1)
#make sure it is present
assert_not_nil ClientVariation.find_by_variation_id
(first_variation.id)
#delete the record from the DB
get :delete_concept, {:concept_id => concepts(:entreprise).id}
#search for the record, if not there, raises an exception
assert_raises(ActiveRecord::RecordNotFound) {
Concept.find(concepts(:entreprise).id) }
#search for the variation, if not there, raises an exception
#this is the line that generate the faillure
assert_raises(ActiveRecord::RecordNotFound) {
Variation.find_by_concept_id(concepts(:entreprise).id) }
#search for the client_variation, if not there, raises an exception
end

Any ideas?

thanks a lot!