Unit testing with model inheritence

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 .

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?

+! 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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs