Newer versions of Rails has a nice feature where you can use label references for fixtures. So instead of:
# posts.yml
test_post:
user_id: 1
title: My Test Post
You can do this:
test_post:
user: quentin
title: My Test Post
However, if your model class name is in a pluralized form, you might find that label references won’t work. That’s because fixtures derive their class name from the singular form of the table name by default. Fortunately, you can fix this by adding this line to your TestHelper:
class Test::Unit::TestCase
# Explicitly map the table name to class name
set_fixture_class :accounts => 'accounts'
end
Hopefully, this will save someone else from having to dig through the Rails fixtures internals.