1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #22684 from teknofire/fix-using-add_resource-with-a-block-after-gem-call

Fix using add_resource with a block after gem in custom generators
This commit is contained in:
Yves Senn 2015-12-21 16:46:42 +01:00
commit a88ab73f7e
3 changed files with 14 additions and 1 deletions

View file

@ -1,3 +1,7 @@
* Fix using `add_source` with a block after using `gem` in a custom generator.
*Will Fisher*
## Rails 5.0.0.beta1 (December 18, 2015) ##
* No changes.

View file

@ -75,7 +75,7 @@ module Rails
in_root do
if block
append_file "Gemfile", "source #{quote(source)} do", force: true
append_file "Gemfile", "\nsource #{quote(source)} do", force: true
@in_group = true
instance_eval(&block)
@in_group = false

View file

@ -52,6 +52,15 @@ class ActionsTest < Rails::Generators::TestCase
assert_file 'Gemfile', /source 'http:\/\/gems\.github\.com' do\n gem 'rspec-rails'\nend/
end
def test_add_source_with_block_adds_source_to_gemfile_after_gem
run_generator
action :gem, 'will-paginate'
action :add_source, 'http://gems.github.com' do
gem 'rspec-rails'
end
assert_file 'Gemfile', /gem 'will-paginate'\nsource 'http:\/\/gems\.github\.com' do\n gem 'rspec-rails'\nend/
end
def test_gem_should_put_gem_dependency_in_gemfile
run_generator
action :gem, 'will-paginate'