DB not being repopulated prior to Unit test execution


#1

I’m working my way through the AWD book and have just started the
testing chapter. The first two unit tests run as expected. When I add
the test for the ‘destroy’ function to product_test.rb, however, I’m
getting a failure I don’t understand.

The error I’m getting says that in the setup method for test_update, it
“couldn’t find Product with ID=1”. When I run product_test.rb without
the test_destroy test case, the other two methods (test_create &
test_update) find that record fine. When I add the test_destroy case
in, though, it appears that the database isn’t being cleaned and
restored before the test_update method is executed (which appears in
this case to happen after the test_destroy method). At least, that’s
the only explanation I can come up with for what’s happening.

Any help understanding this will be very much appreciated.

Bill