# Delete the fixtures on a functionnal test

**URL:** <https://www.ruby-forum.com/t/delete-the-fixtures-on-a-functionnal-test/106678>\
**Category:** Rails\
**Created:** [June 13, 2007, 7:05am UTC](https://www.ruby-forum.com/t/delete-the-fixtures-on-a-functionnal-test/106678 "2007-06-13T07:05:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cyril\_mougel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a9adbd/32.png) [@cyril\_mougel](https://www.ruby-forum.com/u/cyril_mougel)\
**Post date:** [June 13, 2007, 7:05am UTC](https://www.ruby-forum.com/t/delete-the-fixtures-on-a-functionnal-test/106678/1 "2007-06-13T07:05:18Z")

</div>

Hi,

Since couple a day, I block with the delete of my fixtures in my  
functionnals test. In my controller, I need test a redirect if there  
are no value.

But i load my fixtures in start of my test and in a specific test I  
want delete all. Only in this method, not in other method. In API, I  
discover the method delete\_existing\_fixtures, who seem the good  
practice, but I can’t find how use it. I have always the information  
of method not found.

So I want know if anyone has an information for delete my fixtures in  
a test.

thanks

–  
Cyril M.

---

<div class="post-metadata">

**Author:** ![cyril\_mougel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a9adbd/32.png) [@cyril\_mougel](https://www.ruby-forum.com/u/cyril_mougel)\
**Post date:** [June 14, 2007, 5:31am UTC](https://www.ruby-forum.com/t/delete-the-fixtures-on-a-functionnal-test/106678/2 "2007-06-14T05:31:22Z")

</div>

cyril mougel wrote:

> So I want know if anyone has an information for delete my fixtures in  
> a test.

This is just an ActiveRecord question. Given a model called Model, just  
call  
Model.destroy\_all before the test case that needs to see no records.

Tip: Don’t destroy every record in every model. Only destroy the exact  
ones  
your tests need destroyed. If you change fixtures or behavior later in a  
way  
this test dislikes, it should fail, and that might stop you from making  
a  
mistake.

–  
Phlip  
[Test Driven Ajax (on Rails) [Book]](http://www.oreilly.com/catalog/9780596510657/)  
“Test Driven Ajax (on Rails)”  
assert\_xpath, assert\_javascript, & assert\_ajax
