From 64ce7711c0c428531ae09472c85df85cd3d1b603 Mon Sep 17 00:00:00 2001 From: hsbt Date: Mon, 28 Mar 2016 02:30:28 +0000 Subject: * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ lib/rubygems.rb | 2 +- test/rubygems/test_gem.rb | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f1a4a1a55d..27285d2554 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Mar 28 11:30:23 2016 Shinichi Maeshima + + * 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 * lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.6.2. diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 8783756cd9..6b2016fd9b 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -254,7 +254,7 @@ module Gem 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 diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index e78f874b4e..931c9e498d 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -143,6 +143,20 @@ class TestGem < Gem::TestCase 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' -- cgit v1.2.3