Forum: Ruby on Rails unit testing with model inheritence

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Sean B. (Guest)
on 2006-04-12 12:09
(Received via mailing list)
Having jotted down some models, with some inheritence I tried to run
unit tests. After waiting for rake test_units to run I got a rake of
(if you'll forgive the play on words). The errors were to do with
tables in the tear down stage. The unknown tables corresponded to
where single table inheritence was used. In other words, these tables
*shouldn't* exist. Any thoughts? I can only hope there is another
error lurking in my project.

Sean .
Sean B. (Guest)
on 2006-04-12 12:21
(Received via mailing list)
One workaround seems to be to delete the generated fixtures for the
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
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
scaffolds the tests) could catch this nuance, perhaps only generating
classes for model objects that directly extend the active record stuff?
Brian H. (Guest)
on 2006-04-12 18:07
(Received via mailing list)
+! 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
to test the subclasses.
This topic is locked and can not be replied to.