diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 3 | ||||
-rw-r--r-- | railties/test/generators/actions_test.rb | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index abcbe7068d..a239874df0 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -258,13 +258,12 @@ module Rails # Surround string with single quotes if there is no quotes. # Otherwise fall back to double quotes def quote(str) - if str.class == String && str.scan("'").size > 0 + if str.include?("'") str.inspect else "'#{str}'" end end - end end end diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index d7be17ed36..6d6de0fb52 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -78,6 +78,14 @@ class ActionsTest < Rails::Generators::TestCase assert_file 'Gemfile', /gem 'rspec', github: 'dchelimsky\/rspec', tag: '1\.2\.9\.rc1'/ end + def test_gem_falls_back_to_inspect_if_string_contains_single_quote + run_generator + + action :gem, 'rspec', ">=2.0'0" + + assert_file 'Gemfile', /^gem 'rspec', ">=2\.0'0"$/ + end + def test_gem_group_should_wrap_gems_in_a_group run_generator |