Topic: Testing a method using delete_all

I am writing a test for a method being used in my model that uses the delete_all method.  The method essentially deletes all access_permission tokens that are older than 3 days.  In writing my test for it, I wrote a test case for a token older then 3 days, and one that is current.  However, the following test fails:

it does not prune a permission that is newer then three days old do
    @new_permission.should_not_receive(:destroy)
    AccessPermission.prune!
end

is there something about delete_all that I need to know here?  For example, does delete_all send a :destroy call to every instance?  Also, how can I test this to make sure that I am testing what I actually want to be testing, namely, that any permissions newer than 3 days old is not destroyed?

Last edited by dsullivan (2012-01-03 11:33:16)

Re: Testing a method using delete_all

Given the results, i think it's a fair assumption to say it does to a destroy on each object. I would instead test to see if the object still exists in the database after the method call.