diff options
author | Sam Schenkman-Moore <samsm@samsm.com> | 2013-09-28 21:47:38 -0400 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2013-12-18 16:08:17 -0800 |
commit | 210badb9efa70a546b9e3ab22780d2de95fa6468 (patch) | |
tree | 558ce77981a80a9293fd9304e64db9a2f5294793 | |
parent | 876ef22b8d3d1b37d7adca7037b7b77d0aefb70a (diff) | |
download | bundler-210badb9efa70a546b9e3ab22780d2de95fa6468.tar.gz |
bin_path checks gem name as well as the availability of named bin.
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 4 | ||||
-rw-r--r-- | spec/commands/binstubs_spec.rb | 36 |
2 files changed, 38 insertions, 2 deletions
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 3bbbf1d293..c901445c16 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -300,8 +300,8 @@ module Bundler spec = nil if exec_name - spec = specs.find { |s| s.executables.include?(exec_name) } - spec or raise Gem::Exception, "can't find executable #{exec_name}" + spec = specs.find { |s| s.name == name && s.executables.include?(exec_name) } + spec or raise Gem::Exception, "can't find executable #{exec_name} in #{name}" else spec = specs.find { |s| s.name == name } exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}" diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index 3d3ed0fc58..d38c6fb6f1 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -191,3 +191,39 @@ describe "bundle binstubs <gem>" do end end end + +describe "running binstubs" do + it "gets correct version from binstub" do + build_git "gem_with_executable1" do |s| + s.executables = "gwe" + end + install_gemfile <<-G + gem "gem_with_executable1", :git => "#{lib_path('gem_with_executable1-1.0')}" + gem "bundler" + G + + bundle "binstubs gem_with_executable1" + + expect(bundled_app("bin/gwe")).to exist + expect(sys_exec("RUBYLIB='#{lib}' #{bundled_app("bin/gwe")}")).to eq("1.0") + end + + it "loads correct version from binstub when two gems have a bin with the same name" do + build_git "gem_with_executable1" do |s| + s.executables = "gwe" + end + build_git "gem_with_executable2", "2.0" do |s| + s.executables = "gwe" + end + install_gemfile <<-G + gem "gem_with_executable1", :git => "#{lib_path('gem_with_executable1-1.0')}" + gem "gem_with_executable2", :git => "#{lib_path('gem_with_executable2-2.0')}" + gem "bundler" + G + + bundle "binstubs gem_with_executable2" + + expect(bundled_app("bin/gwe")).to exist + expect(sys_exec("RUBYLIB='#{lib}' #{bundled_app("bin/gwe")}")).to eq("2.0") + end +end |