Permalink
Browse files

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

This was caused by #15327.
  • Loading branch information...
1 parent 20e7f08 commit b9b521306c47d65bdbe18ec31a7b784adbfd1849 @senny senny committed Aug 27, 2014
Showing with 23 additions and 4 deletions.
  1. +7 −0 railties/CHANGELOG.md
  2. +6 −4 railties/lib/rails/generators/actions.rb
  3. +10 −0 railties/test/generators/actions_test.rb
View
@@ -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
@@ -268,11 +268,13 @@ def extify(name)
# 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
@@ -79,6 +79,16 @@ def test_gem_should_include_options
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

0 comments on commit b9b5213

Please sign in to comment.