aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators
diff options
context:
space:
mode:
authorRizwan Reza <rizwanreza@gmail.com>2010-05-17 02:40:15 +0430
committerRizwan Reza <rizwanreza@gmail.com>2010-05-17 02:40:15 +0430
commitd148a6f6ba5f8ee65905f12cd2601fcc377d4852 (patch)
tree4bcb5e7ad47cfb9a9bb14ffe7c9e003d4646d64c /railties/test/generators
parente1c773006969abea3c0619fbdc7e32c121b6085f (diff)
parent6b4e0cc526f55b5532cf99292c94f0a4db53b16f (diff)
downloadrails-d148a6f6ba5f8ee65905f12cd2601fcc377d4852.tar.gz
rails-d148a6f6ba5f8ee65905f12cd2601fcc377d4852.tar.bz2
rails-d148a6f6ba5f8ee65905f12cd2601fcc377d4852.zip
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'railties/test/generators')
-rw-r--r--railties/test/generators/actions_test.rb14
-rw-r--r--railties/test/generators/app_generator_test.rb9
-rw-r--r--railties/test/generators/generated_attribute_test.rb40
3 files changed, 59 insertions, 4 deletions
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index e6fab93a87..65fbf61902 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -86,8 +86,13 @@ class ActionsTest < Rails::Generators::TestCase
action :gem, 'mislav-will-paginate', :lib => 'will-paginate', :source => 'http://gems.github.com'
end
- assert_file 'Gemfile', /gem "mislav\-will\-paginate", :require_as => "will\-paginate"/
+ assert_deprecated do
+ action :gem, 'thoughtbot-factory_girl', :require_as => 'factory_girl', :source => 'http://gems.github.com'
+ end
+
+ assert_file 'Gemfile', /gem "mislav\-will\-paginate", :require => "will\-paginate"/
assert_file 'Gemfile', /source "http:\/\/gems\.github\.com"/
+ assert_file 'Gemfile', /gem "thoughtbot-factory_girl", :require => "factory_girl"/
end
def test_gem_with_env_should_include_all_dependencies_in_gemfile
@@ -97,7 +102,12 @@ class ActionsTest < Rails::Generators::TestCase
action :gem, 'rspec', :env => %w(development test)
end
- assert_file 'Gemfile', /gem "rspec", :only => \["development", "test"\]/
+ assert_deprecated do
+ action :gem, 'rspec-rails', :only => %w(development test)
+ end
+
+ assert_file 'Gemfile', /gem "rspec", :group => \["development", "test"\]/
+ assert_file 'Gemfile', /gem "rspec-rails", :group => \["development", "test"\]/
end
def test_gem_with_version_should_include_version_in_gemfile
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 8743defe82..3975a39ab1 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -70,8 +70,13 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
def test_name_collision_raises_an_error
- content = capture(:stderr){ run_generator [File.join(destination_root, "generate")] }
- assert_equal "Invalid application name generate. Please give a name which does not match one of the reserved rails words.\n", content
+ reserved_words = %w[generate g console c server s dbconsole db
+ application destroy benchmarker profiler
+ plugin runner test]
+ reserved_words.each do |reserved|
+ content = capture(:stderr){ run_generator [File.join(destination_root, reserved)] }
+ assert_equal "Invalid application name #{reserved}. Please give a name which does not match one of the reserved rails words.\n", content
+ end
end
def test_invalid_database_option_raises_an_error
diff --git a/railties/test/generators/generated_attribute_test.rb b/railties/test/generators/generated_attribute_test.rb
new file mode 100644
index 0000000000..dacb06fb13
--- /dev/null
+++ b/railties/test/generators/generated_attribute_test.rb
@@ -0,0 +1,40 @@
+require 'generators/generators_test_helper'
+require 'rails/generators/generated_attribute'
+
+class GeneratedAttributeTest < Rails::Generators::TestCase
+ include GeneratorsTestHelper
+
+ def test_field_type_returns_text_field
+ %w(integer float decimal string).each do |name|
+ assert_field_type name, :text_field
+ end
+ end
+
+ def test_field_type_returns_datetime_select
+ %w(datetime timestamp).each do |name|
+ assert_field_type name, :datetime_select
+ end
+ end
+
+ def test_field_type_returns_time_select
+ assert_field_type 'time', :time_select
+ end
+
+ def test_field_type_returns_date_select
+ assert_field_type 'date', :date_select
+ end
+
+ def test_field_type_returns_text_area
+ assert_field_type 'text', :text_area
+ end
+
+ def test_field_type_returns_check_box
+ assert_field_type 'boolean', :check_box
+ end
+
+ def test_field_type_with_unknown_type_returns_text_field
+ %w(foo bar baz).each do |name|
+ assert_field_type name, :text_field
+ end
+ end
+end