Jul 02 2006

Ruby on Rails: Fixtures Gotcha

Published by Robert Fischer at 9:00 pm under To Be Categorized

Watch out for this little behavior change….

Ruby on Rails has deprecated — or at least defaulted away — some behavior that’s advertised in Agile Web Development with Ruby. Ruby has this nifty feature called fixtures that lets you set up test data in your database automatically. It’s extremely easy, and makes for some rockin’ test development.

In Agile Web Development with Ruby, it says that you can do this in a file:

user_alice:
  id: 2
  name: alice

And then you would have a member variable initialized to the proper values in your unit test. You can then start talking about that data in Ruby-speak as “@user_alice” — which still screws with me, because @ means “array” to all us Perl-heads. But @ means “member variable” in Ruby-speak, so there you go.

Popularity: 2% [?]

Trackback URI | Comments RSS

Leave a Reply

Green Web Hosting! This site hosted by DreamHost.