# A way to stop some fixtures from loading for certain tests?

**URL:** <https://www.ruby-forum.com/t/a-way-to-stop-some-fixtures-from-loading-for-certain-tests/204034>\
**Category:** Rails\
**Created:** [March 3, 2011, 7:02pm UTC](https://www.ruby-forum.com/t/a-way-to-stop-some-fixtures-from-loading-for-certain-tests/204034 "2011-03-03T19:02:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 3, 2011, 7:02pm UTC](https://www.ruby-forum.com/t/a-way-to-stop-some-fixtures-from-loading-for-certain-tests/204034/1 "2011-03-03T19:02:26Z")

</div>

I am using Rails 3. Is there a way to stop a fixture from loading for  
certain test cases?

Regards,  
Don Mc

---

<div class="post-metadata">

**Author:** ![dmcclean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dmcclean](https://www.ruby-forum.com/u/dmcclean)\
**Post date:** [March 3, 2011, 7:05pm UTC](https://www.ruby-forum.com/t/a-way-to-stop-some-fixtures-from-loading-for-certain-tests/204034/2 "2011-03-03T19:05:34Z")

</div>

It seems like best practice is to use a factory gem like factory\_girl  
instead of fixtures. Easily getting different data for different tests  
is one of the benefits of such an approach.

Best Wishes,  
Peter

---

<div class="post-metadata">

**Author:** ![dmcclean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dmcclean](https://www.ruby-forum.com/u/dmcclean)\
**Post date:** [March 3, 2011, 10:02pm UTC](https://www.ruby-forum.com/t/a-way-to-stop-some-fixtures-from-loading-for-certain-tests/204034/3 "2011-03-03T22:02:33Z")

</div>

On 3 March 2011 18:03, Peter B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It seems like best practice is to use a factory gem like factory\_girl instead of  
> fixtures. Easily getting different data for different tests is one of the benefits  
> of such an approach.

+1

You don’t need to chuck everything out and start again however. For  
the tests that are giving you the problem at the moment start using a  
factory (I like machinist rather than factory\_girl but it is a matter  
of personal preference) instead of the fixtures and as you add new  
tests or need to change old ones then do the same. There is no  
problem keeping the fixtures for the existing tests.

Colin
