mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
36 lines
No EOL
966 B
Ruby
36 lines
No EOL
966 B
Ruby
require 'abstract_unit'
|
|
|
|
module Rails
|
|
def self.root
|
|
@root ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures'))
|
|
end
|
|
end
|
|
Rails.application.config.root = Rails.root
|
|
Rails.application.config.generators.templates = [File.join(Rails.root, "lib", "templates")]
|
|
|
|
require 'rails/generators'
|
|
require 'rails/generators/test_case'
|
|
|
|
require 'active_record'
|
|
require 'action_dispatch'
|
|
|
|
module GeneratorsTestHelper
|
|
def self.included(base)
|
|
base.class_eval do
|
|
destination File.join(Rails.root, "tmp")
|
|
setup :prepare_destination
|
|
|
|
begin
|
|
base.tests Rails::Generators.const_get(base.name.sub(/Test$/, ''))
|
|
rescue
|
|
end
|
|
end
|
|
end
|
|
|
|
def copy_routes
|
|
routes = File.expand_path("../../../lib/rails/generators/rails/app/templates/config/routes.rb", __FILE__)
|
|
destination = File.join(destination_root, "config")
|
|
FileUtils.mkdir_p(destination)
|
|
FileUtils.cp File.expand_path(routes), destination
|
|
end
|
|
end |