Load fixtures for each methode

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

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

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