Permalink
Browse files

Change spec helpers to skip over incomplete models

* If a model was created for some other purpose, besides testing its
  persistence logic, it's likely it was an anonymous class and may be considered
  incomplete and impossible to auto-migrate.
  • Loading branch information...
1 parent e7d51df commit 1cda2bec4eded8cbd16b7f81628aa9d4e937918b @dkubb dkubb committed Apr 9, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/dm-core/spec/lib/adapter_helpers.rb
@@ -29,15 +29,23 @@ def describe_adapter(kind, &block)
# create all tables and constraints before each spec
DataMapper::Model.descendants.each do |model|
next unless model.respond_to?(:auto_migrate!)
- model.auto_migrate!(@repository.name)
+ begin
+ model.auto_migrate!(@repository.name)
+ rescue IncompleteModelError
+ # skip incomplete models
+ end
end
end
after :all do
# remove all tables and constraints after each spec
DataMapper::Model.descendants.each do |model|
next unless model.respond_to?(:auto_migrate_down!)
- model.auto_migrate_down!(@repository.name)
+ begin
+ model.auto_migrate_down!(@repository.name)
+ rescue IncompleteModelError
+ # skip incomplete models
+ end
end
# TODO consider proper automigrate functionality
if @adapter.respond_to?(:reset)

0 comments on commit 1cda2be

Please sign in to comment.