Sha256: 5b60983ac6190fdc78d399131130ee5357ebf15165c5671b9a2489b5c377dc1f

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require 'pathname'
require 'spec'

# require the plugin
require Pathname(__FILE__).dirname.parent.expand_path + 'lib/dm-accepts_nested_attributes'

# allow testing with dm-validations enabled
# must be required after the plugin, since
# dm-validations seems to need dm-core
require 'dm-validations'
require 'dm-constraints'

ENV["SQLITE3_SPEC_URI"]  ||= 'sqlite3::memory:'
ENV["MYSQL_SPEC_URI"]    ||= 'mysql://localhost/dm-accepts_nested_attributes_test'
ENV["POSTGRES_SPEC_URI"] ||= 'postgres://postgres@localhost/dm-accepts_nested_attributes_test'
 
 
def setup_adapter(name, default_uri = nil)
  begin
    DataMapper.setup(name, ENV["#{ENV['ADAPTER'].to_s.upcase}_SPEC_URI"] || default_uri)
    Object.const_set('ADAPTER', ENV['ADAPTER'].to_sym) if name.to_s == ENV['ADAPTER']
    true
  rescue Exception => e
    if name.to_s == ENV['ADAPTER']
      Object.const_set('ADAPTER', nil)
      warn "Could not load do_#{name}: #{e}"
    end
    false
  end
end

ENV['ADAPTER'] ||= 'mysql'
setup_adapter(:default)

spec_dir = Pathname(__FILE__).dirname.to_s
Dir[ spec_dir + "/lib/**/*.rb"      ].each { |rb| require(rb) }
Dir[ spec_dir + "/fixtures/**/*.rb" ].each { |rb| require(rb) }
Dir[ spec_dir + "/shared/**/*.rb"   ].each { |rb| require(rb) }


module XToOneHelpers
  
  def clear_data
    Profile.all.destroy!
    Person.all.destroy!
  end
  
end

module OneToManyHelpers
  
  def clear_data
    Task.all.destroy!
    Project.all.destroy!
  end
  
end

module ManyToManyHelpers
  
  def clear_data
    ProjectMembership.all.destroy!
    Project.all.destroy!
    Person.all.destroy!
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snusnu-dm-accepts_nested_attributes-0.11.0 spec/spec_helper.rb