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

fix broken gem method with non-String arguments. Closes #16709.

This was caused by #15327.
This commit is contained in:
Yves Senn 2014-08-27 12:30:35 +02:00
parent 20e7f08ecc
commit b9b521306c
3 changed files with 23 additions and 4 deletions

View file

@ -1,3 +1,10 @@
* Fix a bug in the `gem` method for Rails templates when non-String options
are used.
Fixes #16709.
*Yves Senn*
* The [web-console](https://github.com/rails/web-console) gem is now
installed by default for new applications. It can help you debug
development exceptions by spawnig an interactive console in its cause

View file

@ -268,11 +268,13 @@ module Rails
# Surround string with single quotes if there is no quotes.
# Otherwise fall back to double quotes
def quote(str)
if str.include?("'")
str.inspect
def quote(value)
return value.inspect unless value.is_a? String
if value.include?("'")
value.inspect
else
"'#{str}'"
"'#{value}'"
end
end
end

View file

@ -79,6 +79,16 @@ class ActionsTest < Rails::Generators::TestCase
assert_file 'Gemfile', /gem 'rspec', github: 'dchelimsky\/rspec', tag: '1\.2\.9\.rc1'/
end
def test_gem_with_non_string_options
run_generator
action :gem, 'rspec', require: false
action :gem, 'rspec-rails', group: [:development, :test]
assert_file 'Gemfile', /^gem 'rspec', require: false$/
assert_file 'Gemfile', /^gem 'rspec-rails', group: \[:development, :test\]$/
end
def test_gem_falls_back_to_inspect_if_string_contains_single_quote
run_generator