Skip to content

Instantly share code, notes, and snippets.

@probablykabari
Created February 14, 2010 00:05
Show Gist options
  • Save probablykabari/303755 to your computer and use it in GitHub Desktop.
Save probablykabari/303755 to your computer and use it in GitHub Desktop.
require "dm-core"
require 'dm-migrations'
require "test/unit"
DataMapper.setup(:default, 'sqlite3::memory:')
class Person
include DataMapper::Resource
property :id, Serial
property :name, String
end
class Doctor < Person
self.storage_names[:default] = 'doctors'
property :hospital, String
end
class TestAutoMigrate < Test::Unit::TestCase
def test_storage_is_created_with_auto_migrate
Person.auto_migrate!
assert repository.storage_exists?(Person.storage_name)
Doctor.auto_migrate!
assert repository.storage_exists?(Doctor.storage_name), '<doctors> table is not created'
end
def test_storage_is_created_directly
repository.create_model_storage(Doctor)
assert repository.storage_exists?(Doctor.storage_name)
end
def teardown
repository.destroy_model_storage(Doctor)
repository.destroy_model_storage(Person)
end
end
# RESULTS
#########
# Loaded suite bug1198_test
# Started
# .F
# Finished in 0.004982 seconds.
#
# 1) Failure:
# test_storage_is_created_with_auto_migrate(TestAutoMigrate) [confirm_test.rb:25]:
# <doctors> table is not created
#
# 2 tests, 3 assertions, 1 failures, 0 errors, 0 skips
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment