ENV["RAILS_ENV"] = "test"
ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'

require File.expand_path(File.join(ENV['RAILS_ROOT'],'config','environment'))
require 'test_help'

class ActiveSupport::TestCase
  self.fixture_path = File.join(File.dirname(__FILE__),'fixtures')
  self.use_transactional_fixtures = true
  self.use_instantiated_fixtures  = false
  fixtures :all
  set_fixture_class :rfm_files => 'RFM::FileSystem::Base'
end

ActiveRecord::Migration.verbose = false

def load_schema
  config = YAML::load(IO.read(File.dirname(__FILE__) + '/db/database.yml'))
  ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")

  db_adapter = ENV['DB'] || 'sqlite3mem'

  ActiveRecord::Base.establish_connection(config[db_adapter])
  load(File.dirname(__FILE__) + "/db/schema.rb")
  require File.dirname(__FILE__) + '/../init.rb'
end
