1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/generators/generators_test_helper.rb

49 lines
1.3 KiB
Ruby
Raw Normal View History

require 'abstract_unit'
2013-12-15 15:04:54 -05:00
require 'active_support/core_ext/module/remove_method'
require 'active_support/testing/stream'
require 'rails/generators'
require 'rails/generators/test_case'
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
end
end
Rails.application.config.root = Rails.root
Rails.application.config.generators.templates = [File.join(Rails.root, "lib", "templates")]
# 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
2009-09-14 15:54:43 -04:00
require 'active_record'
require 'action_dispatch'
2013-07-30 05:28:31 -04:00
require 'action_view'
module GeneratorsTestHelper
include ActiveSupport::Testing::Stream
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
begin
base.tests Rails::Generators.const_get(base.name.sub(/Test$/, ''))
rescue
end
end
2010-01-03 18:31:53 -05:00
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 routes, destination
end
end