aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/rails_generator_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/rails_generator_test.rb')
-rw-r--r--railties/test/rails_generator_test.rb25
1 files changed, 9 insertions, 16 deletions
diff --git a/railties/test/rails_generator_test.rb b/railties/test/rails_generator_test.rb
index 5934bb3e7b..8470bed943 100644
--- a/railties/test/rails_generator_test.rb
+++ b/railties/test/rails_generator_test.rb
@@ -1,29 +1,22 @@
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
+RAILS_ROOT = File.dirname(__FILE__)
+
require 'test/unit'
-# Optionally load RubyGems.
+require 'rails_generator'
+require 'rails_generator/simple_logger'
+Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new
+
begin
require 'rubygems'
+ require_gem 'actionpack'
rescue LoadError
end
-# Must set before requiring generator libs.
-RAILS_ROOT = File.dirname(__FILE__)
-
-# Preemptively load the rest of Rails so Gems don't hijack our requires.
-require File.dirname(__FILE__) + '/../../activerecord/lib/active_record'
-require File.dirname(__FILE__) + '/../../actionpack/lib/action_controller'
-require File.dirname(__FILE__) + '/../lib/rails_generator'
-
class RailsGeneratorTest < Test::Unit::TestCase
BUILTINS = %w(controller mailer model scaffold)
CAPITALIZED_BUILTINS = BUILTINS.map { |b| b.capitalize }
- def test_sources
- expected = [:app, :user, :RubyGems, :builtin]
- expected.delete(:gem) unless Object.const_defined?(:Gem)
- assert_equal expected, Rails::Generator::Base.sources.map { |s| s.label }
- end
-
def test_lookup_builtins
(BUILTINS + CAPITALIZED_BUILTINS).each do |name|
assert_nothing_raised do
@@ -78,7 +71,7 @@ class RailsGeneratorTest < Test::Unit::TestCase
assert_equal 'admin/foo', g.name
assert_equal %w(admin), g.class_path
assert_equal 'Admin', g.class_nesting
- assert_equal 'Admin::Foo', g.class_name
+ assert_equal 'Foo', g.class_name
assert_equal 'foo', g.singular_name
assert_equal 'foos', g.plural_name
assert_equal g.singular_name, g.file_name