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 . -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/2d05e29b/attachment.html
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 12/04/06, Sean Blezard <sean.blezard@gmail.com> wrote:> > 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 . >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/74f65077/attachment.html
+! 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. On 4/12/06, Sean Blezard <sean.blezard@gmail.com> wrote:> > 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 12/04/06, Sean Blezard <sean.blezard@gmail.com> wrote: > > > > 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 . > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060412/14d5a520/attachment.html