# Load fixtures for each methode

**URL:** <https://www.ruby-forum.com/t/load-fixtures-for-each-methode/138848>\
**Category:** Rails\
**Created:** [May 28, 2008, 10:59am UTC](https://www.ruby-forum.com/t/load-fixtures-for-each-methode/138848 "2008-05-28T10:59:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddy\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@eddy\_b](https://www.ruby-forum.com/u/eddy_b)\
**Post date:** [May 28, 2008, 10:59am UTC](https://www.ruby-forum.com/t/load-fixtures-for-each-methode/138848/1 "2008-05-28T10:59:35Z")

</div>

Hi,

officially Rails load for each test the fixures file into the database  
but in my case Rails load the fixures only on the begining of the class  
and so I get strange side effects. An example:

country\_test.rb:  
require File.dirname( **FILE** ) + ‘/…/test\_helper’

class CountryTest \< Test::Unit::TestCase  
fixtures :countries

def test\_should\_destroy  
assert\_equal 2, Country.count  
Country.find(:first).destroy  
assert\_equal 1, Country.count  
end

def test\_should\_have\_2\_entries  
assert\_equal 2, Country.count  
end

end

countries.yml:  
germany:  
code: DE  
name: Germany  
japan:  
code: JP  
name: Japan

Error message:

1. Failure:  
test\_should\_have\_2\_fixtures(CountryTes…  
[test/unit/country\_test.rb:22]:  
\<2\> expected but was  
\<1\>.

2 tests, 3 assertions, 1 failures, 0 errors

Know anybody this phenomenon or make I a misstake?

Eddy

---

<div class="post-metadata">

**Author:** ![eddy\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@eddy\_b](https://www.ruby-forum.com/u/eddy_b)\
**Post date:** [May 28, 2008, 11:45am UTC](https://www.ruby-forum.com/t/load-fixtures-for-each-methode/138848/2 "2008-05-28T11:45:00Z")

</div>

On 28 May 2008, at 09:59, Eddy B. wrote:

> Hi,
> 
> officially Rails load for each test the fixures file into the database  
> but in my case Rails load the fixures only on the begining of the  
> class  
> and so I get strange side effects. An example:

It sounds like you’ve got transactional fixtures on (which means that  
for speed reasons rails doesn’t reload fixtures, but wraps tests in a  
transaction that is rolled back) but that your database doesn’t  
support transactions (which usually means mysql with myisam tables)

Fred

---

<div class="post-metadata">

**Author:** ![eddy\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@eddy\_b](https://www.ruby-forum.com/u/eddy_b)\
**Post date:** [May 28, 2008, 12:30pm UTC](https://www.ruby-forum.com/t/load-fixtures-for-each-methode/138848/3 "2008-05-28T12:30:26Z")

</div>

Frederick C. wrote:

> On 28 May 2008, at 09:59, Eddy B. wrote:
> 
> > Hi,
> > 
> > officially Rails load for each test the fixures file into the database  
> > but in my case Rails load the fixures only on the begining of the  
> > class  
> > and so I get strange side effects. An example:
> 
> It sounds like you’ve got transactional fixtures on (which means that  
> for speed reasons rails doesn’t reload fixtures, but wraps tests in a  
> transaction that is rolled back) but that your database doesn’t  
> support transactions (which usually means mysql with myisam tables)
> 
> Fred

You are my man! Thanks!!! With InnoDB as storage engine it works.

Many thanks, Eddy
