Sha256: f7525013eb6ed721a46d06c3032edda80d755c800bb9074ea3213c7317bfe888

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

$:.unshift(File.dirname(__FILE__) + '/../lib')
require "bundler/setup"
require "test/unit"
require "active_record"
require "assertions"
require "database_cleaner"
require "acts_as_archival"

def prepare_for_tests
  setup_logging if ENV["LOGGING_ENABLED"]
  setup_active_record
  setup_database_cleaner
  create_test_tables
  require_test_classes
end

def setup_logging
  require "logger"
  logfile = File.dirname(__FILE__) + "/debug.log"
  ActiveRecord::Base.logger = Logger.new(logfile)
end

def setup_active_record
  dbconfig_file = File.dirname(__FILE__) + "/database.yml"
  dbconfig = YAML.load File.read(dbconfig_file)
  ActiveRecord::Base.establish_connection(dbconfig)
end

def setup_database_cleaner
  DatabaseCleaner.strategy = :truncation
  ActiveSupport::TestCase.send(:setup) do
    DatabaseCleaner.clean
  end
end

def create_test_tables
  schema_file   = File.dirname(__FILE__) + "/schema.rb"
  load(schema_file) if File.exist?(schema_file)
end

def require_test_classes
  ActiveSupport::Inflector.inflections do |inflect|
    inflect.irregular "poly", "polys"
  end

  [:archival,
   :archival_kid,
   :archival_grandkid,
   :archival_table_name,
   :exploder,
   :independent_archival,
   :mass_attribute_protected,
   :missing_archived_at,
   :missing_archive_number,
   :plain,
   :poly,
   :readonly_when_archived
  ].each {|test_class_file| require_relative "fixtures/#{test_class_file}"}
end

prepare_for_tests

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts_as_archival-0.5.1 test/test_helper.rb