Sha256: c59c6db2e49d6bea74d06ee00ca721d700e3d6cb49e5651f792125bd89ec2d24

Contents?: true

Size: 1.48 KB

Versions: 21

Compression:

Stored size: 1.48 KB

Contents

$LOAD_PATH << "." unless $LOAD_PATH.include?(".")

begin
  require "rubygems"
  require "bundler"

  if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.5")
    raise RuntimeError, "Your bundler version is too old." +
     "Run `gem install bundler` to upgrade."
  end

  # Set up load paths for all bundled gems
  Bundler.setup
rescue Bundler::GemNotFound
  raise RuntimeError, "Bundler couldn't find some gems." +
    "Did you run `bundle install`?"
end

Bundler.require
require File.expand_path('../../lib/custom-attributes', __FILE__)

unless [].respond_to?(:freq)
  class Array
    def freq
      k=Hash.new(0)
      each {|e| k[e]+=1}
      k
    end
  end
end

ENV['DB'] ||= 'sqlite3'

database_yml = File.expand_path('../database.yml', __FILE__)
if File.exists?(database_yml)
  active_record_configuration = YAML.load_file(database_yml)[ENV['DB']]
  
  ActiveRecord::Base.establish_connection(active_record_configuration)
  ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
  
  ActiveRecord::Base.silence do
    ActiveRecord::Migration.verbose = false
    
    load(File.dirname(__FILE__) + '/schema.rb')
    load(File.dirname(__FILE__) + '/models.rb')
  end  
  
else
  raise "Please create #{database_yml} first to configure your database. Take a look at: #{database_yml}.sample"
end

def clean_database!
  models = [Person]
  models.each do |model|
    ActiveRecord::Base.connection.execute "DELETE FROM #{model.table_name}"
  end
end

clean_database!

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
custom-attributes-0.2.27 spec/spec_helper.rb
custom-attributes-0.2.26 spec/spec_helper.rb
custom-attributes-0.2.25 spec/spec_helper.rb
custom-attributes-0.2.24 spec/spec_helper.rb
custom-attributes-0.2.23 spec/spec_helper.rb
custom-attributes-0.2.22 spec/spec_helper.rb
custom-attributes-0.2.18 spec/spec_helper.rb
custom-attributes-0.2.17 spec/spec_helper.rb
custom-attributes-0.2.16 spec/spec_helper.rb
custom-attributes-0.2.15 spec/spec_helper.rb
custom-attributes-0.2.12 spec/spec_helper.rb
custom-attributes-0.2.5 spec/spec_helper.rb
custom-attributes-0.2.4 spec/spec_helper.rb
custom-attributes-0.2.3 spec/spec_helper.rb
custom-attributes-0.2.2 spec/spec_helper.rb
custom-attributes-0.2.1 spec/spec_helper.rb
custom-attributes-0.2.0 spec/spec_helper.rb
custom-attributes-0.1.2 spec/spec_helper.rb
custom-attributes-0.1.1 spec/spec_helper.rb
custom-attributes-0.1.0 spec/spec_helper.rb