Forum: Ruby on Rails Model relationships in tests

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Keith L. (Guest)
on 2006-02-17 04:37
(Received via mailing list)
I'm finding that its a pain to create yml files for tests where there
are relationships between tables/classes.
For example, I might have something like this:

vehicle.yml
red_ford:
  id:1
  owner_id:2

owner.yml
ford_owner:
  id:2
  address_id:5

address.yml
home_address:
  id:5
  etc.

To build up complex test relations, I have to edit all three files,
keeping track of the ids / fkeys for each test case. I've thought about
skipping foreign keys altogether in the fixtures and creating the
relations programmatically in the test, or possibly writing a custom
fixture generator of some sort. I know I could create the relations in
the db one way or the other and export, but that is not much better.

Any ideas/thoughts on this would be appreciated!
Keith
This topic is locked and can not be replied to.