Using Class#Find in dynamic fixtures

Hi,

I am currently coding my tests and I made a lot of fixture files. To
make everything simple (I thought), I didnt put the ID in the fixture,
insted when I needed to put the id of something, I used
Class.find_by_name “name of the item to find”.

When I use the file to import data in my migration everything is fine.
But when I use the same files for my unit test, there is a problem. If I
try to load the fixture all in a row, there is a crash as soon as I hit
a fixture that require to fetch the ID from another table.

It seems like it cant find the fixture because its not there.

This is also confirmed when I load every table one at the time, the
belongs_to.id field in my table are using the ID of records from the
previous test!!!

How can I fix this? And how can I have fixtures commit its import after
each execution?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs