summaryrefslogtreecommitdiff
path: root/spec/bundler/commands
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-01 23:29:38 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-01 23:29:38 +0000
commitbe7b5929126cb3e696ef222339237faba9b8fe5a (patch)
tree51eae376f93c09bc82dde5a657a91df2c89062e4 /spec/bundler/commands
parentae49dbd392083f69026f2a0fff4a1d5f42d172a7 (diff)
Update bundled bundler to 1.16.0.
* lib/bundler, spec/bundler: Merge bundler-1.16.0. * common.mk: rspec examples of bundler-1.16.0 needs require option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/bundler/commands')
-rw-r--r--spec/bundler/commands/add_spec.rb5
-rw-r--r--spec/bundler/commands/binstubs_spec.rb168
-rw-r--r--spec/bundler/commands/check_spec.rb56
-rw-r--r--spec/bundler/commands/clean_spec.rb147
-rw-r--r--spec/bundler/commands/config_spec.rb7
-rw-r--r--spec/bundler/commands/console_spec.rb3
-rw-r--r--spec/bundler/commands/doctor_spec.rb17
-rw-r--r--spec/bundler/commands/exec_spec.rb81
-rw-r--r--spec/bundler/commands/help_spec.rb3
-rw-r--r--spec/bundler/commands/info_spec.rb1
-rw-r--r--spec/bundler/commands/init_spec.rb99
-rw-r--r--spec/bundler/commands/inject_spec.rb11
-rw-r--r--spec/bundler/commands/install_spec.rb82
-rw-r--r--spec/bundler/commands/issue_spec.rb1
-rw-r--r--spec/bundler/commands/licenses_spec.rb1
-rw-r--r--spec/bundler/commands/list_spec.rb40
-rw-r--r--spec/bundler/commands/lock_spec.rb35
-rw-r--r--spec/bundler/commands/newgem_spec.rb30
-rw-r--r--spec/bundler/commands/open_spec.rb1
-rw-r--r--spec/bundler/commands/outdated_spec.rb54
-rw-r--r--spec/bundler/commands/package_spec.rb30
-rw-r--r--spec/bundler/commands/pristine_spec.rb56
-rw-r--r--spec/bundler/commands/show_spec.rb11
-rw-r--r--spec/bundler/commands/update_spec.rb282
-rw-r--r--spec/bundler/commands/version_spec.rb39
-rw-r--r--spec/bundler/commands/viz_spec.rb1
26 files changed, 946 insertions, 315 deletions
diff --git a/spec/bundler/commands/add_spec.rb b/spec/bundler/commands/add_spec.rb
index 4931402c33..7916db960a 100644
--- a/spec/bundler/commands/add_spec.rb
+++ b/spec/bundler/commands/add_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle add" do
before :each do
@@ -82,7 +81,7 @@ RSpec.describe "bundle add" do
it "using combination of short form options works like long form" do
bundle "add 'foo' -s='file://#{gem_repo2}' -g='development' -v='~>1.0'"
- expect(bundled_app("Gemfile").read).to match(%r{gem "foo", "~> 1.0", :group => \[:development\], :source => "file:\/\/#{gem_repo2}"})
+ expect(bundled_app("Gemfile").read).to include %(gem "foo", "~> 1.0", :group => [:development], :source => "file://#{gem_repo2}")
expect(the_bundle).to include_gems "foo 1.1"
end
@@ -93,7 +92,7 @@ RSpec.describe "bundle add" do
it "shows error message when gem cannot be found" do
bundle "add 'werk_it'"
- expect(out).to match("Could not find gem 'werk_it' in any of the gem sources listed in your Gemfile.")
+ expect(out).to match("Could not find gem 'werk_it' in")
bundle "add 'werk_it' -s='file://#{gem_repo2}'"
expect(out).to match("Could not find gem 'werk_it' in rubygems repository")
diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb
index cb0999348e..0313f48b60 100644
--- a/spec/bundler/commands/binstubs_spec.rb
+++ b/spec/bundler/commands/binstubs_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle binstubs <gem>" do
context "when the gem exists in the lockfile" do
@@ -51,22 +50,130 @@ RSpec.describe "bundle binstubs <gem>" do
expect(out).to include("`bundle binstubs` needs at least one gem to run.")
end
- it "does not bundle the bundler binary" do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- G
+ context "the bundle binstub" do
+ before do
+ if system_bundler_version == :bundler
+ system_gems :bundler
+ elsif system_bundler_version
+ build_repo4 do
+ build_gem "bundler", system_bundler_version do |s|
+ s.executables = "bundle"
+ s.bindir = "exe"
+ s.write "exe/bundle", "puts %(system bundler #{system_bundler_version}\\n\#{ARGV.inspect})"
+ end
+ end
+ system_gems "bundler-#{system_bundler_version}", :gem_repo => gem_repo4
+ end
+ build_repo2 do
+ build_gem "prints_loaded_gems", "1.0" do |s|
+ s.executables = "print_loaded_gems"
+ s.write "bin/print_loaded_gems", <<-R
+ specs = Gem.loaded_specs.values.reject {|s| Bundler.rubygems.spec_default_gem?(s) }
+ puts specs.map(&:full_name).sort.inspect
+ R
+ end
+ end
+ install_gemfile! <<-G
+ source "file://#{gem_repo2}"
+ gem "rack"
+ gem "prints_loaded_gems"
+ G
+ bundle! "binstubs bundler rack prints_loaded_gems"
+ end
+
+ let(:system_bundler_version) { Bundler::VERSION }
+
+ 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
+ it "runs the correct version of bundler" do
+ sys_exec "BUNDLER_VERSION='999.999.999' #{bundled_app("bin/bundle")} install"
+ 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'`")
+ end
+ end
+
+ context "when a lockfile exists with a locked bundler version" do
+ 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"
+ 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'`")
+ end
+
+ it "runs the correct version of bundler when the version is older" do
+ simulate_bundler_version "55"
+ lockfile lockfile.gsub(system_bundler_version, "44.0")
+ sys_exec "#{bundled_app("bin/bundle")} install"
+ expect(exitstatus).to eq(42) if exitstatus
+ expect(last_command.stderr).to include("Activating bundler (44.0) failed:").
+ and include("To install the version of bundler this project requires, run `gem install bundler -v '44.0'`")
+ end
+
+ it "runs the correct version of bundler when the version is a pre-release" do
+ simulate_bundler_version "55"
+ lockfile lockfile.gsub(system_bundler_version, "2.12.0.a")
+ sys_exec "#{bundled_app("bin/bundle")} install"
+ expect(exitstatus).to eq(42) if exitstatus
+ expect(last_command.stderr).to include("Activating bundler (2.12.0.a) failed:").
+ and include("To install the version of bundler this project requires, run `gem install bundler -v '2.12.0.a'`")
+ end
+ end
+
+ context "when update --bundler is called" do
+ before { lockfile.gsub(system_bundler_version, "1.1.1") }
+
+ it "calls through to the latest bundler version" do
+ sys_exec! "#{bundled_app("bin/bundle")} update --bundler"
+ expect(last_command.stdout).to eq %(system bundler #{system_bundler_version}\n["update", "--bundler"])
+ end
+
+ it "calls through to the explicit bundler version" do
+ sys_exec "#{bundled_app("bin/bundle")} update --bundler=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'`")
+ end
+ end
+
+ context "without a lockfile" do
+ it "falls back to the latest installed bundler" do
+ FileUtils.rm bundled_app("Gemfile.lock")
+ sys_exec! bundled_app("bin/bundle").to_s
+ expect(out).to eq "system bundler #{system_bundler_version}\n[]"
+ end
+ end
+
+ context "using another binstub", :ruby_repo do
+ let(:system_bundler_version) { :bundler }
+ it "loads all gems" do
+ sys_exec! bundled_app("bin/print_loaded_gems").to_s
+ expect(out).to eq %(["bundler-#{Bundler::VERSION}", "prints_loaded_gems-1.0", "rack-1.2"])
+ end
- bundle "binstubs bundler"
+ context "when requesting a different bundler version" do
+ before { lockfile lockfile.gsub(Bundler::VERSION, "999.999.999") }
- expect(bundled_app("bin/bundle")).not_to exist
- expect(out).to include("Sorry, Bundler can only be run via Rubygems.")
+ it "attempts to load that version" do
+ sys_exec bundled_app("bin/rackup").to_s
+ 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'`")
+ end
+ end
+ end
end
it "installs binstubs from git gems" do
FileUtils.mkdir_p(lib_path("foo/bin"))
FileUtils.touch(lib_path("foo/bin/foo"))
build_git "foo", "1.0", :path => lib_path("foo") do |s|
- s.executables = %w(foo)
+ s.executables = %w[foo]
end
install_gemfile <<-G
gem "foo", :git => "#{lib_path("foo")}"
@@ -81,7 +188,7 @@ RSpec.describe "bundle binstubs <gem>" do
FileUtils.mkdir_p(lib_path("foo/bin"))
FileUtils.touch(lib_path("foo/bin/foo"))
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.executables = %w(foo)
+ s.executables = %w[foo]
end
install_gemfile <<-G
gem "foo", :path => "#{lib_path("foo")}"
@@ -104,6 +211,19 @@ RSpec.describe "bundle binstubs <gem>" do
expect(File.stat(binary).mode.to_s(8)).to eq("100775")
end
end
+
+ context "when using --shebang" do
+ it "sets the specified shebang for the the binstub" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle "binstubs rack --shebang jruby"
+
+ expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env jruby\n")
+ end
+ end
end
context "when the gem doesn't exist" do
@@ -131,33 +251,43 @@ RSpec.describe "bundle binstubs <gem>" do
expect(bundled_app("exec/rackup")).to exist
end
- it "setting is saved for bundle install" do
+ it "setting is saved for bundle install", :bundler => "< 2" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
gem "rails"
G
- bundle "binstubs rack --path exec"
- bundle :install
+ bundle! "binstubs rack", forgotten_command_line_options([:path, :bin] => "exec")
+ bundle! :install
expect(bundled_app("exec/rails")).to exist
end
end
- context "after installing with --standalone" do
+ context "with --standalone option" do
before do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
- bundle "install --standalone"
end
- it "includes the standalone path" do
- bundle "binstubs rack --standalone"
- standalone_line = File.read(bundled_app("bin/rackup")).each_line.find {|line| line.include? "$:.unshift" }.strip
- expect(standalone_line).to eq %($:.unshift File.expand_path "../../bundle", path.realpath)
+ it "generates a standalone binstub" do
+ bundle! "binstubs rack --standalone"
+ expect(bundled_app("bin/rackup")).to exist
+ end
+
+ it "generates a binstub that does not depend on rubygems or bundler" do
+ bundle! "binstubs rack --standalone"
+ expect(File.read(bundled_app("bin/rackup"))).to_not include("Gem.bin_path")
+ end
+
+ context "when specified --path option" do
+ it "generates a standalone binstub at the given path" do
+ bundle! "binstubs rack --standalone --path foo"
+ expect(bundled_app("foo/rackup")).to exist
+ end
end
end
diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb
index 532be07c3f..f2af446fbf 100644
--- a/spec/bundler/commands/check_spec.rb
+++ b/spec/bundler/commands/check_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle check" do
it "returns success when the Gemfile is satisfied" do
@@ -93,7 +92,7 @@ RSpec.describe "bundle check" do
expect(out).to include("Bundler can't satisfy your Gemfile's dependencies.")
end
- it "remembers --without option from install" do
+ it "remembers --without option from install", :bundler => "< 2" do
gemfile <<-G
source "file://#{gem_repo1}"
group :foo do
@@ -101,9 +100,21 @@ RSpec.describe "bundle check" do
end
G
- bundle "install --without foo"
- bundle "check"
- expect(exitstatus).to eq(0) if exitstatus
+ bundle! "install --without foo"
+ bundle! "check"
+ expect(out).to include("The Gemfile's dependencies are satisfied")
+ end
+
+ it "uses the without setting" do
+ bundle! "config without foo"
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+ group :foo do
+ gem "rack"
+ end
+ G
+
+ bundle! "check"
expect(out).to include("The Gemfile's dependencies are satisfied")
end
@@ -113,7 +124,7 @@ RSpec.describe "bundle check" do
gem "rack", :group => :foo
G
- bundle "install --without foo"
+ bundle :install, forgotten_command_line_options(:without => "foo")
gemfile <<-G
source "file://#{gem_repo1}"
@@ -126,8 +137,6 @@ RSpec.describe "bundle check" do
end
it "ignores missing gems restricted to other platforms" do
- system_gems "rack-1.0.0"
-
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -136,6 +145,8 @@ RSpec.describe "bundle check" do
end
G
+ system_gems "rack-1.0.0", :path => :bundle_path
+
lockfile <<-G
GEM
remote: file:#{gem_repo1}/
@@ -157,8 +168,6 @@ RSpec.describe "bundle check" do
end
it "works with env conditionals" do
- system_gems "rack-1.0.0"
-
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -167,6 +176,8 @@ RSpec.describe "bundle check" do
end
G
+ system_gems "rack-1.0.0", :path => :bundle_path
+
lockfile <<-G
GEM
remote: file:#{gem_repo1}/
@@ -211,25 +222,23 @@ RSpec.describe "bundle check" do
3.times do
bundle :check
expect(out).to eq(last_out)
- expect(err).to lack_errors
end
end
it "fails when there's no lock file and frozen is set" do
- gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "foo"
G
- bundle "install"
- bundle "install --deployment"
+ bundle! "install", forgotten_command_line_options(:deployment => true)
FileUtils.rm(bundled_app("Gemfile.lock"))
bundle :check
- expect(exitstatus).not_to eq(0) if exitstatus
+ expect(last_command).to be_failure
end
- context "--path" do
+ context "--path", :bundler => "< 2" do
before do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -241,15 +250,13 @@ RSpec.describe "bundle check" do
end
it "returns success" do
- bundle "check --path vendor/bundle"
- expect(exitstatus).to eq(0) if exitstatus
+ bundle! "check --path vendor/bundle"
expect(out).to include("The Gemfile's dependencies are satisfied")
end
- it "should write to .bundle/config" do
+ it "should write to .bundle/config", :bundler => "< 2" do
bundle "check --path vendor/bundle"
- bundle "check"
- expect(exitstatus).to eq(0) if exitstatus
+ bundle! "check"
end
end
@@ -299,7 +306,7 @@ RSpec.describe "bundle check" do
rack (1.0.0)
PLATFORMS
- #{generic_local_platform}
+ #{lockfile_platforms}
DEPENDENCIES
rack
@@ -330,9 +337,8 @@ RSpec.describe "bundle check" do
context "is newer" do
it "does not change the lock but warns" do
lockfile lock_with(Bundler::VERSION.succ)
- bundle :check
- expect(out).to include("the running version of Bundler (#{Bundler::VERSION}) is older than the version that created the lockfile (#{Bundler::VERSION.succ})")
- expect(err).to lack_errors
+ bundle! :check
+ expect(last_command.bundler_err).to include("the running version of Bundler (#{Bundler::VERSION}) is older than the version that created the lockfile (#{Bundler::VERSION.succ})")
lockfile_should_be lock_with(Bundler::VERSION.succ)
end
end
diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb
index 02d96a0ff7..bab87372d1 100644
--- a/spec/bundler/commands/clean_spec.rb
+++ b/spec/bundler/commands/clean_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle clean" do
def should_have_gems(*gems)
@@ -26,16 +25,16 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
gem "thin"
G
- bundle "install"
+ bundle! "install"
- bundle :clean
+ bundle! :clean
expect(out).to include("Removing foo (1.0)")
@@ -53,7 +52,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -81,7 +80,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -89,9 +88,9 @@ RSpec.describe "bundle clean" do
gem "rack", "0.9.1"
gem "foo"
G
- bundle "install"
+ bundle! "update rack"
- bundle :clean
+ bundle! :clean
expect(out).to include("Removing rack (1.0.0)")
@@ -112,8 +111,8 @@ RSpec.describe "bundle clean" do
end
G
- bundle "install --path vendor/bundle"
- bundle "install --without test_group"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
+ bundle "install", forgotten_command_line_options(:without => "test_group")
bundle :clean
expect(out).to include("Removing rack (1.0.0)")
@@ -138,12 +137,13 @@ RSpec.describe "bundle clean" do
end
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
bundle :clean
- digest = Digest::SHA1.hexdigest(git_path.to_s)
- expect(vendored_gems("cache/bundler/git/foo-1.0-#{digest}")).to exist
+ digest = Digest(:SHA1).hexdigest(git_path.to_s)
+ cache_path = Bundler::VERSION.start_with?("1.") ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}")
+ expect(cache_path).to exist
end
it "removes unused git gems" do
@@ -160,7 +160,7 @@ RSpec.describe "bundle clean" do
end
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
gemfile <<-G
source "file://#{gem_repo1}"
@@ -175,7 +175,7 @@ RSpec.describe "bundle clean" do
expect(vendored_gems("gems/rack-1.0.0")).to exist
expect(vendored_gems("bundler/gems/foo-#{revision[0..11]}")).not_to exist
- digest = Digest::SHA1.hexdigest(git_path.to_s)
+ digest = Digest(:SHA1).hexdigest(git_path.to_s)
expect(vendored_gems("cache/bundler/git/foo-#{digest}")).not_to exist
expect(vendored_gems("specifications/rack-1.0.0.gemspec")).to exist
@@ -196,13 +196,13 @@ RSpec.describe "bundle clean" do
end
G
- bundle "install --path vendor/bundle"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
update_git "foo", :path => lib_path("foo-bar")
revision2 = revision_for(lib_path("foo-bar"))
- bundle "update"
- bundle :clean
+ bundle! "update", :all => bundle_update_requires_all?
+ bundle! :clean
expect(out).to include("Removing foo-bar (#{revision[0..11]})")
@@ -226,7 +226,7 @@ RSpec.describe "bundle clean" do
gem "activesupport", :git => "#{lib_path("rails")}", :ref => '#{revision}'
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
bundle :clean
expect(out).to include("")
@@ -248,13 +248,13 @@ RSpec.describe "bundle clean" do
end
end
G
- bundle "install --path vendor/bundle --without test"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :without => "test")
bundle :clean
expect(out).to include("")
expect(vendored_gems("bundler/gems/foo-#{revision[0..11]}")).to exist
- digest = Digest::SHA1.hexdigest(git_path.to_s)
+ digest = Digest(:SHA1).hexdigest(git_path.to_s)
expect(vendored_gems("cache/bundler/git/foo-#{digest}")).to_not exist
end
@@ -269,13 +269,14 @@ RSpec.describe "bundle clean" do
end
G
- bundle "install --path vendor/bundle --without development"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :without => "development")
bundle :clean
expect(exitstatus).to eq(0) if exitstatus
end
it "displays an error when used without --path" do
+ bundle! "config path.system true"
install_gemfile <<-G
source "file://#{gem_repo1}"
@@ -284,7 +285,7 @@ RSpec.describe "bundle clean" do
bundle :clean
- expect(exitstatus).to eq(1) if exitstatus
+ expect(exitstatus).to eq(15) if exitstatus
expect(out).to include("--force")
end
@@ -297,7 +298,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
gemfile <<-G
source "file://#{gem_repo1}"
@@ -319,34 +320,37 @@ RSpec.describe "bundle clean" do
end
it "does not call clean automatically when using system gems" do
- gemfile <<-G
+ bundle! "config path.system true"
+
+ bundle! :config
+
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "thin"
gem "rack"
G
- bundle :install
- gemfile <<-G
+ bundle! "info thin"
+
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
G
- bundle :install
- sys_exec "gem list"
- expect(out).to include("rack (1.0.0)")
- expect(out).to include("thin (1.0)")
+ sys_exec! "gem list"
+ expect(out).to include("rack (1.0.0)").and include("thin (1.0)")
end
- it "--clean should override the bundle setting on install" do
+ it "--clean should override the bundle setting on install", :bundler => "< 2" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "thin"
gem "rack"
G
- bundle "install --path vendor/bundle --clean"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => true)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -359,7 +363,7 @@ RSpec.describe "bundle clean" do
should_not_have_gems "thin-1.0"
end
- it "--clean should override the bundle setting on update" do
+ it "--clean should override the bundle setting on update", :bundler => "< 2" do
build_repo2
gemfile <<-G
@@ -367,18 +371,42 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --clean"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => true)
update_repo2 do
build_gem "foo", "1.0.1"
end
- bundle "update"
+ bundle! "update", :all => bundle_update_requires_all?
should_have_gems "foo-1.0.1"
should_not_have_gems "foo-1.0"
end
+ it "automatically cleans when path has not been set", :bundler => "2" do
+ build_repo2
+
+ install_gemfile! <<-G
+ source "file://#{gem_repo2}"
+
+ gem "foo"
+ G
+
+ update_repo2 do
+ build_gem "foo", "1.0.1"
+ end
+
+ bundle! "update", :all => true
+
+ files = Pathname.glob(bundled_app(".bundle", Bundler.ruby_scope, "*", "*"))
+ files.map! {|f| f.to_s.sub(bundled_app(".bundle", Bundler.ruby_scope).to_s, "") }
+ expect(files.sort).to eq %w[
+ /cache/foo-1.0.1.gem
+ /gems/foo-1.0.1
+ /specifications/foo-1.0.1.gemspec
+ ]
+ end
+
it "does not clean automatically on --path" do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -386,7 +414,7 @@ RSpec.describe "bundle clean" do
gem "thin"
gem "rack"
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
gemfile <<-G
source "file://#{gem_repo1}"
@@ -406,17 +434,19 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
update_repo2 do
build_gem "foo", "1.0.1"
end
- bundle :update
+ bundle! :update, :all => bundle_update_requires_all?
should_have_gems "foo-1.0", "foo-1.0.1"
end
it "does not clean on bundle update when using --system" do
+ bundle! "config path.system true"
+
build_repo2
gemfile <<-G
@@ -424,18 +454,20 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install"
+ bundle! "install"
update_repo2 do
build_gem "foo", "1.0.1"
end
- bundle :update
+ bundle! :update, :all => bundle_update_requires_all?
- sys_exec "gem list"
+ sys_exec! "gem list"
expect(out).to include("foo (1.0.1, 1.0)")
end
it "cleans system gems when --force is used" do
+ bundle! "config path.system true"
+
gemfile <<-G
source "file://#{gem_repo1}"
@@ -459,8 +491,10 @@ RSpec.describe "bundle clean" do
end
describe "when missing permissions" do
+ before { ENV["BUNDLE_PATH__SYSTEM"] = "true" }
+ let(:system_cache_path) { system_gem_path("cache") }
after do
- FileUtils.chmod(0o755, default_bundle_path("cache"))
+ FileUtils.chmod(0o755, system_cache_path)
end
it "returns a helpful error message" do
gemfile <<-G
@@ -478,7 +512,6 @@ RSpec.describe "bundle clean" do
G
bundle :install
- system_cache_path = default_bundle_path("cache")
FileUtils.chmod(0o500, system_cache_path)
bundle :clean, :force => true
@@ -502,7 +535,7 @@ RSpec.describe "bundle clean" do
gem "foo", :git => "#{lib_path("foo-1.0")}"
G
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
# mimic 7 length git revisions in Gemfile.lock
gemfile_lock = File.read(bundled_app("Gemfile.lock")).split("\n")
@@ -513,7 +546,7 @@ RSpec.describe "bundle clean" do
file.print gemfile_lock.join("\n")
end
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
bundle :clean
@@ -523,6 +556,8 @@ RSpec.describe "bundle clean" do
end
it "when using --force on system gems, it doesn't remove binaries" do
+ bundle! "config path.system true"
+
build_repo2
update_repo2 do
build_gem "bindir" do |s|
@@ -561,10 +596,8 @@ RSpec.describe "bundle clean" do
gem "bar", "1.0", :path => "#{relative_path}"
G
- bundle "install --path vendor/bundle"
- bundle :clean
-
- expect(exitstatus).to eq(0) if exitstatus
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
+ bundle! :clean
end
it "doesn't remove gems in dry-run mode with path set" do
@@ -575,7 +608,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -603,7 +636,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -633,7 +666,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
bundle "config dry_run false"
gemfile <<-G
@@ -663,7 +696,7 @@ RSpec.describe "bundle clean" do
gem "foo"
G
- bundle "install --path vendor/bundle --no-clean"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
gemfile <<-G
source "file://#{gem_repo1}"
@@ -672,8 +705,8 @@ RSpec.describe "bundle clean" do
gem "weakling"
G
- bundle "config auto_install 1"
- bundle :clean
+ bundle! "config auto_install 1"
+ bundle! :clean
expect(out).to include("Installing weakling 0.0.3")
should_have_gems "thin-1.0", "rack-1.0.0", "weakling-0.0.3"
should_not_have_gems "foo-1.0"
@@ -690,7 +723,7 @@ RSpec.describe "bundle clean" do
gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
G
- bundle! "install --path vendor/bundle"
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
expect(vendored_gems("bundler/gems/extensions")).to exist
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb
index a3ca696ec1..9e49357465 100644
--- a/spec/bundler/commands/config_spec.rb
+++ b/spec/bundler/commands/config_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe ".bundle/config" do
before :each do
@@ -46,7 +45,7 @@ RSpec.describe ".bundle/config" do
describe "BUNDLE_APP_CONFIG" do
it "can be moved with an environment variable" do
ENV["BUNDLE_APP_CONFIG"] = tmp("foo/bar").to_s
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
expect(bundled_app(".bundle")).not_to exist
expect(tmp("foo/bar/config")).to exist
@@ -58,7 +57,7 @@ RSpec.describe ".bundle/config" do
Dir.chdir bundled_app("omg")
ENV["BUNDLE_APP_CONFIG"] = "../foo"
- bundle "install --path vendor/bundle"
+ bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
expect(bundled_app(".bundle")).not_to exist
expect(bundled_app("../foo/config")).to exist
@@ -267,7 +266,7 @@ RSpec.describe ".bundle/config" do
expect(out).to eq "bar=value"
end
- it "preferes local config over global" do
+ it "prefers local config over global" do
bundle "config --local bar value2"
bundle "config --global bar value"
bundle "config bar --parseable"
diff --git a/spec/bundler/commands/console_spec.rb b/spec/bundler/commands/console_spec.rb
index de14b6db5f..9bf66e8f5b 100644
--- a/spec/bundler/commands/console_spec.rb
+++ b/spec/bundler/commands/console_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
-require "spec_helper"
-RSpec.describe "bundle console" do
+RSpec.describe "bundle console", :bundler => "< 2" do
before :each do
install_gemfile <<-G
source "file://#{gem_repo1}"
diff --git a/spec/bundler/commands/doctor_spec.rb b/spec/bundler/commands/doctor_spec.rb
index 7c6e48ce19..2572d4ff4d 100644
--- a/spec/bundler/commands/doctor_spec.rb
+++ b/spec/bundler/commands/doctor_spec.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require "spec_helper"
+
require "stringio"
require "bundler/cli"
require "bundler/cli/doctor"
@@ -17,45 +17,42 @@ RSpec.describe "bundle doctor" do
end
it "exits with no message if the installed gem has no C extensions" do
- gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
G
- bundle :install
- Bundler::CLI::Doctor.new({}).run
+ expect { Bundler::CLI::Doctor.new({}).run }.not_to raise_error
expect(@stdout.string).to be_empty
end
it "exits with no message if the installed gem's C extension dylib breakage is fine" do
- gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
G
- bundle :install
doctor = Bundler::CLI::Doctor.new({})
expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"]
expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/lib/libSystem.dylib"]
allow(File).to receive(:exist?).and_call_original
allow(File).to receive(:exist?).with("/usr/lib/libSystem.dylib").and_return(true)
- doctor.run
+ expect { doctor.run }.not_to(raise_error, @stdout.string)
expect(@stdout.string).to be_empty
end
it "exits with a message if one of the linked libraries is missing" do
- gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
G
- bundle :install
doctor = Bundler::CLI::Doctor.new({})
expect(doctor).to receive(:bundles_for_gem).exactly(2).times.and_return ["/path/to/rack/rack.bundle"]
expect(doctor).to receive(:dylibs).exactly(2).times.and_return ["/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib"]
allow(File).to receive(:exist?).and_call_original
allow(File).to receive(:exist?).with("/usr/local/opt/icu4c/lib/libicui18n.57.1.dylib").and_return(false)
- expect { doctor.run }.to raise_error Bundler::ProductionError, strip_whitespace(<<-E).strip
+ expect { doctor.run }.to raise_error(Bundler::ProductionError, strip_whitespace(<<-E).strip), @stdout.string
The following gems are missing OS dependencies:
* bundler: /usr/local/opt/icu4c/lib/libicui18n.57.1.dylib
* rack: /usr/local/opt/icu4c/lib/libicui18n.57.1.dylib
diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb
index 7736adefe1..077e1b03a2 100644
--- a/spec/bundler/commands/exec_spec.rb
+++ b/spec/bundler/commands/exec_spec.rb
@@ -1,10 +1,9 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle exec" do
- let(:system_gems_to_install) { %w(rack-1.0.0 rack-0.9.1) }
+ let(:system_gems_to_install) { %w[rack-1.0.0 rack-0.9.1] }
before :each do
- system_gems(system_gems_to_install)
+ system_gems(system_gems_to_install, :path => :bundle_path)
end
it "activates the correct gem" do
@@ -138,7 +137,7 @@ RSpec.describe "bundle exec" do
end
it "handles gems installed with --without" do
- install_gemfile <<-G, :without => :middleware
+ install_gemfile <<-G, forgotten_command_line_options(:without => "middleware")
source "file://#{gem_repo1}"
gem "rack" # rack 0.9.1 and 1.0 exist
@@ -217,6 +216,7 @@ RSpec.describe "bundle exec" do
end
it "raises a helpful error when exec'ing to something outside of the bundle", :ruby_repo, :rubygems => ">= 2.5.2" do
+ bundle! "config clean false" # want to keep the rackup binstub
install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "with_license"
@@ -224,7 +224,7 @@ RSpec.describe "bundle exec" do
[true, false].each do |l|
bundle! "config disable_exec_load #{l}"
bundle "exec rackup"
- expect(err).to include "can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?"
+ expect(last_command.stderr).to include "can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?"
end
end
@@ -238,7 +238,7 @@ RSpec.describe "bundle exec" do
[true, false].each do |l|
bundle! "config disable_exec_load #{l}"
bundle "exec rackup"
- expect(err).to include "rack is not part of the bundle. Add it to your Gemfile."
+ expect(last_command.stderr).to include "rack is not part of the bundle. Add it to your Gemfile."
end
end
@@ -518,8 +518,8 @@ RSpec.describe "bundle exec" do
it "like a normally executed executable" do
subject
expect(exitstatus).to eq(exit_code) if exitstatus
- expect(err).to eq(expected_err)
- expect(out).to eq(expected)
+ expect(last_command.stderr).to eq(expected_err)
+ expect(last_command.stdout).to eq(expected)
end
end
@@ -538,7 +538,27 @@ RSpec.describe "bundle exec" do
end
end
- context "the executable is empty" do
+ context "the executable exits by SignalException" do
+ let(:executable) do
+ ex = super()
+ ex << "\n"
+ if LessThanProc.with(RUBY_VERSION).call("1.9")
+ # Ruby < 1.9 needs a flush for a exit by signal, later
+ # rubies do not
+ ex << "STDOUT.flush\n"
+ end
+ ex << "raise SignalException, 'SIGTERM'\n"
+ ex
+ end
+ let(:exit_code) do
+ # signal mask 128 + plus signal 15 -> TERM
+ # this is specified by C99
+ 128 + 15
+ end
+ it_behaves_like "it runs"
+ end
+
+ context "the executable is empty", :bundler => "< 2" do
let(:executable) { "" }
let(:exit_code) { 0 }
@@ -553,7 +573,16 @@ RSpec.describe "bundle exec" do
end
end
- context "the executable raises" do
+ context "the executable is empty", :bundler => "2" do
+ let(:executable) { "" }
+
+ let(:exit_code) { 0 }
+ let(:expected_err) { "#{path} is empty" }
+ let(:expected) { "" }
+ it_behaves_like "it runs"
+ end
+
+ context "the executable raises", :bundler => "< 2" do
let(:executable) { super() << "\nraise 'ERROR'" }
let(:exit_code) { 1 }
let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" }
@@ -564,12 +593,22 @@ RSpec.describe "bundle exec" do
it_behaves_like "it runs"
end
+ context "the executable raises", :bundler => "2" do
+ let(:executable) { super() << "\nraise 'ERROR'" }
+ let(:exit_code) { 1 }
+ let(:expected_err) do
+ "bundler: failed to load command: #{path} (#{path})" \
+ "\nRuntimeError: ERROR\n #{path}:10:in `<top (required)>'"
+ end
+ it_behaves_like "it runs"
+ end
+
context "when the file uses the current ruby shebang", :ruby_repo do
let(:shebang) { "#!#{Gem.ruby}" }
it_behaves_like "it runs"
end
- context "when Bundler.setup fails" do
+ context "when Bundler.setup fails", :bundler => "< 2" do
before do
gemfile <<-G
gem 'rack', '2'
@@ -586,6 +625,24 @@ RSpec.describe "bundle exec" do
it_behaves_like "it runs"
end
+ context "when Bundler.setup fails", :bundler => "2" do
+ before do
+ gemfile <<-G
+ gem 'rack', '2'
+ G
+ ENV["BUNDLER_FORCE_TTY"] = "true"
+ end
+
+ let(:exit_code) { Bundler::GemNotFound.new.status_code }
+ let(:expected) { <<-EOS.strip }
+\e[31mCould not find gem 'rack (= 2)' in locally installed gems.
+The source contains 'rack' at: 1.0.0\e[0m
+\e[33mRun `bundle install` to install missing gems.\e[0m
+ EOS
+
+ it_behaves_like "it runs"
+ end
+
context "when the executable exits non-zero via at_exit" do
let(:executable) { super() + "\n\nat_exit { $! ? raise($!) : exit(1) }" }
let(:exit_code) { 1 }
@@ -729,7 +786,7 @@ __FILE__: #{path.to_s.inspect}
# sanity check that we get the newer, custom version without bundler
sys_exec("#{Gem.ruby} #{file}")
- expect(err).to include("custom openssl should not be loaded")
+ expect(last_command.stderr).to include("custom openssl should not be loaded")
end
end
end
diff --git a/spec/bundler/commands/help_spec.rb b/spec/bundler/commands/help_spec.rb
index 6faeed058e..cd6f13756c 100644
--- a/spec/bundler/commands/help_spec.rb
+++ b/spec/bundler/commands/help_spec.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle help" do
- # Rubygems 1.4+ no longer load gem plugins so this test is no longer needed
+ # RubyGems 1.4+ no longer load gem plugins so this test is no longer needed
it "complains if older versions of bundler are installed", :rubygems => "< 1.4" do
system_gems "bundler-0.8.1"
diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb
index cdfea983dc..a9ab8fc210 100644
--- a/spec/bundler/commands/info_spec.rb
+++ b/spec/bundler/commands/info_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle info" do
context "info from specific gem in gemfile" do
diff --git a/spec/bundler/commands/init_spec.rb b/spec/bundler/commands/init_spec.rb
index 6ab7e25cc3..0441e62e13 100644
--- a/spec/bundler/commands/init_spec.rb
+++ b/spec/bundler/commands/init_spec.rb
@@ -1,10 +1,16 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle init" do
- it "generates a Gemfile" do
- bundle :init
- expect(bundled_app("Gemfile")).to exist
+ it "generates a Gemfile", :bundler => "< 2" do
+ bundle! :init
+ expect(out).to include("Writing new Gemfile")
+ expect(bundled_app("Gemfile")).to be_file
+ end
+
+ it "generates a gems.rb", :bundler => "2" do
+ bundle! :init
+ expect(out).to include("Writing new gems.rb")
+ expect(bundled_app("gems.rb")).to be_file
end
context "when a Gemfile already exists" do
@@ -24,7 +30,24 @@ RSpec.describe "bundle init" do
end
end
- context "given --gemspec option" do
+ context "when a gems.rb already exists" do
+ before do
+ create_file "gems.rb", <<-G
+ gem "rails"
+ G
+ end
+
+ it "does not change existing gem.rb files" do
+ expect { bundle :init }.not_to change { File.read(bundled_app("gems.rb")) }
+ end
+
+ it "notifies the user that an existing gems.rb already exists" do
+ bundle :init
+ expect(out).to include("gems.rb already exists")
+ end
+ end
+
+ context "given --gemspec option", :bundler => "< 2" do
let(:spec_file) { tmp.join("test.gemspec") }
it "should generate from an existing gemspec" do
@@ -40,7 +63,11 @@ RSpec.describe "bundle init" do
bundle :init, :gemspec => spec_file
- gemfile = bundled_app("Gemfile").read
+ gemfile = if Bundler::VERSION[0, 2] == "1."
+ bundled_app("Gemfile").read
+ else
+ bundled_app("gems.rb").read
+ end
expect(gemfile).to match(%r{source 'https://rubygems.org'})
expect(gemfile.scan(/gem "rack", "= 1.0.1"/).size).to eq(1)
expect(gemfile.scan(/gem "rspec", "= 1.2"/).size).to eq(1)
@@ -59,7 +86,65 @@ RSpec.describe "bundle init" do
end
bundle :init, :gemspec => spec_file
- expect(out).to include("There was an error while loading `test.gemspec`")
+ expect(last_command.bundler_err).to include("There was an error while loading `test.gemspec`")
+ end
+ end
+ end
+
+ context "when init_gems_rb setting is enabled" do
+ before { bundle "config init_gems_rb true" }
+
+ it "generates a gems.rb file" do
+ bundle :init
+ expect(bundled_app("gems.rb")).to exist
+ end
+
+ context "when gems.rb already exists" do
+ before do
+ create_file("gems.rb", <<-G)
+ gem "rails"
+ G
+ end
+
+ it "does not change existing Gemfiles" do
+ expect { bundle :init }.not_to change { File.read(bundled_app("gems.rb")) }
+ end
+
+ it "notifies the user that an existing gems.rb already exists" do
+ bundle :init
+ expect(out).to include("gems.rb already exists")
+ end
+ end
+
+ context "given --gemspec option", :bundler => "< 2" do
+ let(:spec_file) { tmp.join("test.gemspec") }
+
+ before do
+ File.open(spec_file, "w") do |file|
+ file << <<-S
+ Gem::Specification.new do |s|
+ s.name = 'test'
+ s.add_dependency 'rack', '= 1.0.1'
+ s.add_development_dependency 'rspec', '1.2'
+ end
+ S
+ end
+ end
+
+ it "should generate from an existing gemspec" do
+ bundle :init, :gemspec => spec_file
+
+ gemfile = bundled_app("gems.rb").read
+ expect(gemfile).to match(%r{source 'https://rubygems.org'})
+ expect(gemfile.scan(/gem "rack", "= 1.0.1"/).size).to eq(1)
+ expect(gemfile.scan(/gem "rspec", "= 1.2"/).size).to eq(1)
+ expect(gemfile.scan(/group :development/).size).to eq(1)
+ end
+
+ it "prints message to user" do
+ bundle :init, :gemspec => spec_file
+
+ expect(out).to include("Writing new gems.rb")
end
end
end
diff --git a/spec/bundler/commands/inject_spec.rb b/spec/bundler/commands/inject_spec.rb
index dd0f1348cc..6c1994b59d 100644
--- a/spec/bundler/commands/inject_spec.rb
+++ b/spec/bundler/commands/inject_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
-require "spec_helper"
-RSpec.describe "bundle inject" do
+RSpec.describe "bundle inject", :bundler => "< 2" do
before :each do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -80,7 +79,11 @@ Usage: "bundle inject GEM VERSION"
context "when frozen" do
before do
bundle "install"
- bundle "config --local frozen 1"
+ if Bundler.feature_flag.bundler_2_mode?
+ bundle! "config --local deployment true"
+ else
+ bundle! "config --local frozen true"
+ end
end
it "injects anyway" do
@@ -97,7 +100,7 @@ Usage: "bundle inject GEM VERSION"
it "restores frozen afterwards" do
bundle "inject 'rack-obama' '> 0'"
config = YAML.load(bundled_app(".bundle/config").read)
- expect(config["BUNDLE_FROZEN"]).to eq("1")
+ expect(config["BUNDLE_DEPLOYMENT"] || config["BUNDLE_FROZEN"]).to eq("true")
end
it "doesn't allow Gemfile changes" do
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb
index 2d67a39f1e..4cb8584633 100644
--- a/spec/bundler/commands/install_spec.rb
+++ b/spec/bundler/commands/install_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle install with gem sources" do
describe "the simple case" do
@@ -17,8 +16,7 @@ RSpec.describe "bundle install with gem sources" do
raise StandardError, "FAIL"
G
- expect(err).to lack_errors
- expect(out).to match(/StandardError, "FAIL"/)
+ expect(last_command.bundler_err).to include('StandardError, "FAIL"')
expect(bundled_app("Gemfile.lock")).not_to exist
end
@@ -31,13 +29,23 @@ RSpec.describe "bundle install with gem sources" do
expect(bundled_app("Gemfile.lock")).to exist
end
- it "does not create ./.bundle by default" do
+ it "does not create ./.bundle by default", :bundler => "< 2" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
- bundle :install # can't use install_gemfile since it sets retry
+ bundle! :install # can't use install_gemfile since it sets retry
+ expect(bundled_app(".bundle")).not_to exist
+ end
+
+ it "does not create ./.bundle by default when installing to system gems" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle! :install, :env => { "BUNDLE_PATH__SYSTEM" => true } # can't use install_gemfile since it sets retry
expect(bundled_app(".bundle")).not_to exist
end
@@ -168,7 +176,7 @@ RSpec.describe "bundle install with gem sources" do
end
it "does not reinstall any gem that is already available locally" do
- system_gems "activesupport-2.3.2"
+ system_gems "activesupport-2.3.2", :path => :bundle_path
build_repo2 do
build_gem "activesupport", "2.3.2" do |s|
@@ -185,7 +193,7 @@ RSpec.describe "bundle install with gem sources" do
end
it "works when the gemfile specifies gems that only exist in the system" do
- build_gem "foo", :to_system => true
+ build_gem "foo", :to_bundle => true
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -196,7 +204,7 @@ RSpec.describe "bundle install with gem sources" do
end
it "prioritizes local gems over remote gems" do
- build_gem "rack", "1.0.0", :to_system => true do |s|
+ build_gem "rack", "1.0.0", :to_bundle => true do |s|
s.add_dependency "activesupport", "2.3.5"
end
@@ -263,26 +271,26 @@ RSpec.describe "bundle install with gem sources" do
end
it "works" do
- bundle "install --path vendor"
+ bundle "install", forgotten_command_line_options(:path => "vendor")
expect(the_bundle).to include_gems "rack 1.0"
end
- it "allows running bundle install --system without deleting foo" do
- bundle "install --path vendor"
- bundle "install --system"
+ it "allows running bundle install --system without deleting foo", :bundler => "< 2" do
+ bundle "install", forgotten_command_line_options(:path => "vendor")
+ bundle "install", forgotten_command_line_options(:system => true)
FileUtils.rm_rf(bundled_app("vendor"))
expect(the_bundle).to include_gems "rack 1.0"
end
- it "allows running bundle install --system after deleting foo" do
- bundle "install --path vendor"
+ it "allows running bundle install --system after deleting foo", :bundler => "< 2" do
+ bundle "install", forgotten_command_line_options(:path => "vendor")
FileUtils.rm_rf(bundled_app("vendor"))
- bundle "install --system"
+ bundle "install", forgotten_command_line_options(:system => true)
expect(the_bundle).to include_gems "rack 1.0"
end
end
- it "finds gems in multiple sources" do
+ it "finds gems in multiple sources", :bundler => "< 2" do
build_repo2
update_repo2
@@ -316,9 +324,9 @@ RSpec.describe "bundle install with gem sources" do
it "gracefully handles error when rubygems server is unavailable" do
install_gemfile <<-G, :artifice => nil
source "file://#{gem_repo1}"
- source "http://localhost:9384"
-
- gem 'foo'
+ source "http://localhost:9384" do
+ gem 'foo'
+ end
G
bundle :install, :artifice => nil
@@ -345,9 +353,8 @@ RSpec.describe "bundle install with gem sources" do
gem "ajp-rails", "0.0.0"
G
- expect(out).not_to match(/Error Report/i)
- expect(err).not_to match(/Error Report/i)
- expect(out).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue.").
+ expect(last_command.stdboth).not_to match(/Error Report/i)
+ expect(last_command.bundler_err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue.").
and include("Make sure that `gem install ajp-rails -v '0.0.0'` succeeds before bundling.")
end
@@ -382,10 +389,10 @@ RSpec.describe "bundle install with gem sources" do
context "and using an unsupported Ruby version" do
it "prints an error" do
install_gemfile <<-G
- ::RUBY_VERSION = '1.8.7'
- ruby '~> 2.1'
+ ::RUBY_VERSION = '2.0.1'
+ ruby '~> 2.2'
G
- expect(out).to include("Your Ruby version is 1.8.7, but your Gemfile specified ~> 2.1")
+ expect(out).to include("Your Ruby version is 2.0.1, but your Gemfile specified ~> 2.2")
end
end
@@ -404,7 +411,7 @@ RSpec.describe "bundle install with gem sources" do
specs:
PLATFORMS
- ruby
+ #{lockfile_platforms}
DEPENDENCIES
@@ -428,7 +435,7 @@ RSpec.describe "bundle install with gem sources" do
specs:
PLATFORMS
- ruby
+ #{lockfile_platforms}
DEPENDENCIES
@@ -489,17 +496,34 @@ RSpec.describe "bundle install with gem sources" do
it "should display a proper message to explain the problem" do
FileUtils.chmod(0o500, bundled_app("vendor"))
- bundle :install, :path => "vendor"
+ bundle :install, forgotten_command_line_options(:path => "vendor")
expect(out).to include(bundled_app("vendor").to_s)
expect(out).to include("grant write permissions")
end
end
+ context "after installing with --standalone" do
+ before do
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+ forgotten_command_line_options(:path => "bundle")
+ bundle! "install", :standalone => true
+ end
+
+ it "includes the standalone path" do
+ bundle! "binstubs rack", :standalone => true
+ standalone_line = File.read(bundled_app("bin/rackup")).each_line.find {|line| line.include? "$:.unshift" }.strip
+ expect(standalone_line).to eq %($:.unshift File.expand_path "../../bundle", path.realpath)
+ end
+ end
+
describe "when bundle install is executed with unencoded authentication" do
before do
gemfile <<-G
source 'https://rubygems.org/'
- gem 'bundler'
+ gem "."
G
end
diff --git a/spec/bundler/commands/issue_spec.rb b/spec/bundler/commands/issue_spec.rb
index 056ef0f300..04c575130e 100644
--- a/spec/bundler/commands/issue_spec.rb
+++ b/spec/bundler/commands/issue_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle issue" do
it "exits with a message" do
diff --git a/spec/bundler/commands/licenses_spec.rb b/spec/bundler/commands/licenses_spec.rb
index 0ee1a46945..144931fb27 100644
--- a/spec/bundler/commands/licenses_spec.rb
+++ b/spec/bundler/commands/licenses_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle licenses" do
before :each do
diff --git a/spec/bundler/commands/list_spec.rb b/spec/bundler/commands/list_spec.rb
new file mode 100644
index 0000000000..0ea70f015c
--- /dev/null
+++ b/spec/bundler/commands/list_spec.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+RSpec.describe "bundle list", :bundler => "2" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+ end
+
+ context "with name-only option" do
+ it "prints only the name of the gems in the bundle" do
+ bundle "list --name-only"
+ expect(out).to eq "rack"
+ end
+ end
+
+ context "when no gems are in the gemfile" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ G
+ end
+
+ it "prints message saying no gems are in the bundle" do
+ bundle "list"
+ expect(out).to include("No gems in the Gemfile")
+ end
+ end
+
+ it "lists gems installed in the bundle" do
+ bundle "list"
+ expect(out).to include(" * rack (1.0.0)")
+ end
+
+ it "aliases the ls command to list" do
+ bundle "ls"
+ expect(out).to include("Gems included by the bundle")
+ end
+end
diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb
index 5c15b6a7f6..b16a828cad 100644
--- a/spec/bundler/commands/lock_spec.rb
+++ b/spec/bundler/commands/lock_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle lock" do
def strip_lockfile(lockfile)
@@ -44,7 +43,7 @@ RSpec.describe "bundle lock" do
with_license (1.0)
PLATFORMS
- #{local}
+ #{lockfile_platforms}
DEPENDENCIES
foo
@@ -59,7 +58,7 @@ RSpec.describe "bundle lock" do
it "prints a lockfile when there is no existing lockfile with --print" do
bundle "lock --print"
- expect(out).to include(@lockfile)
+ expect(out).to eq(@lockfile)
end
it "prints a lockfile when there is an existing lockfile with --print" do
@@ -87,7 +86,7 @@ RSpec.describe "bundle lock" do
it "does not fetch remote specs when using the --local option" do
bundle "lock --update --local"
- expect(out).to include("sources listed in your Gemfile")
+ expect(out).to match(/sources listed in your Gemfile|installed locally/)
end
it "writes to a custom location using --lockfile" do
@@ -120,17 +119,17 @@ RSpec.describe "bundle lock" do
context "conservative updates" do
before do
build_repo4 do
- build_gem "foo", %w(1.4.3 1.4.4) do |s|
+ build_gem "foo", %w[1.4.3 1.4.4] do |s|
s.add_dependency "bar", "~> 2.0"
end
- build_gem "foo", %w(1.4.5 1.5.0) do |s|
+ build_gem "foo", %w[1.4.5 1.5.0] do |s|
s.add_dependency "bar", "~> 2.1"
end
- build_gem "foo", %w(1.5.1) do |s|
+ build_gem "foo", %w[1.5.1] do |s|
s.add_dependency "bar", "~> 3.0"
end
- build_gem "bar", %w(2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0)
- build_gem "qux", %w(1.0.0 1.0.1 1.1.0 2.0.0)
+ build_gem "bar", %w[2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0]
+ build_gem "qux", %w[1.0.0 1.0.1 1.1.0 2.0.0]
end
# establish a lockfile set to 1.4.3
@@ -153,13 +152,13 @@ RSpec.describe "bundle lock" do
it "single gem updates dependent gem to minor" do
bundle "lock --update foo --patch"
- expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w(foo-1.4.5 bar-2.1.1 qux-1.0.0).sort)
+ expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[foo-1.4.5 bar-2.1.1 qux-1.0.0].sort)
end
it "minor preferred with strict" do
bundle "lock --update --minor --strict"
- expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w(foo-1.5.0 bar-2.1.1 qux-1.1.0).sort)
+ expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[foo-1.5.0 bar-2.1.1 qux-1.1.0].sort)
end
end
@@ -167,13 +166,13 @@ RSpec.describe "bundle lock" do
bundle! "lock --add-platform java x86-mingw32"
lockfile = Bundler::LockfileParser.new(read_lockfile)
- expect(lockfile.platforms).to eq([java, local, mingw])
+ expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq)
end
it "supports adding the `ruby` platform" do
bundle! "lock --add-platform ruby"
lockfile = Bundler::LockfileParser.new(read_lockfile)
- expect(lockfile.platforms).to eq([local, "ruby"].uniq)
+ expect(lockfile.platforms).to match_array(local_platforms.unshift("ruby").uniq)
end
it "warns when adding an unknown platform" do
@@ -185,17 +184,17 @@ RSpec.describe "bundle lock" do
bundle! "lock --add-platform java x86-mingw32"
lockfile = Bundler::LockfileParser.new(read_lockfile)
- expect(lockfile.platforms).to eq([java, local, mingw])
+ expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq)
bundle! "lock --remove-platform java"
lockfile = Bundler::LockfileParser.new(read_lockfile)
- expect(lockfile.platforms).to eq([local, mingw])
+ expect(lockfile.platforms).to match_array(local_platforms.unshift(mingw).uniq)
end
it "errors when removing all platforms" do
- bundle "lock --remove-platform #{local}"
- expect(out).to include("Removing all platforms from the bundle is not allowed")
+ bundle "lock --remove-platform #{local_platforms.join(" ")}"
+ expect(last_command.bundler_err).to include("Removing all platforms from the bundle is not allowed")
end
# from https://github.com/bundler/bundler/issues/4896
@@ -221,7 +220,7 @@ RSpec.describe "bundle lock" do
# we need all these versions to get the sorting the same as it would be
# pulling from rubygems.org
- %w(0.8.3 0.8.2 0.8.1 0.8.0).each do |v|
+ %w[0.8.3 0.8.2 0.8.1 0.8.0].each do |v|
build_gem "win32-process", v do |s|
s.add_dependency "ffi", ">= 1.0.0"
end
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index e9c19005eb..dcd89391a4 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle gem" do
def reset!
@@ -166,10 +165,10 @@ RSpec.describe "bundle gem" do
expect(bundled_app("test_gem/.git")).to exist
end
- context "when git is not avaiable" do
+ context "when git is not available" do
let(:gem_name) { "test_gem" }
- # This spec cannot have `git` avaiable in the test env
+ # This spec cannot have `git` available in the test env
before do
load_paths = [lib, spec]
load_path_str = "-I#{load_paths.join(File::PATH_SEPARATOR)}"
@@ -191,8 +190,6 @@ RSpec.describe "bundle gem" do
end
it "generates a valid gemspec" do
- system_gems ["rake-10.0.2"]
-
in_app_root
bundle "gem newgem --bin"
@@ -214,12 +211,11 @@ RSpec.describe "bundle gem" do
end
Dir.chdir(bundled_app("newgem")) do
- bundle "exec rake build"
+ system_gems ["rake-10.0.2"], :path => :bundle_path
+ bundle! "exec rake build"
end
- expect(exitstatus).to be_zero if exitstatus
- expect(out).not_to include("ERROR")
- expect(err).not_to include("ERROR")
+ expect(last_command.stdboth).not_to include("ERROR")
end
context "gem naming with relative paths" do
@@ -785,24 +781,24 @@ RSpec.describe "bundle gem" do
it "fails gracefully with a ." do
bundle "gem foo.gemspec"
- expect(out).to end_with("Invalid gem name foo.gemspec -- `Foo.gemspec` is an invalid constant name")
+ expect(last_command.bundler_err).to end_with("Invalid gem name foo.gemspec -- `Foo.gemspec` is an invalid constant name")
end
it "fails gracefully with a ^" do
bundle "gem ^"
- expect(out).to end_with("Invalid gem name ^ -- `^` is an invalid constant name")
+ expect(last_command.bundler_err).to end_with("Invalid gem name ^ -- `^` is an invalid constant name")
end
it "fails gracefully with a space" do
bundle "gem 'foo bar'"
- expect(out).to end_with("Invalid gem name foo bar -- `Foo bar` is an invalid constant name")
+ expect(last_command.bundler_err).to end_with("Invalid gem name foo bar -- `Foo bar` is an invalid constant name")
end
it "fails gracefully when multiple names are passed" do
bundle "gem foo bar baz"
- expect(out).to eq(<<-E.strip)
+ expect(last_command.bundler_err).to eq(<<-E.strip)
ERROR: "bundle gem" was called with arguments ["foo", "bar", "baz"]
-Usage: "bundle gem GEM [OPTIONS]"
+Usage: "bundle gem NAME [OPTIONS]"
E
end
end
@@ -890,8 +886,8 @@ Usage: "bundle gem GEM [OPTIONS]"
in_app_root do
FileUtils.touch("conflict-foobar")
end
- output = bundle "gem conflict-foobar"
- expect(output).to include("Errno::ENOTDIR")
+ bundle "gem conflict-foobar"
+ expect(last_command.bundler_err).to include("Errno::ENOTDIR")
expect(exitstatus).to eql(32) if exitstatus
end
end
@@ -902,7 +898,7 @@ Usage: "bundle gem GEM [OPTIONS]"
FileUtils.mkdir_p("conflict-foobar/Gemfile")
end
bundle! "gem conflict-foobar"
- expect(out).to include("file_clash conflict-foobar/Gemfile").
+ expect(last_command.stdout).to include("file_clash conflict-foobar/Gemfile").
and include "Initializing git repo in #{bundled_app("conflict-foobar")}"
end
end
diff --git a/spec/bundler/commands/open_spec.rb b/spec/bundler/commands/open_spec.rb
index 6872e859d2..5cab846fb5 100644
--- a/spec/bundler/commands/open_spec.rb
+++ b/spec/bundler/commands/open_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle open" do
before :each do
diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb
index c6b6c9f59e..f0ad136c98 100644
--- a/spec/bundler/commands/outdated_spec.rb
+++ b/spec/bundler/commands/outdated_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle outdated" do
before :each do
@@ -192,6 +191,8 @@ RSpec.describe "bundle outdated" do
build_gem "activesupport", "2.3.4"
end
+ bundle! "config clean false"
+
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "activesupport", "2.3.4"
@@ -334,7 +335,7 @@ RSpec.describe "bundle outdated" do
G
update_repo2 do
- build_gem "activesupport", %w(2.4.0 3.0.0)
+ build_gem "activesupport", %w[2.4.0 3.0.0]
build_gem "weakling", "0.0.5"
end
@@ -352,7 +353,7 @@ RSpec.describe "bundle outdated" do
G
update_repo2 do
- build_gem "activesupport", %w(2.3.9)
+ build_gem "activesupport", %w[2.3.9]
build_gem "weakling", "0.1.5"
end
@@ -370,7 +371,7 @@ RSpec.describe "bundle outdated" do
G
update_repo2 do
- build_gem "activesupport", %w(2.4.0 2.5.0)
+ build_gem "activesupport", %w[2.4.0 2.5.0]
build_gem "weakling", "1.1.5"
end
@@ -406,9 +407,9 @@ RSpec.describe "bundle outdated" do
expect(out).to include("Installing foo 1.0")
end
- context "after bundle install --deployment" do
+ context "after bundle install --deployment", :bundler => "< 2" do
before do
- install_gemfile <<-G, :deployment => true
+ install_gemfile <<-G, forgotten_command_line_options(:deployment => true)
source "file://#{gem_repo2}"
gem "rack"
@@ -420,7 +421,7 @@ RSpec.describe "bundle outdated" do
update_repo2 { build_gem "activesupport", "3.0" }
bundle "outdated"
- expect(exitstatus).to_not be_zero if exitstatus
+ expect(last_command).to be_failure
expect(out).to include("You are trying to check outdated gems in deployment mode.")
expect(out).to include("Run `bundle outdated` elsewhere.")
expect(out).to include("If this is a development machine, remove the ")
@@ -428,6 +429,29 @@ RSpec.describe "bundle outdated" do
end
end
+ context "after bundle config deployment true" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+
+ gem "rack"
+ gem "foo"
+ G
+ bundle! "config deployment true"
+ end
+
+ it "outputs a helpful message about being in deployment mode" do
+ update_repo2 { build_gem "activesupport", "3.0" }
+
+ bundle "outdated"
+ expect(last_command).to be_failure
+ expect(out).to include("You are trying to check outdated gems in deployment mode.")
+ expect(out).to include("Run `bundle outdated` elsewhere.")
+ expect(out).to include("If this is a development machine, remove the ")
+ expect(out).to include("Gemfile freeze\nby running `bundle config --delete deployment`.")
+ end
+ end
+
context "update available for a gem on a different platform" do
before do
install_gemfile <<-G
@@ -629,9 +653,9 @@ RSpec.describe "bundle outdated" do
context "without update-strict" do
before do
build_repo4 do
- build_gem "patch", %w(1.0.0 1.0.1)
- build_gem "minor", %w(1.0.0 1.0.1 1.1.0)
- build_gem "major", %w(1.0.0 1.0.1 1.1.0 2.0.0)
+ build_gem "patch", %w[1.0.0 1.0.1]
+ build_gem "minor", %w[1.0.0 1.0.1 1.1.0]
+ build_gem "major", %w[1.0.0 1.0.1 1.1.0 2.0.0]
end
# establish a lockfile set to 1.0.0
@@ -689,17 +713,17 @@ RSpec.describe "bundle outdated" do
context "with update-strict" do
before do
build_repo4 do
- build_gem "foo", %w(1.4.3 1.4.4) do |s|
+ build_gem "foo", %w[1.4.3 1.4.4] do |s|
s.add_dependency "bar", "~> 2.0"
end
- build_gem "foo", %w(1.4.5 1.5.0) do |s|
+ build_gem "foo", %w[1.4.5 1.5.0] do |s|
s.add_dependency "bar", "~> 2.1"
end
- build_gem "foo", %w(1.5.1) do |s|
+ build_gem "foo", %w[1.5.1] do |s|
s.add_dependency "bar", "~> 3.0"
end
- build_gem "bar", %w(2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0)
- build_gem "qux", %w(1.0.0 1.1.0 2.0.0)
+ build_gem "bar", %w[2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0]
+ build_gem "qux", %w[1.0.0 1.1.0 2.0.0]
end
# establish a lockfile set to 1.4.3
diff --git a/spec/bundler/commands/package_spec.rb b/spec/bundler/commands/package_spec.rb
index 86c09db3ca..6351909bc7 100644
--- a/spec/bundler/commands/package_spec.rb
+++ b/spec/bundler/commands/package_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle package" do
context "with --gemfile" do
@@ -25,7 +24,7 @@ RSpec.describe "bundle package" do
gem 'bundler'
D
- bundle "package --all"
+ bundle :package, forgotten_command_line_options([:all, :cache_all] => true)
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
@@ -55,7 +54,7 @@ RSpec.describe "bundle package" do
gemspec
D
- bundle! "package --all"
+ bundle! :package, forgotten_command_line_options([:all, :cache_all] => true)
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
@@ -86,7 +85,7 @@ RSpec.describe "bundle package" do
gemspec
D
- bundle! "package --all"
+ bundle! :package, forgotten_command_line_options([:all, :cache_all] => true)
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
@@ -130,7 +129,7 @@ RSpec.describe "bundle package" do
gemspec :name => 'mygem_test'
D
- bundle! "package --all"
+ bundle! :package, forgotten_command_line_options([:all, :cache_all] => true)
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
@@ -142,14 +141,14 @@ RSpec.describe "bundle package" do
end
end
- context "with --path" do
+ context "with --path", :bundler => "< 2" do
it "sets root directory for gems" do
gemfile <<-D
source "file://#{gem_repo1}"
gem 'rack'
D
- bundle "package --path=#{bundled_app("test")}"
+ bundle! :package, forgotten_command_line_options(:path => bundled_app("test"))
expect(the_bundle).to include_gems "rack 1.0.0"
expect(bundled_app("test/vendor/cache/")).to exist
@@ -163,7 +162,7 @@ RSpec.describe "bundle package" do
gem 'rack'
D
- bundle "package --no-install"
+ bundle! "package --no-install"
expect(the_bundle).not_to include_gems "rack 1.0.0"
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
@@ -175,8 +174,8 @@ RSpec.describe "bundle package" do
gem 'rack'
D
- bundle "package --no-install"
- bundle "install"
+ bundle! "package --no-install"
+ bundle! "install"
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -203,9 +202,10 @@ RSpec.describe "bundle package" do
bundle "install"
end
- subject { bundle "package --frozen" }
+ subject { bundle :package, forgotten_command_line_options(:frozen => true) }
it "tries to install with frozen" do
+ bundle! "config deployment true"
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -217,7 +217,7 @@ RSpec.describe "bundle package" do
expect(out).to include("You have added to the Gemfile")
expect(out).to include("* rack-obama")
bundle "env"
- expect(out).to include("frozen")
+ expect(out).to include("frozen").or include("deployment")
end
end
end
@@ -241,16 +241,16 @@ RSpec.describe "bundle install with gem sources" do
it "does not hit the remote at all" do
build_repo2
- install_gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "rack"
G
- bundle :pack
+ bundle! :pack
simulate_new_machine
FileUtils.rm_rf gem_repo2
- bundle "install --deployment"
+ bundle! :install, forgotten_command_line_options(:deployment => true, :path => "vendor/bundle")
expect(the_bundle).to include_gems "rack 1.0.0"
end
diff --git a/spec/bundler/commands/pristine_spec.rb b/spec/bundler/commands/pristine_spec.rb
index 3aca313e0f..ee75934380 100644
--- a/spec/bundler/commands/pristine_spec.rb
+++ b/spec/bundler/commands/pristine_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require "spec_helper"
-require "fileutils"
+
+require "bundler/vendored_fileutils"
RSpec.describe "bundle pristine", :ruby_repo do
before :each do
@@ -28,7 +28,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
G
end
- context "when sourced from Rubygems" do
+ context "when sourced from RubyGems" do
it "reverts using cached .gem file" do
spec = Bundler.definition.specs["weakling"].first
changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt")
@@ -55,12 +55,23 @@ RSpec.describe "bundle pristine", :ruby_repo do
changed_file = Pathname.new(spec.full_gem_path).join("lib/foo.rb")
diff = "#Pristine spec changes"
- File.open(changed_file, "a") {|f| f.puts "#Pristine spec changes" }
+ File.open(changed_file, "a") {|f| f.puts diff }
expect(File.read(changed_file)).to include(diff)
- bundle "pristine"
+ bundle! "pristine"
expect(File.read(changed_file)).to_not include(diff)
end
+
+ it "removes added files" do
+ spec = Bundler.definition.specs["foo"].first
+ changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt")
+
+ FileUtils.touch(changes_txt)
+ expect(changes_txt).to be_file
+
+ bundle! "pristine"
+ expect(changes_txt).not_to be_file
+ end
end
context "when sourced from gemspec" do
@@ -69,7 +80,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
changed_file = Pathname.new(spec.full_gem_path).join("lib/baz.rb")
diff = "#Pristine spec changes"
- File.open(changed_file, "a") {|f| f.puts "#Pristine spec changes" }
+ File.open(changed_file, "a") {|f| f.puts diff }
expect(File.read(changed_file)).to include(diff)
bundle "pristine"
@@ -102,6 +113,39 @@ RSpec.describe "bundle pristine", :ruby_repo do
end
end
+ context "when passing a list of gems to pristine" do
+ it "resets them" do
+ foo = Bundler.definition.specs["foo"].first
+ foo_changes_txt = Pathname.new(foo.full_gem_path).join("lib/changes.txt")
+ FileUtils.touch(foo_changes_txt)
+ expect(foo_changes_txt).to be_file
+
+ bar = Bundler.definition.specs["bar"].first
+ bar_changes_txt = Pathname.new(bar.full_gem_path).join("lib/changes.txt")
+ FileUtils.touch(bar_changes_txt)
+ expect(bar_changes_txt).to be_file
+
+ weakling = Bundler.definition.specs["weakling"].first
+ weakling_changes_txt = Pathname.new(weakling.full_gem_path).join("lib/changes.txt")
+ FileUtils.touch(weakling_changes_txt)
+ expect(weakling_changes_txt).to be_file
+
+ bundle! "pristine foo bar weakling"
+
+ expect(out).to include("Cannot pristine bar (1.0). Gem is sourced from local path.").
+ and include("Installing weakling 1.0")
+
+ expect(weakling_changes_txt).not_to be_file
+ expect(foo_changes_txt).not_to be_file
+ expect(bar_changes_txt).to be_file
+ end
+
+ it "raises when one of them is not in the lockfile" do
+ bundle "pristine abcabcabc"
+ expect(out).to include("Could not find gem 'abcabcabc'.")
+ end
+ end
+
context "when a build config exists for one of the gems" do
let(:very_simple_binary) { Bundler.definition.specs["very_simple_binary"].first }
let(:c_ext_dir) { Pathname.new(very_simple_binary.full_gem_path).join("ext") }
diff --git a/spec/bundler/commands/show_spec.rb b/spec/bundler/commands/show_spec.rb
index fc34831a72..adbf289fd0 100644
--- a/spec/bundler/commands/show_spec.rb
+++ b/spec/bundler/commands/show_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
-require "spec_helper"
-RSpec.describe "bundle show" do
+RSpec.describe "bundle show", :bundler => "< 2" do
context "with a standard Gemfile" do
before :each do
install_gemfile <<-G
@@ -32,15 +31,15 @@ RSpec.describe "bundle show" do
end
it "warns if path no longer exists on disk" do
- FileUtils.rm_rf("#{system_gem_path}/gems/rails-2.3.2")
+ FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2"))
bundle "show rails"
- expect(out).to match(/has been deleted/i)
- expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s)
+ expect(out).to match(/has been deleted/i).
+ and include(default_bundle_path("gems", "rails-2.3.2").to_s)
end
- it "prints the path to the running bundler" do
+ it "prints the path to the running bundler", :ruby_repo do
bundle "show bundler"
expect(out).to eq(root.to_s)
end
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
index 4992e428da..a8283cf593 100644
--- a/spec/bundler/commands/update_spec.rb
+++ b/spec/bundler/commands/update_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle update" do
before :each do
@@ -12,7 +11,7 @@ RSpec.describe "bundle update" do
G
end
- describe "with no arguments" do
+ describe "with no arguments", :bundler => "< 2" do
it "updates the entire bundle" do
update_repo2 do
build_gem "activesupport", "3.0"
@@ -35,6 +34,51 @@ RSpec.describe "bundle update" do
end
end
+ describe "with --all", :bundler => "2" do
+ it "updates the entire bundle" do
+ update_repo2 do
+ build_gem "activesupport", "3.0"
+ end
+
+ bundle! "update", :all => true
+ expect(out).to include("Bundle updated!")
+ expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
+ end
+
+ it "doesn't delete the Gemfile.lock file if something goes wrong" do
+ gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "activesupport"
+ gem "rack-obama"
+ exit!
+ G
+ bundle "update", :all => true
+ expect(bundled_app("Gemfile.lock")).to exist
+ end
+ end
+
+ context "when update_requires_all_flag is set" do
+ before { bundle! "config update_requires_all_flag true" }
+
+ it "errors when passed nothing" do
+ install_gemfile! ""
+ bundle :update
+ expect(out).to eq("To update everything, pass the `--all` flag.")
+ end
+
+ it "errors when passed --all and another option" do
+ install_gemfile! ""
+ bundle "update --all foo"
+ expect(out).to eq("Cannot specify --all along with specific options.")
+ end
+
+ it "updates everything when passed --all" do
+ install_gemfile! ""
+ bundle "update --all"
+ expect(out).to include("Bundle updated!")
+ end
+ end
+
describe "--quiet argument" do
it "hides UI messages" do
bundle "update --quiet"
@@ -101,7 +145,7 @@ RSpec.describe "bundle update" do
end
end
- bundle! "update"
+ bundle! "update", :all => bundle_update_requires_all?
expect(the_bundle).to include_gems("a 1.0", "b 1.0", "c 2.0")
end
@@ -112,13 +156,13 @@ RSpec.describe "bundle update" do
it "doesn't hit repo2" do
FileUtils.rm_rf(gem_repo2)
- bundle "update --local"
- expect(out).not_to match(/Fetching source index/)
+ bundle "update --local --all"
+ expect(out).not_to include("Fetching source index")
end
end
describe "with --group option" do
- it "should update only specifed group gems" do
+ it "should update only specified group gems" do
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "activesupport", :group => :development
@@ -154,46 +198,66 @@ RSpec.describe "bundle update" do
end
describe "in a frozen bundle" do
- it "should fail loudly" do
- bundle "install --deployment"
- bundle "update"
+ it "should fail loudly", :bundler => "< 2" do
+ bundle! "install --deployment"
+ bundle "update", :all => bundle_update_requires_all?
+ expect(last_command).to be_failure
expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
expect(out).to match(/freeze \nby running `bundle install --no-deployment`./m)
- expect(exitstatus).not_to eq(0) if exitstatus
end
- it "should suggest different command when frozen is set globally" do
- bundler "config --global frozen 1"
- bundle "update"
- expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
- expect(out).to match(/freeze \nby running `bundle config --delete frozen`./m)
+ it "should suggest different command when frozen is set globally", :bundler => "< 2" do
+ bundle! "config --global frozen 1"
+ bundle "update", :all => bundle_update_requires_all?
+ expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
+ and match(/freeze \nby running `bundle config --delete frozen`./m)
+ end
+
+ it "should suggest different command when frozen is set globally", :bundler => "2" do
+ bundle! "config --global deployment true"
+ bundle "update", :all => bundle_update_requires_all?
+ expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
+ and match(/freeze \nby running `bundle config --delete deployment`./m)
end
end
describe "with --source option" do
- it "should not update gems not included in the source that happen to have the same name" do
- pending("Allowed to fail to preserve backwards-compatibility")
-
- install_gemfile <<-G
+ it "should not update gems not included in the source that happen to have the same name", :bundler => "< 2" do
+ install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "activesupport"
G
update_repo2 { build_gem "activesupport", "3.0" }
- bundle "update --source activesupport"
- expect(the_bundle).not_to include_gems "activesupport 3.0"
+ bundle! "update --source activesupport"
+ expect(the_bundle).to include_gem "activesupport 3.0"
end
- it "should update gems not included in the source that happen to have the same name" do
- install_gemfile <<-G
+ it "should not update gems not included in the source that happen to have the same name", :bundler => "2" do
+ install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "activesupport"
G
update_repo2 { build_gem "activesupport", "3.0" }
- bundle "update --source activesupport"
- expect(the_bundle).to include_gems "activesupport 3.0"
+ bundle! "update --source activesupport"
+ expect(the_bundle).not_to include_gem "activesupport 3.0"
+ end
+
+ context "with unlock_source_unlocks_spec set to false" do
+ before { bundle! "config unlock_source_unlocks_spec false" }
+
+ it "should not update gems not included in the source that happen to have the same name" do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "activesupport"
+ G
+ update_repo2 { build_gem "activesupport", "3.0" }
+
+ bundle "update --source activesupport"
+ expect(the_bundle).not_to include_gems "activesupport 3.0"
+ end
end
end
@@ -213,7 +277,7 @@ RSpec.describe "bundle update" do
G
end
- it "should not update the child dependencies of a gem that has the same name as the source" do
+ it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 2" do
update_repo2 do
build_gem "fred", "2.0"
build_gem "harry", "2.0" do |s|
@@ -225,6 +289,18 @@ RSpec.describe "bundle update" do
expect(the_bundle).to include_gems "harry 2.0"
expect(the_bundle).to include_gems "fred 1.0"
end
+
+ it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "2" do
+ update_repo2 do
+ build_gem "fred", "2.0"
+ build_gem "harry", "2.0" do |s|
+ s.add_dependency "fred"
+ end
+ end
+
+ bundle "update --source harry"
+ expect(the_bundle).to include_gems "harry 1.0", "fred 1.0"
+ end
end
context "when there is a child dependency that appears elsewhere in the dependency graph" do
@@ -246,7 +322,7 @@ RSpec.describe "bundle update" do
G
end
- it "should not update the child dependencies of a gem that has the same name as the source" do
+ it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 2" do
update_repo2 do
build_gem "george", "2.0"
build_gem "harry", "2.0" do |s|
@@ -259,6 +335,18 @@ RSpec.describe "bundle update" do
expect(the_bundle).to include_gems "fred 1.0"
expect(the_bundle).to include_gems "george 1.0"
end
+
+ it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "2" do
+ update_repo2 do
+ build_gem "george", "2.0"
+ build_gem "harry", "2.0" do |s|
+ s.add_dependency "george"
+ end
+ end
+
+ bundle "update --source harry"
+ expect(the_bundle).to include_gems "harry 1.0", "fred 1.0", "george 1.0"
+ end
end
end
@@ -285,6 +373,24 @@ RSpec.describe "bundle update in more complicated situations" do
expect(the_bundle).to include_gems "thin 2.0", "rack 1.2", "rack-obama 1.0"
end
+ it "will warn when some explicitly updated gems are not updated" do
+ install_gemfile! <<-G
+ source "file:#{gem_repo2}"
+
+ gem "thin"
+ gem "rack-obama"
+ G
+
+ update_repo2 do
+ build_gem("thin", "2.0") {|s| s.add_dependency "rack" }
+ build_gem "rack", "10.0"
+ end
+
+ bundle! "update thin rack-obama"
+ expect(last_command.stdboth).to include "Bundler attempted to update rack-obama but its version stayed the same"
+ expect(the_bundle).to include_gems "thin 2.0", "rack 10.0", "rack-obama 1.0"
+ end
+
it "will update only from pinned source" do
install_gemfile <<-G
source "file://#{gem_repo2}"
@@ -313,7 +419,7 @@ RSpec.describe "bundle update without a Gemfile.lock" do
gem "rack", "1.0"
G
- bundle "update"
+ bundle "update", :all => bundle_update_requires_all?
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -333,21 +439,23 @@ RSpec.describe "bundle update when a gem depends on a newer version of bundler"
G
end
- it "should not explode" do
- bundle "update"
- expect(err).to lack_errors
+ it "should explain that bundler conflicted", :bundler => "< 2" do
+ bundle "update", :all => bundle_update_requires_all?
+ expect(last_command.stdboth).not_to match(/in snapshot/i)
+ expect(last_command.bundler_err).to match(/current Bundler version/i).
+ and match(/perhaps you need to update bundler/i)
end
- it "should explain that bundler conflicted" do
- bundle "update"
- expect(out).not_to match(/in snapshot/i)
- expect(out).to match(/current Bundler version/i)
- expect(out).to match(/perhaps you need to update bundler/i)
+ it "should warn that the newer version of Bundler would conflict", :bundler => "2" do
+ bundle! "update", :all => true
+ expect(last_command.bundler_err).to include("rails (3.0.1) has dependency bundler").
+ and include("so the dependency is being ignored")
+ expect(the_bundle).to include_gem "rails 3.0.1"
end
end
RSpec.describe "bundle update" do
- it "shows the previous version of the gem when updated from rubygems source" do
+ it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 2" do
build_repo2
install_gemfile <<-G
@@ -355,17 +463,52 @@ RSpec.describe "bundle update" do
gem "activesupport"
G
- bundle "update"
+ bundle "update", :all => bundle_update_requires_all?
expect(out).to include("Using activesupport 2.3.5")
update_repo2 do
build_gem "activesupport", "3.0"
end
- bundle "update"
+ bundle "update", :all => bundle_update_requires_all?
expect(out).to include("Installing activesupport 3.0 (was 2.3.5)")
end
+ context "with suppress_install_using_messages set" do
+ before { bundle! "config suppress_install_using_messages true" }
+
+ it "only prints `Using` for versions that have changed" do
+ build_repo4 do
+ build_gem "bar"
+ build_gem "foo"
+ end
+
+ install_gemfile! <<-G
+ source "file://#{gem_repo4}"
+ gem "bar"
+ gem "foo"
+ G
+
+ bundle! "update", :all => bundle_update_requires_all?
+ out.gsub!(/RubyGems [\d\.]+ is not threadsafe.*\n?/, "")
+ expect(out).to include "Resolving dependencies...\nBundle updated!"
+
+ update_repo4 do
+ build_gem "foo", "2.0"
+ end
+
+ bundle! "update", :all => bundle_update_requires_all?
+ out.sub!("Removing foo (1.0)\n", "")
+ out.gsub!(/RubyGems [\d\.]+ is not threadsafe.*\n?/, "")
+ expect(out).to include strip_whitespace(<<-EOS).strip
+ Resolving dependencies...
+ Fetching foo 2.0 (was 1.0)
+ Installing foo 2.0 (was 1.0)
+ Bundle updated
+ EOS
+ end
+ end
+
it "shows error message when Gemfile.lock is not preset and gem is specified" do
install_gemfile <<-G
source "file://#{gem_repo2}"
@@ -403,7 +546,7 @@ RSpec.describe "bundle update --ruby" do
specs:
PLATFORMS
- ruby
+ #{lockfile_platforms}
DEPENDENCIES
@@ -429,7 +572,7 @@ RSpec.describe "bundle update --ruby" do
specs:
PLATFORMS
- ruby
+ #{lockfile_platforms}
DEPENDENCIES
@@ -473,7 +616,7 @@ RSpec.describe "bundle update --ruby" do
specs:
PLATFORMS
- ruby
+ #{lockfile_platforms}
DEPENDENCIES
@@ -487,22 +630,43 @@ RSpec.describe "bundle update --ruby" do
end
end
+RSpec.describe "bundle update --bundler" do
+ it "updates the bundler version in the lockfile without re-resolving" do
+ build_repo4 do
+ build_gem "rack", "1.0"
+ end
+
+ install_gemfile! <<-G
+ source "file:#{gem_repo4}"
+ gem "rack"
+ G
+ lockfile lockfile.sub(Bundler::VERSION, "1.0.0")
+
+ FileUtils.rm_r gem_repo4
+
+ bundle! :update, :bundler => true, :verbose => true
+ expect(the_bundle).to include_gem "rack 1.0"
+
+ expect(the_bundle.locked_gems.bundler_version).to eq v(Bundler::VERSION)
+ end
+end
+
# these specs are slow and focus on integration and therefore are not exhaustive. unit specs elsewhere handle that.
RSpec.describe "bundle update conservative" do
context "patch and minor options" do
before do
build_repo4 do
- build_gem "foo", %w(1.4.3 1.4.4) do |s|
+ build_gem "foo", %w[1.4.3 1.4.4] do |s|
s.add_dependency "bar", "~> 2.0"
end
- build_gem "foo", %w(1.4.5 1.5.0) do |s|
+ build_gem "foo", %w[1.4.5 1.5.0] do |s|
s.add_dependency "bar", "~> 2.1"
end
- build_gem "foo", %w(1.5.1) do |s|
+ build_gem "foo", %w[1.5.1] do |s|
s.add_dependency "bar", "~> 3.0"
end
- build_gem "bar", %w(2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0)
- build_gem "qux", %w(1.0.0 1.0.1 1.1.0 2.0.0)
+ build_gem "bar", %w[2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0]
+ build_gem "qux", %w[1.0.0 1.0.1 1.1.0 2.0.0]
end
# establish a lockfile set to 1.4.3
@@ -524,13 +688,13 @@ RSpec.describe "bundle update conservative" do
context "patch preferred" do
it "single gem updates dependent gem to minor" do
- bundle "update --patch foo"
+ bundle! "update --patch foo"
expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.0"
end
it "update all" do
- bundle "update --patch"
+ bundle! "update --patch", :all => bundle_update_requires_all?
expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.1"
end
@@ -538,7 +702,7 @@ RSpec.describe "bundle update conservative" do
context "minor preferred" do
it "single gem updates dependent gem to major" do
- bundle "update --minor foo"
+ bundle! "update --minor foo"
expect(the_bundle).to include_gems "foo 1.5.1", "bar 3.0.0", "qux 1.0.0"
end
@@ -546,13 +710,13 @@ RSpec.describe "bundle update conservative" do
context "strict" do
it "patch preferred" do
- bundle "update --patch foo bar --strict"
+ bundle! "update --patch foo bar --strict"
expect(the_bundle).to include_gems "foo 1.4.4", "bar 2.0.5", "qux 1.0.0"
end
it "minor preferred" do
- bundle "update --minor --strict"
+ bundle! "update --minor --strict", :all => bundle_update_requires_all?
expect(the_bundle).to include_gems "foo 1.5.0", "bar 2.1.1", "qux 1.1.0"
end
@@ -562,18 +726,18 @@ RSpec.describe "bundle update conservative" do
context "eager unlocking" do
before do
build_repo4 do
- build_gem "isolated_owner", %w(1.0.1 1.0.2) do |s|
+ build_gem "isolated_owner", %w[1.0.1 1.0.2] do |s|
s.add_dependency "isolated_dep", "~> 2.0"
end
- build_gem "isolated_dep", %w(2.0.1 2.0.2)
+ build_gem "isolated_dep", %w[2.0.1 2.0.2]
- build_gem "shared_owner_a", %w(3.0.1 3.0.2) do |s|
+ build_gem "shared_owner_a", %w[3.0.1 3.0.2] do |s|
s.add_dependency "shared_dep", "~> 5.0"
end
- build_gem "shared_owner_b", %w(4.0.1 4.0.2) do |s|
+ build_gem "shared_owner_b", %w[4.0.1 4.0.2] do |s|
s.add_dependency "shared_dep", "~> 5.0"
end
- build_gem "shared_dep", %w(5.0.1 5.0.2)
+ build_gem "shared_dep", %w[5.0.1 5.0.2]
end
gemfile <<-G
@@ -649,9 +813,9 @@ RSpec.describe "bundle update conservative" do
end
it "raises if too many flags are provided" do
- bundle "update --patch --minor"
+ bundle "update --patch --minor", :all => bundle_update_requires_all?
- expect(out).to eq "Provide only one of the following options: minor, patch"
+ expect(last_command.bundler_err).to eq "Provide only one of the following options: minor, patch"
end
end
end
diff --git a/spec/bundler/commands/version_spec.rb b/spec/bundler/commands/version_spec.rb
new file mode 100644
index 0000000000..b919c25e0f
--- /dev/null
+++ b/spec/bundler/commands/version_spec.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+RSpec.describe "bundle version" do
+ context "with -v" do
+ it "outputs the version", :bundler => "< 2" do
+ bundle! "-v"
+ expect(out).to eq("Bundler version #{Bundler::VERSION}")
+ end
+
+ it "outputs the version", :bundler => "2" do
+ bundle! "-v"
+ expect(out).to eq(Bundler::VERSION)
+ end
+ end
+
+ context "with --version" do
+ it "outputs the version", :bundler => "< 2" do
+ bundle! "--version"
+ expect(out).to eq("Bundler version #{Bundler::VERSION}")
+ end
+
+ it "outputs the version", :bundler => "2" do
+ bundle! "--version"
+ expect(out).to eq(Bundler::VERSION)
+ end
+ end
+
+ context "with version" do
+ it "outputs the version with build metadata", :bundler => "< 2" do
+ bundle! "version"
+ expect(out).to match(/\ABundler version #{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit [a-fA-F0-9]{7,}\)\z/)
+ end
+
+ it "outputs the version with build metadata", :bundler => "2" do
+ bundle! "version"
+ expect(out).to match(/\A#{Regexp.escape(Bundler::VERSION)} \(\d{4}-\d{2}-\d{2} commit [a-fA-F0-9]{7,}\)\z/)
+ end
+ end
+end
diff --git a/spec/bundler/commands/viz_spec.rb b/spec/bundler/commands/viz_spec.rb
index 77112aace4..0e8667eaa7 100644
--- a/spec/bundler/commands/viz_spec.rb
+++ b/spec/bundler/commands/viz_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle viz", :ruby => "1.9.3", :if => Bundler.which("dot") do
let(:ruby_graphviz) do