Sha256: 175240fc2e4063219bd737f7dd8f7435a9b035a0191b6347afa5c6159ac3e6e7

Contents?: true

Size: 1013 Bytes

Versions: 1

Compression:

Stored size: 1013 Bytes

Contents

require 'rubygems'
require 'test/unit'
require "bundler/setup"
require 'shoulda'

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'dm-migrations'
require 'dm-tokyo-adapter'

class Test::Unit::TestCase
end

DataMapper::Logger.new(STDOUT, :debug) if $VERBOSE
DataMapper.setup(:default, {
  :adapter  => 'tokyo_cabinet',
  :database => 'tc',
  :path     => File.dirname(__FILE__)
})

DataMapper.setup(:sqlite, 'sqlite::memory:')

class Test::Unit::TestCase
  include Extlib::Hook

  # after :teardown do
  def teardown
    descendants = DataMapper::Model.descendants.to_a
    while model = descendants.shift
      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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-tokyo-adapter-0.4.1 test/helper.rb