Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8160

Show
Ignore:
Timestamp:
11/17/07 01:39:19 (11 months ago)
Author:
bitsweat
Message:

RAILS_GEM_VERSION may be set to any valid gem version specifier. Closes #10057.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/CHANGELOG

    r8159 r8160  
    11*SVN* 
     2 
     3* RAILS_GEM_VERSION may be set to any valid gem version specifier.  #10057 [Chad Woolley, Chu Yeow] 
    24 
    35* Load config/preinitializer.rb, if present, before loading the environment.  #9943 [Chad Woolley] 
  • trunk/railties/environments/boot.rb

    r8159 r8160  
    5656    def load_rails_gem 
    5757      if version = self.class.gem_version 
    58         gem 'rails', "=#{version}" 
     58        gem 'rails', version 
    5959      else 
    6060        gem 'rails' 
     
    9494 
    9595      def parse_gem_version(text) 
    96         $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*'([\d.]+)'/ 
     96        $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*'([!~<>=]*\s*[\d.]+)'/ 
    9797      end 
    9898 
  • trunk/railties/test/boot_test.rb

    r8159 r8160  
    9797 
    9898    boot = GemBoot.new 
    99     boot.expects(:gem).with('rails', '=0.0.1') 
     99    boot.expects(:gem).with('rails', '0.0.1') 
    100100    boot.load_rails_gem 
    101101  end 
     
    113113 
    114114    boot = GemBoot.new 
    115     boot.expects(:gem).with('rails', '=0.0.1').raises(Gem::LoadError, 'missing rails 0.0.1 gem') 
     115    boot.expects(:gem).with('rails', '0.0.1').raises(Gem::LoadError, 'missing rails 0.0.1 gem') 
    116116    STDERR.expects(:puts) 
    117117    boot.expects(:exit).with(1) 
     
    156156  end 
    157157 
     158  def test_should_allow_advanced_rubygems_version_specifications 
     159    # See http://rubygems.org/read/chapter/16 
     160    assert_equal "=1.2.3", parse("RAILS_GEM_VERSION = '=1.2.3'") # equal sign 
     161    assert_equal "= 1.2.3", parse("RAILS_GEM_VERSION = '= 1.2.3'") # with space 
     162    assert_equal "!=1.2.3", parse("RAILS_GEM_VERSION = '!=1.2.3'") # not equal 
     163    assert_equal ">1.2.3", parse("RAILS_GEM_VERSION = '>1.2.3'") # greater than 
     164    assert_equal "<1.2.3", parse("RAILS_GEM_VERSION = '<1.2.3'") # less than 
     165    assert_equal ">=1.2.3", parse("RAILS_GEM_VERSION = '>=1.2.3'") # greater than or equal 
     166    assert_equal "<=1.2.3", parse("RAILS_GEM_VERSION = '<=1.2.3'") # less than or equal 
     167    assert_equal "~>1.2.3.0", parse("RAILS_GEM_VERSION = '~>1.2.3.0'") # approximately greater than 
     168  end 
     169 
    158170  private 
    159171    def parse(text)