diff options
author | Nikita Penzin <npenzin@icloud.com> | 2017-07-30 18:24:20 +0300 |
---|---|---|
committer | Lisa Ugray <lisa.ugray@shopify.com> | 2017-11-14 08:09:12 -0500 |
commit | 5345b61f29568c80bee6f8d0000a61e35d93429a (patch) | |
tree | 0b10ca0ccbdc4493fb1ac68019265e6c09eb07b1 | |
parent | 090eaa7e1b42143ffdb42409aa5d429cbeb3e55d (diff) | |
download | rails-5345b61f29568c80bee6f8d0000a61e35d93429a.tar.gz rails-5345b61f29568c80bee6f8d0000a61e35d93429a.tar.bz2 rails-5345b61f29568c80bee6f8d0000a61e35d93429a.zip |
Ensure plugin_generator adds to new line in Gemfile
Ensure plugin_generator adds to new line in Gemfile, even if the Gemfile
does not end with an empty line.
[Lisa Ugray, Nikita Penzin]
-rw-r--r-- | railties/lib/rails/generators/rails/plugin/plugin_generator.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/plugin_generator_test.rb | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index a1209e4624..e946452bd6 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -167,7 +167,7 @@ task default: :test gemfile_in_app_path = File.join(rails_app_path, "Gemfile") if File.exist? gemfile_in_app_path - entry = "gem '#{name}', path: '#{relative_path}'" + entry = "\ngem '#{name}', path: '#{relative_path}'" append_file gemfile_in_app_path, entry end end diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index e8372dea47..c7c82de12b 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -530,10 +530,11 @@ class PluginGeneratorTest < Rails::Generators::TestCase gemfile_path = "#{Rails.root}/Gemfile" Object.const_set("APP_PATH", Rails.root) FileUtils.touch gemfile_path + File.write(gemfile_path, "#foo") run_generator - assert_file gemfile_path, /gem 'bukkits', path: 'tmp\/bukkits'/ + assert_file gemfile_path, /^gem 'bukkits', path: 'tmp\/bukkits'/ ensure Object.send(:remove_const, "APP_PATH") FileUtils.rm gemfile_path |