fixture magic with associations: never use a FK id again!

I've written some fun code to ease the pain of associating between fixtures. 'Tis tested and documented! Essentially it allows you to replace this syntax

  user_id: 5

with this:

  user: :joe

as long as you have users.yml with

joe:   id: 5

http://blog.caboo.se/articles/2006/10/17/named-references-for-test-fixtures http://dev.rubyonrails.org/ticket/6424

There's not much actual code in there, and I sacrificed brevity for readability. Comments?

How do the dependencies work? Does it just scan the already-loaded fixtures? Use the first-found in case of duplicate keys?

No. Once all fixtures are loaded from this statement

fixtures :foo, :bar

It looks in :foo and :bar as the table names to match. It will only attempt to match if the value in this statement is a symbol:   user: :fred

In the case of duplicate keys, you're on your own and probably have bigger fish to fry. If you're relying on symbols loading into fixtures you're probably screwed, but then, who does that?

This is intended to be a really lightweight addition for people on the golden path of rails. More advanced matching algorithms of course welcome.

Been waiting for this for a while. Thanks for the patch!

Remind me why yaml is preferred to a ruby DSL again?