Sha256: 4e8bb5a2ade0179ae3aa9e9dfde68bc06e4415f198615ed4d81ae7f3307bf647

Contents?: true

Size: 772 Bytes

Versions: 3

Compression:

Stored size: 772 Bytes

Contents

ENV['LOG_NAME'] = 'spec'
require File.dirname(__FILE__) + '/../environment'

# Define a fixtures helper method to load up our test data.
def fixtures(name)
  entry = YAML::load_file(File.dirname(__FILE__) + "/fixtures/#{name}.yaml")
  klass = Kernel::const_get(Inflector.classify(Inflector.singularize(name)))
  
  database.log.debug { "AUTOMIGRATE: #{klass}" }
  klass.auto_migrate!
  
  (entry.kind_of?(Array) ? entry : [entry]).each do |hash|
    if hash['type']
      Object::const_get(hash['type'])::create(hash)
    else
      klass::create(hash)
    end
  end
end

# Pre-fill the database so non-destructive tests don't need to reload fixtures.
Dir[File.dirname(__FILE__) + "/fixtures/*.yaml"].each do |path|
  fixtures(File::basename(path).sub(/\.yaml$/, ''))
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
datamapper-0.2.0 spec/spec_helper.rb
datamapper-0.2.1 spec/spec_helper.rb
datamapper-0.2.2 spec/spec_helper.rb