On 3/28/06, Maxim K. [email protected] wrote:
become a standard (and be included in Rails) or there are other ways /
thoughts on this ?
Thanks in advance
The core team isn’t particularly enthusiastic about this feature. I
did a patch against trunk for it the other day, and various people
said it worked fine, but wasn’t necessary.
In the meantime, you can use the new subdirectory support for fixtures
to make your life easier.
Assuming your superclass model is called ‘Example’, and your table
name is ‘examples’:
Create test/unit/fixtures/examples.yml. You can put fixtures in here,
or just leave it blank. It has to exist, or the current fixture code
won’t load the subdirectories.
Create a new directory: test/unit/fixtures/examples/
Inside that directory, you can create as many .yml files as you want,
with any names you desire, and they will be picked up as fixtures for
In your unit tests, call “fixtures :examples”
All of the STI subclass fixtures will be in one big pile (e.g.
examples(:some_fixture_name) ), but at least you can keep your test
data in separate files. If you name the fixtures well, it isn’t too
Personally, I much prefer being able to access my fixtures by the name
of the model, rather than of the table… but that’s off the list for