$root_dir = Dir.pwd unless defined?(Rtml) && defined?(Rails) $rtml_external = true # Now, for some reason, Rails (ActiveSupport?) is removing a lot of existing directories from # the load path. Probably for optimization, but kind of counterproductive for this edge case. # So I'm going to back them up, and then re-add them. load_path_backup = $LOAD_PATH.collect { |lp| File.expand_path(lp) } require File.join(File.dirname(__FILE__), '../rtml/dependencies') unless defined?(RAILS_ROOT) RAILS_ROOT = Dir.pwd.gsub(/\/test(\/|)$/, '') end module Rails module VERSION MAJOR = 2 MINOR = 3 TINY = 5 STRING = [MAJOR, MINOR, TINY].join('.') end class Configuration attr_accessor :controller_paths, :view_path def initialize @controller_paths = [File.join(RAILS_ROOT, 'controllers'), File.join(File.dirname(__FILE__), '../../builtin/controllers')] @view_path = File.join(RAILS_ROOT, 'views') end end class << self attr_writer :logger, :backtrace_cleaner, :configuration def logger @logger ||= Logger.new(File.join(RAILS_ROOT, "tmp/rtml.log")) end unless defined?(Rails.logger) def backtrace_cleaner @backtrace_cleaner ||= ActiveSupport::BacktraceCleaner.new end def configuration @configuration ||= Configuration.new end def root RAILS_ROOT end end end class ApplicationController < ActionController::Base end unless defined?(ApplicationController) # Restore the missing load paths. load_path_backup.reverse.each do |path| $LOAD_PATH.unshift path unless $LOAD_PATH.include?(path) end ActiveRecord::Base.logger = Rails.logger ActiveRecord::Base.establish_connection(:database => File.join(RAILS_ROOT, "tmp/rtml_test_db.sqlite3"), :adapter => 'sqlite3', :timeout => 5000, :pool => 5) ActionController::Base.session = { :key => '_myapp_session', :secret => '1'*60 } # Now that we're emulating the bare bones of Rails (at least as far as RTML is concerned), let's # get to RTML itself. require File.join(File.dirname(__FILE__), '../rtml') require File.join(File.dirname(__FILE__), '../rtml/environment') if defined?(Rake::Task) task :environment load File.join(File.dirname(__FILE__), '../../tasks/rtml.rake') load File.join(File.dirname(__FILE__), '../../tasks/db.rake') load 'tasks/routes.rake' end end