Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating newline fix to maintain existing linebreaks and indentation …

…and test for b/eol on inserts
  • Loading branch information...
commit 95e9b5fbfd87b81bf2d2b16a6df6d9ddbfdb686d 1 parent 6f5fdf8
@johnmdonahue johnmdonahue authored
View
7 railties/lib/rails/generators/actions.rb
@@ -68,8 +68,9 @@ def gem(*args)
end
in_root do
- str = "\ngem #{parts.join(", ")}\n"
+ str = "gem #{parts.join(", ")}"
str = " " + str if @in_group
+ str = "\n" + str
append_file "Gemfile", str, :verbose => false
end
end
@@ -87,13 +88,13 @@ def gem_group(*names, &block)
log :gemfile, "group #{name}"
in_root do
- append_file "Gemfile", "\ngroup #{name} do\n", :force => true
+ append_file "Gemfile", "\ngroup #{name} do", :force => true
@in_group = true
instance_eval(&block)
@in_group = false
- append_file "Gemfile", "end\n", :force => true
+ append_file "Gemfile", "\nend\n", :force => true
end
end
View
10 railties/test/generators/actions_test.rb
@@ -95,11 +95,13 @@ def test_gem_with_version_should_include_version_in_gemfile
def test_gem_should_insert_on_separate_lines
run_generator
+ File.open('Gemfile', 'a') {|f| f.write('# Some content...') }
+
action :gem, 'rspec'
action :gem, 'rspec-rails'
- assert_file 'Gemfile', /gem "rspec"$/
- assert_file 'Gemfile', /gem "rspec-rails"$/
+ assert_file 'Gemfile', /^gem "rspec"$/
+ assert_file 'Gemfile', /^gem "rspec-rails"$/
end
def test_gem_group_should_wrap_gems_in_a_group
@@ -112,8 +114,8 @@ def test_gem_group_should_wrap_gems_in_a_group
action :gem_group, :test do
gem 'fakeweb'
end
-
- assert_file 'Gemfile', /\ngroup :development, :test do\n \ngem "rspec-rails"\nend\n\ngroup :test do\n \ngem "fakeweb"\nend/
+
+ assert_file 'Gemfile', /\ngroup :development, :test do\n gem "rspec-rails"\nend\n\ngroup :test do\n gem "fakeweb"\nend/
end
def test_environment_should_include_data_in_environment_initializer_block
Please sign in to comment.
Something went wrong with that request. Please try again.