2009-10-16 15:49:39 -04:00
|
|
|
require 'abstract_unit'
|
2013-12-15 15:04:54 -05:00
|
|
|
require 'active_support/core_ext/module/remove_method'
|
2015-01-15 01:42:33 -05:00
|
|
|
require 'active_support/testing/stream'
|
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
|
2013-12-15 15:04:54 -05:00
|
|
|
class << self
|
|
|
|
remove_possible_method :root
|
|
|
|
def root
|
2014-08-26 06:08:54 -04:00
|
|
|
@root ||= Pathname.new(File.expand_path('../../fixtures', __FILE__))
|
2013-12-15 15:04:54 -05:00
|
|
|
end
|
2009-11-02 21:08:33 -05:00
|
|
|
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'
|
2013-07-30 05:28:31 -04:00
|
|
|
require 'action_view'
|
2009-07-03 08:55:37 -04:00
|
|
|
|
2010-01-18 18:07:11 -05:00
|
|
|
module GeneratorsTestHelper
|
2015-01-15 01:42:33 -05:00
|
|
|
include ActiveSupport::Testing::Stream
|
|
|
|
|
2010-01-18 18:07:11 -05:00
|
|
|
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
|
2014-07-15 16:56:27 -04:00
|
|
|
|
2010-09-23 13:13:07 -04:00
|
|
|
end
|