In my RSpec file, I have used FactoryGirl to create objects that I have used in my RSpec file. In my RSpec file I have used three objects A
, B
and C
where C is dependent on B and B is dependent on A. Here in RSpec file I have written two test cases: one for testing index
method of my controller and another for update
method. So I have created the objects which I have used to test those two methods, as follows:
before(:each) do
@A = FactoryGirl.create(:A)
@B = FactoryGirl.create(:B)
@C = FactoryGirl.create(:C)
end
And here I am using test environment of Rails, so I am using corresponding test database which I have already. So to clean the database after running, I have written the following code:
after(:each) do
C.all.destroy
B.all.destroy
A.all.destroy
end
But the problem is that after running the spec, while I am checking the tables corresponding to them I find that data is not deleted. Here I have used DataMapper in my models. So can please anyone help me to fix this problem i.e. to clean those tables after each run of spec. Thank you.