diff options
Diffstat (limited to 'spec/bundler/runtime/executable_spec.rb')
| -rw-r--r-- | spec/bundler/runtime/executable_spec.rb | 132 |
1 files changed, 44 insertions, 88 deletions
diff --git a/spec/bundler/runtime/executable_spec.rb b/spec/bundler/runtime/executable_spec.rb index 98077efaf0..89cee21b00 100644 --- a/spec/bundler/runtime/executable_spec.rb +++ b/spec/bundler/runtime/executable_spec.rb @@ -3,158 +3,115 @@ RSpec.describe "Running bin/* commands" do before :each do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem "rack" + source "https://gem.repo1" + gem "myrack" G end it "runs the bundled command when in the bundle" do - skip "exec format error" if Gem.win_platform? + bundle "binstubs myrack" - bundle "binstubs rack" - - build_gem "rack", "2.0", :to_system => true do |s| - s.executables = "rackup" + build_gem "myrack", "2.0", to_system: true do |s| + s.executables = "myrackup" end - gembin "rackup" + gembin "myrackup" expect(out).to eq("1.0.0") end - it "allows the location of the gem stubs to be specified" do - skip "created in bin :/" if Gem.win_platform? - - bundle "binstubs rack", :path => "gbin" + it "allows the location of the gem stubs to be configured" do + bundle_config "bin gbin" + bundle "binstubs myrack" expect(bundled_app("bin")).not_to exist - expect(bundled_app("gbin/rackup")).to exist + expect(bundled_app("gbin/myrackup")).to exist - gembin bundled_app("gbin/rackup") + gembin bundled_app("gbin/myrackup") expect(out).to eq("1.0.0") end it "allows absolute paths as a specification of where to install bin stubs" do - skip "exec format error" if Gem.win_platform? + bundle_config "bin #{tmp("bin")}" + bundle "binstubs myrack" - bundle "binstubs rack", :path => tmp("bin") - - gembin tmp("bin/rackup") + gembin tmp("bin/myrackup") expect(out).to eq("1.0.0") end it "uses the default ruby install name when shebang is not specified" do - bundle "binstubs rack" - expect(File.open(bundled_app("bin/rackup")).gets).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n") + bundle "binstubs myrack" + expect(File.readlines(bundled_app("bin/myrackup")).first).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n") end it "allows the name of the shebang executable to be specified" do - skip "not created with custom name :/" if Gem.win_platform? - - bundle "binstubs rack", :shebang => "ruby-foo" - expect(File.open(bundled_app("bin/rackup")).gets).to eq("#!/usr/bin/env ruby-foo\n") + bundle "binstubs myrack", shebang: "ruby-foo" + expect(File.readlines(bundled_app("bin/myrackup")).first).to eq("#!/usr/bin/env ruby-foo\n") end it "runs the bundled command when out of the bundle" do - skip "exec format error" if Gem.win_platform? + bundle "binstubs myrack" - bundle "binstubs rack" - - build_gem "rack", "2.0", :to_system => true do |s| - s.executables = "rackup" + build_gem "myrack", "2.0", to_system: true do |s| + s.executables = "myrackup" end - gembin "rackup", :dir => tmp + gembin "myrackup", dir: tmp expect(out).to eq("1.0.0") end it "works with gems in path" do - skip "exec format error" if Gem.win_platform? - - build_lib "rack", :path => lib_path("rack") do |s| - s.executables = "rackup" + build_lib "myrack", path: lib_path("myrack") do |s| + s.executables = "myrackup" end gemfile <<-G - gem "rack", :path => "#{lib_path("rack")}" + source "https://gem.repo1" + gem "myrack", :path => "#{lib_path("myrack")}" G - bundle "binstubs rack" + bundle "binstubs myrack" - build_gem "rack", "2.0", :to_system => true do |s| - s.executables = "rackup" + build_gem "myrack", "2.0", to_system: true do |s| + s.executables = "myrackup" end - gembin "rackup" + gembin "myrackup" expect(out).to eq("1.0") end - it "creates a bundle binstub" do + it "does not create a bundle binstub" do gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "https://gem.repo1" gem "bundler" G bundle "binstubs bundler" - expect(bundled_app("bin/bundle")).to exist - end + expect(bundled_app("bin/bundle")).not_to exist - it "does not generate bin stubs if the option was not specified" do - skip "generated :/" if Gem.win_platform? - - bundle "install" - - expect(bundled_app("bin/rackup")).not_to exist + expect(err).to include("Bundler itself does not use binstubs because its version is selected by RubyGems") end - it "allows you to stop installing binstubs", :bundler => "< 3" do - skip "delete permission error" if Gem.win_platform? - - bundle "install --binstubs bin/" - bundled_app("bin/rackup").rmtree - bundle "install --binstubs \"\"" - - expect(bundled_app("bin/rackup")).not_to exist - - bundle "config bin" - expect(out).to include("You have not configured a value for `bin`") - end - - it "remembers that the option was specified", :bundler => "< 3" do - gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem "activesupport" - G - - bundle :install, :binstubs => "bin" - - gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem "activesupport" - gem "rack" - G - + it "does not generate bin stubs if the option was not specified" do bundle "install" - expect(bundled_app("bin/rackup")).to exist + expect(bundled_app("bin/myrackup")).not_to exist end - it "rewrites bins on binstubs (to maintain backwards compatibility)" do + it "rewrites bins on binstubs with --force option" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem "rack" + source "https://gem.repo1" + gem "myrack" G - create_file("bin/rackup", "OMG") + create_file("bin/myrackup", "OMG") - bundle "binstubs rack" + bundle "binstubs myrack", { force: true } - expect(bundled_app("bin/rackup").read).to_not eq("OMG") + expect(bundled_app("bin/myrackup").read.strip).to_not eq("OMG") end it "use BUNDLE_GEMFILE gemfile for binstub" do - skip "exec format error" if Gem.win_platform? - # context with bin/bundler w/ default Gemfile bundle "binstubs bundler" @@ -163,8 +120,8 @@ RSpec.describe "Running bin/* commands" do build_gem("bindir") {|s| s.executables = "foo" } end - create_file("OtherGemfile", <<-G) - source "#{file_uri_for(gem_repo2)}" + gemfile("OtherGemfile", <<-G) + source "https://gem.repo2" gem 'bindir' G @@ -179,7 +136,6 @@ RSpec.describe "Running bin/* commands" do # run binstub for non default Gemfile gembin "foo" - expect(exitstatus).to eq(0) if exitstatus expect(out).to eq("1.0") end end |
