aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 01:45:35 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-15 01:45:35 +0000
commitb1999be5a7efd67e2602c37ed898aa8433661863 (patch)
tree03bc833276075d802d0ce0ad261baed3d7232533 /railties/test
parent88a3343ed57c01ca358da8473d15fc4d2b4a5bff (diff)
downloadrails-b1999be5a7efd67e2602c37ed898aa8433661863.tar.gz
rails-b1999be5a7efd67e2602c37ed898aa8433661863.tar.bz2
rails-b1999be5a7efd67e2602c37ed898aa8433661863.zip
A hopefully more successful attempt at the Routing branch merge
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@617 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/rails_generator_test.rb25
1 files changed, 16 insertions, 9 deletions
diff --git a/railties/test/rails_generator_test.rb b/railties/test/rails_generator_test.rb
index 8470bed943..5934bb3e7b 100644
--- a/railties/test/rails_generator_test.rb
+++ b/railties/test/rails_generator_test.rb
@@ -1,22 +1,29 @@
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
-RAILS_ROOT = File.dirname(__FILE__)
-
require 'test/unit'
-require 'rails_generator'
-require 'rails_generator/simple_logger'
-Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new
-
+# Optionally load RubyGems.
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
@@ -71,7 +78,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 'Foo', g.class_name
+ assert_equal 'Admin::Foo', g.class_name
assert_equal 'foo', g.singular_name
assert_equal 'foos', g.plural_name
assert_equal g.singular_name, g.file_name