Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change spec helper to explicit auto-migrate all models in a repository

* Models can be bound to specific repositories, but we want for the tests to
  always auto-migrate the models within the specified repository.
  • Loading branch information...
commit e7d51dfa056420bc9fe771f8758b9c54ea7e6506 1 parent 7691320
@dkubb dkubb authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/dm-core/spec/lib/adapter_helpers.rb
View
10 lib/dm-core/spec/lib/adapter_helpers.rb
@@ -27,15 +27,17 @@ def describe_adapter(kind, &block)
@repository.scope { DataMapper.finalize }
# create all tables and constraints before each spec
- if @repository.respond_to?(:auto_migrate!)
- @repository.auto_migrate!
+ DataMapper::Model.descendants.each do |model|
+ next unless model.respond_to?(:auto_migrate!)
+ model.auto_migrate!(@repository.name)
end
end
after :all do
# remove all tables and constraints after each spec
- if @repository.respond_to?(:auto_migrate_down!, true)
- @repository.send(:auto_migrate_down!, @repository.name)
+ DataMapper::Model.descendants.each do |model|
+ next unless model.respond_to?(:auto_migrate_down!)
+ model.auto_migrate_down!(@repository.name)
end
# TODO consider proper automigrate functionality
if @adapter.respond_to?(:reset)
Please sign in to comment.
Something went wrong with that request. Please try again.