mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Updating newline fix to maintain existing linebreaks and indentation and test for b/eol on inserts
This commit is contained in:
parent
6f5fdf8179
commit
95e9b5fbfd
2 changed files with 10 additions and 7 deletions
|
@ -68,8 +68,9 @@ module Rails
|
|||
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 @@ module Rails
|
|||
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
|
||||
|
||||
|
|
|
@ -95,11 +95,13 @@ class ActionsTest < Rails::Generators::TestCase
|
|||
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 @@ class ActionsTest < Rails::Generators::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue