update gemfile_generator to current rails preamble and bundler syntax

This commit is contained in:
Michael Raidel 2010-05-05 00:30:30 +08:00 committed by Jeremy McAnally
parent 51fac11ae2
commit f44e5c7edf
2 changed files with 9 additions and 11 deletions

View File

@ -47,7 +47,7 @@ module Rails
data = {} data = {}
# Add new keys from old keys # Add new keys from old keys
data[:require_as] = options[:lib] if options[:lib] data[:require] = options[:lib] if options[:lib]
data[:source] = options[:source] if options[:source] data[:source] = options[:source] if options[:source]
version = options[:version] version = options[:version]
@ -60,10 +60,9 @@ module Rails
preamble = <<STR preamble = <<STR
# Edit this Gemfile to bundle your application's dependencies. # Edit this Gemfile to bundle your application's dependencies.
# This preamble is the current preamble for Rails 3 apps; edit as needed. # This preamble is the current preamble for Rails 3 apps; edit as needed.
path "/path/to/rails", :glob => "{*/,}*.gemspec" source 'http://rubygems.org'
git "git://github.com/rails/rack.git"
gem "rails", "3.0.pre" gem 'rails', '3.0.0.beta3'
STR STR
preamble + generate_upgraded_code preamble + generate_upgraded_code

View File

@ -22,10 +22,9 @@ class GemfileGeneratorTest < ActiveSupport::TestCase
PREAMBLE = <<STR PREAMBLE = <<STR
# Edit this Gemfile to bundle your application's dependencies. # Edit this Gemfile to bundle your application's dependencies.
# This preamble is the current preamble for Rails 3 apps; edit as needed. # This preamble is the current preamble for Rails 3 apps; edit as needed.
path "/path/to/rails", :glob => "{*/,}*.gemspec" source 'http://rubygems.org'
git "git://github.com/rails/rack.git"
gem "rails", "3.0.pre" gem 'rails', '3.0.0.beta3'
STR STR
@ -61,13 +60,13 @@ STR
generator = Rails::Upgrading::GemfileGenerator.new generator = Rails::Upgrading::GemfileGenerator.new
generator.environment_code = "config.gem 'camping', :lib => 'kamping'" generator.environment_code = "config.gem 'camping', :lib => 'kamping'"
assert_equal PREAMBLE + "gem 'camping', :require_as => 'kamping'", generator.generate_gemfile assert_equal PREAMBLE + "gem 'camping', :require => 'kamping'", generator.generate_gemfile
end end
def test_generates_with_all_options def test_generates_with_all_options
generator = Rails::Upgrading::GemfileGenerator.new generator = Rails::Upgrading::GemfileGenerator.new
generator.environment_code = "config.gem 'camping', :lib => 'kamping', :source => 'http://code.whytheluckystiff.net', :version => '2.1.1'" generator.environment_code = "config.gem 'camping', :lib => 'kamping', :source => 'http://code.whytheluckystiff.net', :version => '2.1.1'"
assert_equal PREAMBLE + "source 'http://code.whytheluckystiff.net'\ngem 'camping', '2.1.1', :require_as => 'kamping'", generator.generate_gemfile assert_equal PREAMBLE + "source 'http://code.whytheluckystiff.net'\ngem 'camping', '2.1.1', :require => 'kamping'", generator.generate_gemfile
end end
end end