2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe "Running bin/* commands" do
|
|
|
|
before :each do
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "rack"
|
|
|
|
G
|
|
|
|
end
|
|
|
|
|
|
|
|
it "runs the bundled command when in the bundle" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "binstubs rack"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
build_gem "rack", "2.0", :to_system => true do |s|
|
|
|
|
s.executables = "rackup"
|
|
|
|
end
|
|
|
|
|
|
|
|
gembin "rackup"
|
|
|
|
expect(out).to eq("1.0.0")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "allows the location of the gem stubs to be specified" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "binstubs rack", :path => "gbin"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
expect(bundled_app("bin")).not_to exist
|
|
|
|
expect(bundled_app("gbin/rackup")).to exist
|
|
|
|
|
|
|
|
gembin bundled_app("gbin/rackup")
|
|
|
|
expect(out).to eq("1.0.0")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "allows absolute paths as a specification of where to install bin stubs" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "binstubs rack", :path => tmp("bin")
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
gembin tmp("bin/rackup")
|
|
|
|
expect(out).to eq("1.0.0")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "uses the default ruby install name when shebang is not specified" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "binstubs rack"
|
2020-06-17 22:26:13 -04:00
|
|
|
expect(File.readlines(bundled_app("bin/rackup")).first).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "allows the name of the shebang executable to be specified" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "binstubs rack", :shebang => "ruby-foo"
|
2020-06-17 22:26:13 -04:00
|
|
|
expect(File.readlines(bundled_app("bin/rackup")).first).to eq("#!/usr/bin/env ruby-foo\n")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "runs the bundled command when out of the bundle" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "binstubs rack"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
build_gem "rack", "2.0", :to_system => true do |s|
|
|
|
|
s.executables = "rackup"
|
|
|
|
end
|
|
|
|
|
2020-05-08 01:19:04 -04:00
|
|
|
gembin "rackup", :dir => tmp
|
|
|
|
expect(out).to eq("1.0.0")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "works with gems in path" do
|
|
|
|
build_lib "rack", :path => lib_path("rack") do |s|
|
|
|
|
s.executables = "rackup"
|
|
|
|
end
|
|
|
|
|
|
|
|
gemfile <<-G
|
|
|
|
gem "rack", :path => "#{lib_path("rack")}"
|
|
|
|
G
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "binstubs rack"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
build_gem "rack", "2.0", :to_system => true do |s|
|
|
|
|
s.executables = "rackup"
|
|
|
|
end
|
|
|
|
|
|
|
|
gembin "rackup"
|
|
|
|
expect(out).to eq("1.0")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates a bundle binstub" do
|
|
|
|
gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "bundler"
|
|
|
|
G
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "binstubs bundler"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
expect(bundled_app("bin/bundle")).to exist
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not generate bin stubs if the option was not specified" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "install"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
expect(bundled_app("bin/rackup")).not_to exist
|
|
|
|
end
|
|
|
|
|
2019-01-04 08:10:58 -05:00
|
|
|
it "allows you to stop installing binstubs", :bundler => "< 3" do
|
2020-05-08 01:19:04 -04:00
|
|
|
skip "delete permission error" if Gem.win_platform?
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "install --binstubs bin/"
|
2018-11-02 19:07:56 -04:00
|
|
|
bundled_app("bin/rackup").rmtree
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "install --binstubs \"\""
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
expect(bundled_app("bin/rackup")).not_to exist
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "config bin"
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include("You have not configured a value for `bin`")
|
|
|
|
end
|
|
|
|
|
2019-01-04 08:10:58 -05:00
|
|
|
it "remembers that the option was specified", :bundler => "< 3" do
|
2018-11-02 19:07:56 -04:00
|
|
|
gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "activesupport"
|
|
|
|
G
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install, :binstubs => "bin"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "activesupport"
|
|
|
|
gem "rack"
|
|
|
|
G
|
|
|
|
|
|
|
|
bundle "install"
|
|
|
|
|
|
|
|
expect(bundled_app("bin/rackup")).to exist
|
|
|
|
end
|
|
|
|
|
|
|
|
it "rewrites bins on binstubs (to maintain backwards compatibility)" do
|
2020-06-03 14:46:03 -04:00
|
|
|
install_gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "rack"
|
|
|
|
G
|
|
|
|
|
|
|
|
create_file("bin/rackup", "OMG")
|
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "binstubs rack"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
expect(bundled_app("bin/rackup").read).to_not eq("OMG")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "use BUNDLE_GEMFILE gemfile for binstub" do
|
2019-06-20 06:35:55 -04:00
|
|
|
# context with bin/bundler w/ default Gemfile
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "binstubs bundler"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
# generate other Gemfile with executable gem
|
|
|
|
build_repo2 do
|
|
|
|
build_gem("bindir") {|s| s.executables = "foo" }
|
|
|
|
end
|
|
|
|
|
|
|
|
create_file("OtherGemfile", <<-G)
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo2)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem 'bindir'
|
|
|
|
G
|
|
|
|
|
|
|
|
# generate binstub for executable from non default Gemfile (other then bin/bundler version)
|
|
|
|
ENV["BUNDLE_GEMFILE"] = "OtherGemfile"
|
|
|
|
bundle "install"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "binstubs bindir"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
# remove user settings
|
|
|
|
ENV["BUNDLE_GEMFILE"] = nil
|
|
|
|
|
|
|
|
# run binstub for non default Gemfile
|
|
|
|
gembin "foo"
|
|
|
|
|
|
|
|
expect(out).to eq("1.0")
|
|
|
|
end
|
|
|
|
end
|