diff options
Diffstat (limited to 'spec/bundler/commands/binstubs_spec.rb')
-rw-r--r-- | spec/bundler/commands/binstubs_spec.rb | 78 |
1 files changed, 16 insertions, 62 deletions
diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb index 7f2e81c099..3f62f17b45 100644 --- a/spec/bundler/commands/binstubs_spec.rb +++ b/spec/bundler/commands/binstubs_spec.rb @@ -59,7 +59,7 @@ RSpec.describe "bundle binstubs <gem>" do bundle "binstubs" expect(exitstatus).to eq(1) if exitstatus - expect(out).to include("`bundle binstubs` needs at least one gem to run.") + expect(err).to include("`bundle binstubs` needs at least one gem to run.") end it "displays an error when used with --all and gems" do @@ -124,54 +124,16 @@ RSpec.describe "bundle binstubs <gem>" do bundle! "binstubs bundler rack prints_loaded_gems" end - # When environment has a same version of bundler as default gems. - # `system_gems "bundler-x.y.z"` will detect system binstub. - # We need to avoid it by virtual version of bundler. - let(:system_bundler_version) { Gem::Version.new(Bundler::VERSION).bump.to_s } + let(:system_bundler_version) { Bundler::VERSION } - context "when system bundler was used" do - # Support master branch of bundler - if ENV["BUNDLER_SPEC_SUB_VERSION"] - let(:system_bundler_version) { Bundler::VERSION } - end - - before do - gemfile <<-G - source "file:///Users/colby/Projects/bundler/tmp/gems/remote2" - gem "rack" - gem "prints_loaded_gems" - G - - lockfile <<-G - GEM - remote: file:///Users/colby/Projects/bundler/tmp/gems/remote2/ - specs: - prints_loaded_gems (1.0) - rack (1.2) - - PLATFORMS - ruby - - DEPENDENCIES - prints_loaded_gems - rack - - BUNDLED WITH - #{system_bundler_version} - G - end - - it "runs bundler" do - sys_exec! "#{bundled_app("bin/bundle")} install" - expect(out).to eq %(system bundler #{system_bundler_version}\n["install"]) - end + it "runs bundler" do + sys_exec! "#{bundled_app("bin/bundle")} install" + expect(out).to eq %(system bundler #{system_bundler_version}\n["install"]) end context "when BUNDLER_VERSION is set" do - let(:system_bundler_version) { Bundler::VERSION } - it "runs the correct version of bundler" do - sys_exec "BUNDLER_VERSION='999.999.999' #{bundled_app("bin/bundle")} install" + sys_exec "#{bundled_app("bin/bundle")} install", "BUNDLER_VERSION" => "999.999.999" expect(exitstatus).to eq(42) if exitstatus expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:"). and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`") @@ -179,8 +141,6 @@ RSpec.describe "bundle binstubs <gem>" do end context "when a lockfile exists with a locked bundler version" do - let(:system_bundler_version) { Bundler::VERSION } - it "runs the correct version of bundler when the version is newer" do lockfile lockfile.gsub(system_bundler_version, "999.999.999") sys_exec "#{bundled_app("bin/bundle")} install" @@ -236,13 +196,7 @@ RSpec.describe "bundle binstubs <gem>" do let(:system_bundler_version) { :bundler } it "loads all gems" do sys_exec! bundled_app("bin/print_loaded_gems").to_s - # RG < 2.0.14 didn't have a `Gem::Specification#default_gem?` - # This is dirty detection for old RG versions. - if File.dirname(Bundler.load.specs["bundler"][0].loaded_from) =~ %r{specifications/default} - expect(out).to eq %(["prints_loaded_gems-1.0", "rack-1.2"]) - else - expect(out).to eq %(["bundler-#{Bundler::VERSION}", "prints_loaded_gems-1.0", "rack-1.2"]) - end + expect(out).to eq %(["bundler-#{Bundler::VERSION}", "prints_loaded_gems-1.0", "rack-1.2"]) end context "when requesting a different bundler version" do @@ -324,7 +278,7 @@ RSpec.describe "bundle binstubs <gem>" do bundle "binstubs doesnt_exist" expect(exitstatus).to eq(7) if exitstatus - expect(out).to include("Could not find gem 'doesnt_exist'.") + expect(err).to include("Could not find gem 'doesnt_exist'.") end end @@ -396,8 +350,8 @@ RSpec.describe "bundle binstubs <gem>" do expect(bundled_app("bin/rackup")).to exist expect(File.read(bundled_app("bin/rackup"))).to eq("OMG") - expect(out).to include("Skipped rackup") - expect(out).to include("overwrite skipped stubs, use --force") + expect(err).to include("Skipped rackup") + expect(err).to include("overwrite skipped stubs, use --force") end context "when using --force" do @@ -428,8 +382,8 @@ RSpec.describe "bundle binstubs <gem>" do G bundle "binstubs rack-obama" - expect(out).to include("rack-obama has no executables") - expect(out).to include("rack has: rackup") + expect(err).to include("rack-obama has no executables") + expect(err).to include("rack has: rackup") end it "works if child gems don't have bins" do @@ -439,7 +393,7 @@ RSpec.describe "bundle binstubs <gem>" do G bundle "binstubs actionpack" - expect(out).to include("no executables for the gem actionpack") + expect(err).to include("no executables for the gem actionpack") end it "works if the gem has development dependencies" do @@ -449,7 +403,7 @@ RSpec.describe "bundle binstubs <gem>" do G bundle "binstubs with_development_dependency" - expect(out).to include("no executables for the gem with_development_dependency") + expect(err).to include("no executables for the gem with_development_dependency") end end @@ -460,7 +414,7 @@ RSpec.describe "bundle binstubs <gem>" do gem "rack" G - bundle "config auto_install 1" + bundle "config set auto_install 1" bundle "binstubs rack" expect(out).to include("Installing rack 1.0.0") expect(the_bundle).to include_gems "rack 1.0.0" @@ -472,7 +426,7 @@ RSpec.describe "bundle binstubs <gem>" do gem "rack" G - bundle "config auto_install 1" + bundle "config set auto_install 1" bundle "binstubs rack", :env => { "BUNDLE_INSTALL" => 1 } expect(out).not_to include("Installing rack 1.0.0") end |