Using erb in fixture to dynamically find a foreign key

Hi,

I have some unit tests that run perfectly when running the individual test but not when run via "rake test_units" ... here is a snippet from my fixture:

first:     id: 1     state_id: <%= State.find_by_name('Ontario').id %>

In my unit test for clubs I do load the related fixtures:

  fixtures :states, :clubs

Run test directly ...

  fraser@xxx:~/src/yyy$ ruby test/unit/club_test.rb   ...   1 tests, 32 assertions, 0 failures, 0 errors

Run test via "rake test_units" ...

  1) Error:   test_fixtures(ClubTest): Fixture::FormatError: a YAML error occured   parsing /home/fraser/src/naasc/config/../test/fixtures/clubs.yml. Please   note that YAML must be consistently indented using spaces. Tabs are not   allowed. Please have a look at YAML Ain't Markup Language   The exact error was: RuntimeError: Called id for nil, which would mistakenly   be 4 -- if you really wanted the id of nil, use object_id

Can anyone point out where I'm going wrong? It is rails 1.1.6, ruby 1.8.4, postgresql, foreign key constraints are being enforced at db level (as well as in models of course).

Thx!