diff options
Diffstat (limited to 'railties/test/generators/plugin_new_generator_test.rb')
-rw-r--r-- | railties/test/generators/plugin_new_generator_test.rb | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index 826eac904e..4bb5f04a79 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -1,4 +1,3 @@ -require 'abstract_unit' require 'generators/generators_test_helper' require 'rails/generators/rails/plugin_new/plugin_new_generator' require 'generators/shared_generator_tests.rb' @@ -28,13 +27,14 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase include SharedGeneratorTests def test_invalid_plugin_name_raises_an_error - content = capture(:stderr){ run_generator [File.join(destination_root, "43-things")] } - assert_equal "Invalid plugin name 43-things. Please give a name which does not start with numbers.\n", content - end + content = capture(:stderr){ run_generator [File.join(destination_root, "things-43")] } + assert_equal "Invalid plugin name things-43. Please give a name which use only alphabetic or numeric or \"_\" characters.\n", content - def test_invalid_plugin_name_is_fixed - run_generator [File.join(destination_root, "things-43")] - assert_file "things-43/lib/things-43.rb", /module Things43/ + content = capture(:stderr){ run_generator [File.join(destination_root, "things4.3")] } + assert_equal "Invalid plugin name things4.3. Please give a name which use only alphabetic or numeric or \"_\" characters.\n", content + + content = capture(:stderr){ run_generator [File.join(destination_root, "43things")] } + assert_equal "Invalid plugin name 43things. Please give a name which does not start with numbers.\n", content end def test_camelcase_plugin_name_underscores_filenames @@ -242,7 +242,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase assert_file "spec/dummy/config/application.rb" assert_no_file "test" end - + def test_ensure_that_gitignore_can_be_generated_from_a_template_for_dummy_path FileUtils.cd(Rails.root) run_generator([destination_root, "--dummy_path", "spec/dummy" "--skip-test-unit"]) @@ -264,6 +264,37 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase assert_no_file "bukkits.gemspec" end + def test_creating_plugin_in_app_directory_adds_gemfile_entry + # simulate application existance + gemfile_path = "#{Rails.root}/Gemfile" + Object.const_set('APP_PATH', Rails.root) + FileUtils.touch gemfile_path + + run_generator [destination_root] + + assert_file gemfile_path, /gem 'bukkits', :path => 'tmp\/bukkits'/ + ensure + Object.send(:remove_const, 'APP_PATH') + FileUtils.rm gemfile_path + end + + def test_skipping_gemfile_entry + # simulate application existance + gemfile_path = "#{Rails.root}/Gemfile" + Object.const_set('APP_PATH', Rails.root) + FileUtils.touch gemfile_path + + run_generator [destination_root, "--skip-gemfile-entry"] + + assert_file gemfile_path do |contents| + assert_no_match(/gem 'bukkits', :path => 'tmp\/bukkits'/, contents) + end + ensure + Object.send(:remove_const, 'APP_PATH') + FileUtils.rm gemfile_path + end + + protected def action(*args, &block) |