Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes unescaped version passthrough of generator 'gem' command. [#3901

…status:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit 9c654744fbc5f3035e07f741997d37f287729103 1 parent cafe882
@mbleigh mbleigh authored josevalim committed
View
2  railties/lib/rails/generators/actions.rb
@@ -69,7 +69,7 @@ def gem(*args)
# otherwise use name (version).
parts, message = [ name.inspect ], name
if version ||= options.delete(:version)
- parts << version
+ parts << version.inspect
message << " (#{version})"
end
message = options[:git] if options[:git]
View
18 railties/test/generators/actions_test.rb
@@ -103,6 +103,24 @@ def test_gem_with_env_should_include_all_dependencies_in_gemfile
assert_file 'Gemfile', /gem "rspec", :only => \["development", "test"\]/
end
+ def test_gem_with_version_should_include_version_in_gemfile
+ run_generator
+
+ action :gem, 'rspec', '>=2.0.0.a5'
+
+ assert_file 'Gemfile', /gem "rspec", ">=2.0.0.a5"/
+ end
+
+ def test_gem_should_insert_on_separate_lines
+ run_generator
+
+ action :gem, 'rspec'
+ action :gem, 'rspec-rails'
+
+ assert_file 'Gemfile', /gem "rspec"$/
+ assert_file 'Gemfile', /gem "rspec-rails"$/
+ end
+
def test_environment_should_include_data_in_environment_initializer_block
run_generator
load_paths = 'config.load_paths += %w["#{Rails.root}/app/extras"]'
Please sign in to comment.
Something went wrong with that request. Please try again.