module TmpRails class << self attr_accessor :root def root_dir path, options = {} @root = options == :custom ? custom_root_dir(path) : default_root_dir(path) end protected def default_root_dir path File.expand_path(File.join(File.dirname(path), '..', 'tmp')) end def custom_root_dir path File.expand_path(path) end end end module Rails def self.root @root ||= File.join(Rails.application.config.root_dir, 'rails') end end class TestApp < Rails::Application end Rails.application = TestApp