test/helper.rb in shanna-dm-tokyo-adapter-0.3.1 vs test/helper.rb in shanna-dm-tokyo-adapter-0.3.2

- old
+ new

@@ -18,13 +18,21 @@ class Test::Unit::TestCase include Extlib::Hook # after :teardown do def teardown - descendants = DataMapper::Model.descendants.dup.to_a + descendants = DataMapper::Model.descendants.to_a while model = descendants.shift - descendants.concat(model.descendants) if model.respond_to?(:descendants) - Object.send(:remove_const, model.name.to_sym) + descendants.concat(model.descendants.to_a - [ model ]) + + parts = model.name.split('::') + constant_name = parts.pop.to_sym + base = parts.empty? ? Object : Object.full_const_get(parts.join('::')) + + if base.const_defined?(constant_name) + base.send(:remove_const, constant_name) + end + DataMapper::Model.descendants.delete(model) end end end