Forum: Ruby on Rails teardown not cleaning the BD?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Alain Pilon (Guest)
on 2006-05-17 06:45

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

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
    #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
    #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

Any ideas?

thanks a lot!
This topic is locked and can not be replied to.