2009-10-16 15:49:39 -04:00
|
|
|
require 'abstract_unit'
|
2010-06-02 02:45:03 -04:00
|
|
|
require 'rails/generators'
|
|
|
|
require 'rails/generators/test_case'
|
2009-11-02 21:08:33 -05:00
|
|
|
|
|
|
|
module Rails
|
|
|
|
def self.root
|
|
|
|
@root ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures'))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
Rails.application.config.root = Rails.root
|
2010-02-06 11:32:06 -05:00
|
|
|
Rails.application.config.generators.templates = [File.join(Rails.root, "lib", "templates")]
|
2009-11-02 21:08:33 -05:00
|
|
|
|
2010-06-02 02:45:03 -04:00
|
|
|
# Call configure to load the settings from
|
|
|
|
# Rails.application.config.generators to Rails::Generators
|
2011-05-25 03:43:24 -04:00
|
|
|
Rails.application.load_generators
|
2010-01-29 11:41:10 -05:00
|
|
|
|
2009-09-14 15:54:43 -04:00
|
|
|
require 'active_record'
|
2009-08-10 12:29:20 -04:00
|
|
|
require 'action_dispatch'
|
2009-07-03 08:55:37 -04:00
|
|
|
|
2010-01-18 18:07:11 -05:00
|
|
|
module GeneratorsTestHelper
|
|
|
|
def self.included(base)
|
|
|
|
base.class_eval do
|
|
|
|
destination File.join(Rails.root, "tmp")
|
|
|
|
setup :prepare_destination
|
2009-06-25 04:44:46 -04:00
|
|
|
|
2010-01-18 18:07:11 -05:00
|
|
|
begin
|
|
|
|
base.tests Rails::Generators.const_get(base.name.sub(/Test$/, ''))
|
|
|
|
rescue
|
|
|
|
end
|
|
|
|
end
|
2010-01-03 18:31:53 -05:00
|
|
|
end
|
2010-03-19 13:11:37 -04:00
|
|
|
|
|
|
|
def copy_routes
|
2010-03-23 08:40:19 -04:00
|
|
|
routes = File.expand_path("../../../lib/rails/generators/rails/app/templates/config/routes.rb", __FILE__)
|
2010-03-19 13:11:37 -04:00
|
|
|
destination = File.join(destination_root, "config")
|
|
|
|
FileUtils.mkdir_p(destination)
|
2011-02-23 08:40:08 -05:00
|
|
|
FileUtils.cp routes, destination
|
2010-03-19 13:11:37 -04:00
|
|
|
end
|
2010-09-23 13:13:07 -04:00
|
|
|
end
|