aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bleigh <michael@intridea.com>2010-02-08 14:58:32 -0500
committerJosé Valim <jose.valim@gmail.com>2010-02-10 08:28:03 +0100
commit9c654744fbc5f3035e07f741997d37f287729103 (patch)
tree95c86a7b8c895503612165c4ccce23dbc2b41aab
parentcafe882d12d767f510d6b8ad283f49a1c02e82ad (diff)
downloadrails-9c654744fbc5f3035e07f741997d37f287729103.tar.gz
rails-9c654744fbc5f3035e07f741997d37f287729103.tar.bz2
rails-9c654744fbc5f3035e07f741997d37f287729103.zip
Fixes unescaped version passthrough of generator 'gem' command. [#3901 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r--railties/lib/rails/generators/actions.rb2
-rw-r--r--railties/test/generators/actions_test.rb18
2 files changed, 19 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb
index 152fe6e33e..d41da773c6 100644
--- a/railties/lib/rails/generators/actions.rb
+++ b/railties/lib/rails/generators/actions.rb
@@ -69,7 +69,7 @@ module Rails
# 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]
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index 0512f69f4a..5929db6318 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -103,6 +103,24 @@ class ActionsTest < Rails::Generators::TestCase
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"]'