aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-01-07 18:53:49 +0100
committerPiotr Sarnacki <drogus@gmail.com>2012-01-07 19:14:27 +0100
commit8ac53db5eedca8f2605ef7f91bbc956018ae1c50 (patch)
treee462acb200616e0a24c56d6f6427ca93013d90ce /railties/test
parent089bc761f89cf8dab71c448344fe4a8c5edb296f (diff)
downloadrails-8ac53db5eedca8f2605ef7f91bbc956018ae1c50.tar.gz
rails-8ac53db5eedca8f2605ef7f91bbc956018ae1c50.tar.bz2
rails-8ac53db5eedca8f2605ef7f91bbc956018ae1c50.zip
Add Gemfile entry when creating a plugin in application's directory
After vendor/plugins were removed from rails, the new method to create plugins is to create gem plugins. Most of the time if you create a new plugin in rails application's directory, you want to extract something from that application and use it immediately, ie. add such line to Gemfile: gem 'foo', :path => './vendor/foo' This commit makes plugin new generator to add such line automatically.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/generators/plugin_new_generator_test.rb33
1 files changed, 32 insertions, 1 deletions
diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb
index b62bd4b131..6e70517219 100644
--- a/railties/test/generators/plugin_new_generator_test.rb
+++ b/railties/test/generators/plugin_new_generator_test.rb
@@ -241,7 +241,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"])
@@ -263,6 +263,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)