aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-03-15 19:46:03 +0000
committerPratik Naik <pratiknaik@gmail.com>2010-03-15 19:46:03 +0000
commit03a62f4afedbef8bda72c8fdf9a0092273c0f2b0 (patch)
tree2155b65750757d26e3c8c8e0655ad32cc89d6c2e /railties/test
parentf53fddf3665e6582768f4ab0c82b286b39e7fb19 (diff)
parenta594a22267bfd3346e00923742c4aa7edad0cef7 (diff)
downloadrails-03a62f4afedbef8bda72c8fdf9a0092273c0f2b0.tar.gz
rails-03a62f4afedbef8bda72c8fdf9a0092273c0f2b0.tar.bz2
rails-03a62f4afedbef8bda72c8fdf9a0092273c0f2b0.zip
Merge remote branch 'mainstream/master'
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/generators/app_generator_test.rb12
-rw-r--r--railties/test/generators_test.rb18
2 files changed, 26 insertions, 4 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 412034029e..4fc26563ff 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -9,6 +9,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
def setup
super
Rails::Generators::AppGenerator.instance_variable_set('@desc', nil)
+ @bundle_command = File.basename(Thor::Util.ruby_command).sub(/ruby/, 'bundle')
end
def teardown
@@ -65,6 +66,13 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_equal "Invalid application name 43-things. Please give a name which does not start with numbers.\n", content
end
+ def test_application_name_raises_an_error_if_name_already_used_constant
+ %w{ String Hash Class Module Set Symbol }.each do |ruby_class|
+ content = capture(:stderr){ run_generator [File.join(destination_root, ruby_class)] }
+ assert_equal "Invalid application name #{ruby_class}, constant #{ruby_class} is already in use. Please choose another application name.\n", content
+ end
+ end
+
def test_invalid_application_name_is_fixed
run_generator [File.join(destination_root, "things-43")]
assert_file "things-43/config/environment.rb", /Things43::Application\.initialize!/
@@ -161,14 +169,14 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_dev_option
- generator([destination_root], :dev => true).expects(:run).with("bundle install")
+ generator([destination_root], :dev => true).expects(:run).with("#{@bundle_command} install")
silence(:stdout){ generator.invoke }
rails_path = File.expand_path('../../..', Rails.root)
assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:path\s+=>\s+["']#{Regexp.escape(rails_path)}["']$/
end
def test_edge_option
- generator([destination_root], :edge => true).expects(:run).with("bundle install")
+ generator([destination_root], :edge => true).expects(:run).with("#{@bundle_command} install")
silence(:stdout){ generator.invoke }
assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:git\s+=>\s+["']#{Regexp.escape("git://github.com/rails/rails.git")}["']$/
end
diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb
index dd17f8f756..2975e3e3ef 100644
--- a/railties/test/generators_test.rb
+++ b/railties/test/generators_test.rb
@@ -104,11 +104,25 @@ class GeneratorsTest < Rails::Generators::TestCase
def test_rails_generators_with_others_information
output = capture(:stdout){ Rails::Generators.help }
- assert_match /ActiveRecord:/, output
assert_match /Fixjour:/, output
+ assert_match /^ fixjour$/, output
+ end
+
+ def test_rails_generators_does_not_show_activerecord_info_if_its_the_default
+ output = capture(:stdout){ Rails::Generators.help }
+ assert_no_match /ActiveRecord:/, output
+ assert_no_match /^ active_record:model$/, output
+ assert_no_match /^ active_record:fixjour$/, output
+ end
+
+ def test_rails_generators_shows_activerecord_info_if_its_not_the_default
+ Rails::Generators.options[:rails][:orm] = :data_mapper
+ output = capture(:stdout){ Rails::Generators.help }
+ assert_match /ActiveRecord:/, output
assert_match /^ active_record:model$/, output
assert_match /^ active_record:fixjour$/, output
- assert_match /^ fixjour$/, output
+ ensure
+ Rails::Generators.options[:rails][:orm] = :active_record
end
def test_no_color_sets_proper_shell