require "test/unit" require File.join(File.dirname(__FILE__), "..", "..", "test_helpers") require 'rubygems' require 'genosaurus' module Mack module Configuration def self.method_missing(sym, *args) ev = "_mack_#{sym}".downcase return ENV[ev] end def self.set(name, value) ENV["_mack_#{name.to_s.downcase}"] = value end end end $genosaurus_output_directory = File.join(File.dirname(__FILE__), "..", "tmp") ENV["_mack_config_directory"] = File.dirname(__FILE__) ENV["_mack_root"] = $genosaurus_output_directory ENV["_mack_app_directory"] = File.join($genosaurus_output_directory, "app") ENV["_mack_env"] = "test" ENV["_mack_views_directory"] = File.join(ENV["_mack_app_directory"], "views") require File.join(File.dirname(__FILE__), "..", "..", "mack-orm_common", "lib", "mack-orm_common") require File.join(File.dirname(__FILE__), "..", "lib", "mack-data_mapper") load File.join(File.dirname(__FILE__), "lib", "user.rb") class Test::Unit::TestCase # place common methods, assertions, and other type things in this file so # other tests will have access to them. def cleanup database.adapter.flush_connections! FileUtils.rm_rf($genosaurus_output_directory) FileUtils.rm_rf(File.join(Mack::Configuration.config_directory, "routes.rb")) end def teardown cleanup end def setup database.adapter.flush_connections! [$genosaurus_output_directory, migrations_directory, models_directory].each do |d| FileUtils.mkdir_p(d) end FileUtils.cp(fixture_path("routes.rb"), File.join(Mack::Configuration.config_directory, "routes.rb")) end def migrations_directory File.join($genosaurus_output_directory, "db", "migrations") end def models_directory File.join($genosaurus_output_directory, "app", "models") end def test_directory File.join($genosaurus_output_directory, "test") end def fixture_path(*name) path = [File.dirname(__FILE__), "fixtures"] path << name path.flatten! File.join(path) + ".fixture" end def fixture(*name) File.open(fixture_path(name)).read end end