Having jotted down some models, with some inheritence I tried to run some unit tests. After waiting for rake test_units to run I got a rake of errors (if you'll forgive the play on words). The errors were to do with unknown tables in the tear down stage. The unknown tables corresponded to sub-types where single table inheritence was used. In other words, these tables *shouldn't* exist. Any thoughts? I can only hope there is another beginner's error lurking in my project. Sean .
on 2006-04-12 12:09
on 2006-04-12 12:21
One workaround seems to be to delete the generated fixtures for the subtypes and change the unit tests for the subtypes to use the top level parent's fixtures. This effectively says the fixture file for the parent will have fixtures for all the different subtypes. Consequently, the teardown will only tear down the table for the parent, rather than trying to delete entries from phantom tables. A reasonable workaround but it would be nice if the model generator (which scaffolds the tests) could catch this nuance, perhaps only generating test classes for model objects that directly extend the active record stuff?
on 2006-04-12 18:07
+! for Sean's workaround. In fact, I actually don't generate models for my subclasses... I just do them by hand. When I only have one, I use the parent class's unit test file to test the subclasses.