diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-11-17 01:39:19 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-11-17 01:39:19 +0000 |
commit | bff217272dbdb17f366f9986496ef04e2599d2c2 (patch) | |
tree | df1876d425e24db884e2710228a89abe00f20000 | |
parent | 4249ffe2498e9a77242205f95245ba1fcca92732 (diff) | |
download | rails-bff217272dbdb17f366f9986496ef04e2599d2c2.tar.gz rails-bff217272dbdb17f366f9986496ef04e2599d2c2.tar.bz2 rails-bff217272dbdb17f366f9986496ef04e2599d2c2.zip |
RAILS_GEM_VERSION may be set to any valid gem version specifier. Closes #10057.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8160 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/environments/boot.rb | 4 | ||||
-rw-r--r-- | railties/test/boot_test.rb | 16 |
3 files changed, 18 insertions, 4 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 86bad736ac..5b3bb07022 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* RAILS_GEM_VERSION may be set to any valid gem version specifier. #10057 [Chad Woolley, Chu Yeow] + * Load config/preinitializer.rb, if present, before loading the environment. #9943 [Chad Woolley] * FastCGI handler ignores unsupported signals like USR2 on Windows. [Grzegorz Derebecki] diff --git a/railties/environments/boot.rb b/railties/environments/boot.rb index 518a8883c1..b71c198db3 100644 --- a/railties/environments/boot.rb +++ b/railties/environments/boot.rb @@ -55,7 +55,7 @@ module Rails def load_rails_gem if version = self.class.gem_version - gem 'rails', "=#{version}" + gem 'rails', version else gem 'rails' end @@ -93,7 +93,7 @@ module Rails end def parse_gem_version(text) - $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*'([\d.]+)'/ + $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*'([!~<>=]*\s*[\d.]+)'/ end private diff --git a/railties/test/boot_test.rb b/railties/test/boot_test.rb index 930a0d552a..375ce52e31 100644 --- a/railties/test/boot_test.rb +++ b/railties/test/boot_test.rb @@ -96,7 +96,7 @@ class GemBootTest < Test::Unit::TestCase GemBoot.stubs(:gem_version).returns('0.0.1') boot = GemBoot.new - boot.expects(:gem).with('rails', '=0.0.1') + boot.expects(:gem).with('rails', '0.0.1') boot.load_rails_gem end @@ -112,7 +112,7 @@ class GemBootTest < Test::Unit::TestCase GemBoot.stubs(:gem_version).returns('0.0.1') boot = GemBoot.new - boot.expects(:gem).with('rails', '=0.0.1').raises(Gem::LoadError, 'missing rails 0.0.1 gem') + boot.expects(:gem).with('rails', '0.0.1').raises(Gem::LoadError, 'missing rails 0.0.1 gem') STDERR.expects(:puts) boot.expects(:exit).with(1) boot.load_rails_gem @@ -155,6 +155,18 @@ class ParseGemVersionTest < Test::Unit::TestCase assert_equal "1.2.3", parse("RAILS_GEM_VERSION = '1.2.3'\n# RAILS_GEM_VERSION = '9.8.7'") end + def test_should_allow_advanced_rubygems_version_specifications + # See http://rubygems.org/read/chapter/16 + assert_equal "=1.2.3", parse("RAILS_GEM_VERSION = '=1.2.3'") # equal sign + assert_equal "= 1.2.3", parse("RAILS_GEM_VERSION = '= 1.2.3'") # with space + assert_equal "!=1.2.3", parse("RAILS_GEM_VERSION = '!=1.2.3'") # not equal + assert_equal ">1.2.3", parse("RAILS_GEM_VERSION = '>1.2.3'") # greater than + assert_equal "<1.2.3", parse("RAILS_GEM_VERSION = '<1.2.3'") # less than + assert_equal ">=1.2.3", parse("RAILS_GEM_VERSION = '>=1.2.3'") # greater than or equal + assert_equal "<=1.2.3", parse("RAILS_GEM_VERSION = '<=1.2.3'") # less than or equal + assert_equal "~>1.2.3.0", parse("RAILS_GEM_VERSION = '~>1.2.3.0'") # approximately greater than + end + private def parse(text) Rails::GemBoot.parse_gem_version(text) |