ruby-changes:42235
From: hsbt <ko1@a...>
Date: Mon, 28 Mar 2016 11:30:32 +0900 (JST)
Subject: [ruby-changes:42235] hsbt:r54309 (trunk): * lib/rubygems.rb: Fix `Gem.find_spec_for_exe` picks oldest gem.
hsbt 2016-03-28 11:30:28 +0900 (Mon, 28 Mar 2016) New Revision: 54309 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54309 Log: * lib/rubygems.rb: Fix `Gem.find_spec_for_exe` picks oldest gem. https://github.com/travis-ci/travis-ci/issues/5798 https://github.com/rubygems/rubygems/pull/1566 * test/rubygems/test_gem.rb: ditto. Modified files: trunk/ChangeLog trunk/lib/rubygems.rb trunk/test/rubygems/test_gem.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 54308) +++ ChangeLog (revision 54309) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Mar 28 11:30:23 2016 Shinichi Maeshima <netwillnet@g...> + + * lib/rubygems.rb: Fix `Gem.find_spec_for_exe` picks oldest gem. + https://github.com/travis-ci/travis-ci/issues/5798 + https://github.com/rubygems/rubygems/pull/1566 + * test/rubygems/test_gem.rb: ditto. + Mon Mar 28 11:26:31 2016 SHIBATA Hiroshi <hsbt@r...> * lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.6.2. Index: lib/rubygems.rb =================================================================== --- lib/rubygems.rb (revision 54308) +++ lib/rubygems.rb (revision 54309) @@ -254,7 +254,7 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L254 spec.executables.include? exec_name } if exec_name - unless spec = specs.last + unless spec = specs.first msg = "can't find gem #{name} (#{requirements}) with executable #{exec_name}" raise Gem::GemNotFoundException, msg end Index: test/rubygems/test_gem.rb =================================================================== --- test/rubygems/test_gem.rb (revision 54308) +++ test/rubygems/test_gem.rb (revision 54309) @@ -143,6 +143,20 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L143 assert_match 'a-1/bin/exec', Gem.bin_path('a', 'exec', '>= 0') end + def test_self_bin_path_picking_newest + a1 = util_spec 'a', '1' do |s| + s.executables = ['exec'] + end + + a2 = util_spec 'a', '2' do |s| + s.executables = ['exec'] + end + + install_specs a1, a2 + + assert_match 'a-2/bin/exec', Gem.bin_path('a', 'exec', '>= 0') + end + def test_self_bin_path_no_exec_name e = assert_raises ArgumentError do Gem.bin_path 'a' -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/