diff options
Diffstat (limited to 'spec/bundler/runtime/executable_spec.rb')
-rw-r--r-- | spec/bundler/runtime/executable_spec.rb | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/spec/bundler/runtime/executable_spec.rb b/spec/bundler/runtime/executable_spec.rb index ff27d0b415..388ee049d0 100644 --- a/spec/bundler/runtime/executable_spec.rb +++ b/spec/bundler/runtime/executable_spec.rb @@ -1,16 +1,15 @@ # frozen_string_literal: true -require "spec_helper" RSpec.describe "Running bin/* commands" do before :each do - gemfile <<-G + install_gemfile! <<-G source "file://#{gem_repo1}" gem "rack" G end it "runs the bundled command when in the bundle" do - bundle "install --binstubs" + bundle! "binstubs rack" build_gem "rack", "2.0", :to_system => true do |s| s.executables = "rackup" @@ -21,7 +20,7 @@ RSpec.describe "Running bin/* commands" do end it "allows the location of the gem stubs to be specified" do - bundle "install --binstubs gbin" + bundle! "binstubs rack", :path => "gbin" expect(bundled_app("bin")).not_to exist expect(bundled_app("gbin/rackup")).to exist @@ -31,24 +30,24 @@ RSpec.describe "Running bin/* commands" do end it "allows absolute paths as a specification of where to install bin stubs" do - bundle "install --binstubs #{tmp}/bin" + bundle! "binstubs rack", :path => tmp("bin") 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 - bundle "install --binstubs" + bundle! "binstubs rack" expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n") end it "allows the name of the shebang executable to be specified" do - bundle "install --binstubs --shebang ruby-foo" + bundle! "binstubs rack", :shebang => "ruby-foo" expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env ruby-foo\n") end it "runs the bundled command when out of the bundle" do - bundle "install --binstubs" + bundle! "binstubs rack" build_gem "rack", "2.0", :to_system => true do |s| s.executables = "rackup" @@ -69,7 +68,7 @@ RSpec.describe "Running bin/* commands" do gem "rack", :path => "#{lib_path("rack")}" G - bundle "install --binstubs" + bundle! "binstubs rack" build_gem "rack", "2.0", :to_system => true do |s| s.executables = "rackup" @@ -79,7 +78,7 @@ RSpec.describe "Running bin/* commands" do expect(out).to eq("1.0") end - it "don't bundle da bundla" do + it "creates a bundle binstub" do build_gem "bundler", Bundler::VERSION, :to_system => true do |s| s.executables = "bundle" end @@ -89,35 +88,35 @@ RSpec.describe "Running bin/* commands" do gem "bundler" G - bundle "install --binstubs" + bundle! "binstubs bundler" - expect(bundled_app("bin/bundle")).not_to exist + expect(bundled_app("bin/bundle")).to exist end it "does not generate bin stubs if the option was not specified" do - bundle "install" + bundle! "install" expect(bundled_app("bin/rackup")).not_to exist end - it "allows you to stop installing binstubs" do - bundle "install --binstubs bin/" + it "allows you to stop installing binstubs", :bundler => "< 2" do + bundle! "install --binstubs bin/" bundled_app("bin/rackup").rmtree - bundle "install --binstubs \"\"" + bundle! "install --binstubs \"\"" expect(bundled_app("bin/rackup")).not_to exist - bundle "config bin" + bundle! "config bin" expect(out).to include("You have not configured a value for `bin`") end - it "remembers that the option was specified" do + it "remembers that the option was specified", :bundler => "< 2" do gemfile <<-G source "file://#{gem_repo1}" gem "activesupport" G - bundle "install --binstubs" + bundle! :install, forgotten_command_line_options([:binstubs, :bin] => "bin") gemfile <<-G source "file://#{gem_repo1}" @@ -130,13 +129,13 @@ RSpec.describe "Running bin/* commands" do expect(bundled_app("bin/rackup")).to exist end - it "rewrites bins on --binstubs (to maintain backwards compatibility)" do + it "rewrites bins on --binstubs (to maintain backwards compatibility)", :bundler => "< 2" do gemfile <<-G source "file://#{gem_repo1}" gem "rack" G - bundle "install --binstubs bin/" + bundle! :install, forgotten_command_line_options([:binstubs, :bin] => "bin") File.open(bundled_app("bin/rackup"), "wb") do |file| file.print "OMG" @@ -146,4 +145,17 @@ RSpec.describe "Running bin/* commands" do expect(bundled_app("bin/rackup").read).to_not eq("OMG") end + + it "rewrites bins on binstubs (to maintain backwards compatibility)" do + install_gemfile! <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + create_file("bin/rackup", "OMG") + + bundle! "binstubs rack" + + expect(bundled_app("bin/rackup").read).to_not eq("OMG") + end end |