summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/bundler_spec.rb1
-rw-r--r--spec/bundler/cli_spec.rb20
-rw-r--r--spec/bundler/definition_spec.rb53
-rw-r--r--spec/bundler/dsl_spec.rb18
-rw-r--r--spec/bundler/env_spec.rb49
-rw-r--r--spec/bundler/fetcher/downloader_spec.rb9
-rw-r--r--spec/bundler/fetcher/index_spec.rb23
-rw-r--r--spec/bundler/friendly_errors_spec.rb2
-rw-r--r--spec/bundler/gem_helper_spec.rb2
-rw-r--r--spec/bundler/installer/gem_installer_spec.rb11
-rw-r--r--spec/bundler/shared_helpers_spec.rb2
-rw-r--r--spec/bundler/source_list_spec.rb20
-rw-r--r--spec/bundler/ssl_certs/certificate_manager_spec.rb140
-rw-r--r--spec/bundler/ui/shell_spec.rb36
-rw-r--r--spec/cache/gems_spec.rb10
-rw-r--r--spec/cache/git_spec.rb12
-rw-r--r--spec/cache/path_spec.rb4
-rw-r--r--spec/cache/platform_spec.rb2
-rw-r--r--spec/commands/add_spec.rb26
-rw-r--r--spec/commands/binstubs_spec.rb22
-rw-r--r--spec/commands/check_spec.rb10
-rw-r--r--spec/commands/clean_spec.rb71
-rw-r--r--spec/commands/config_spec.rb42
-rw-r--r--spec/commands/console_spec.rb2
-rw-r--r--spec/commands/exec_spec.rb175
-rw-r--r--spec/commands/info_spec.rb114
-rw-r--r--spec/commands/init_spec.rb98
-rw-r--r--spec/commands/inject_spec.rb14
-rw-r--r--spec/commands/install_spec.rb12
-rw-r--r--spec/commands/list_spec.rb75
-rw-r--r--spec/commands/lock_spec.rb2
-rw-r--r--spec/commands/newgem_spec.rb14
-rw-r--r--spec/commands/outdated_spec.rb6
-rw-r--r--spec/commands/package_spec.rb18
-rw-r--r--spec/commands/pristine_spec.rb9
-rw-r--r--spec/commands/show_spec.rb27
-rw-r--r--spec/commands/update_spec.rb115
-rw-r--r--spec/commands/version_spec.rb12
-rw-r--r--spec/install/allow_offline_install_spec.rb2
-rw-r--r--spec/install/binstubs_spec.rb21
-rw-r--r--spec/install/bundler_spec.rb14
-rw-r--r--spec/install/deploy_spec.rb78
-rw-r--r--spec/install/failure_spec.rb8
-rw-r--r--spec/install/gemfile/gemspec_spec.rb107
-rw-r--r--spec/install/gemfile/git_spec.rb62
-rw-r--r--spec/install/gemfile/groups_spec.rb8
-rw-r--r--spec/install/gemfile/lockfile_spec.rb2
-rw-r--r--spec/install/gemfile/path_spec.rb4
-rw-r--r--spec/install/gemfile/platform_spec.rb9
-rw-r--r--spec/install/gemfile/sources_spec.rb93
-rw-r--r--spec/install/gemfile_spec.rb16
-rw-r--r--spec/install/gems/compact_index_spec.rb28
-rw-r--r--spec/install/gems/dependency_api_spec.rb22
-rw-r--r--spec/install/gems/flex_spec.rb10
-rw-r--r--spec/install/gems/native_extensions_spec.rb43
-rw-r--r--spec/install/gems/resolving_spec.rb6
-rw-r--r--spec/install/gems/standalone_spec.rb22
-rw-r--r--spec/install/gems/sudo_spec.rb10
-rw-r--r--spec/install/gemspecs_spec.rb4
-rw-r--r--spec/install/git_spec.rb6
-rw-r--r--spec/install/global_cache_spec.rb4
-rw-r--r--spec/install/path_spec.rb24
-rw-r--r--spec/install/post_bundle_message_spec.rb16
-rw-r--r--spec/install/redownload_spec.rb16
-rw-r--r--spec/install/security_policy_spec.rb3
-rw-r--r--spec/lock/lockfile_bundler_1_spec.rb1388
-rw-r--r--spec/lock/lockfile_spec.rb333
-rw-r--r--spec/other/cli_dispatch_spec.rb10
-rw-r--r--spec/other/major_deprecation_spec.rb460
-rw-r--r--spec/other/platform_spec.rb24
-rw-r--r--spec/other/ssl_cert_spec.rb18
-rw-r--r--spec/plugins/source/example_spec.rb24
-rw-r--r--spec/quality_es_spec.rb2
-rw-r--r--spec/quality_spec.rb29
-rw-r--r--spec/realworld/dependency_api_spec.rb4
-rw-r--r--spec/realworld/edgecases_spec.rb15
-rw-r--r--spec/realworld/gemfile_source_header_spec.rb2
-rw-r--r--spec/realworld/mirror_probe_spec.rb6
-rw-r--r--spec/realworld/parallel_spec.rb2
-rw-r--r--spec/runtime/executable_spec.rb21
-rw-r--r--spec/runtime/gem_tasks_spec.rb6
-rw-r--r--spec/runtime/inline_spec.rb43
-rw-r--r--spec/runtime/platform_spec.rb4
-rw-r--r--spec/runtime/require_spec.rb10
-rw-r--r--spec/runtime/setup_spec.rb93
-rw-r--r--spec/runtime/with_unbundled_env_spec.rb149
-rw-r--r--spec/spec_helper.rb3
-rw-r--r--spec/support/artifice/compact_index.rb6
-rw-r--r--spec/support/code_climate.rb26
-rw-r--r--spec/support/command_execution.rb8
-rw-r--r--spec/support/helpers.rb26
-rw-r--r--spec/support/matchers.rb12
-rw-r--r--spec/support/path.rb2
-rw-r--r--spec/support/platforms.rb7
-rw-r--r--spec/support/rubygems_ext.rb1
-rw-r--r--spec/update/gemfile_spec.rb23
-rw-r--r--spec/update/gems/post_install_spec.rb6
-rw-r--r--spec/update/git_spec.rb28
-rw-r--r--spec/update/redownload_spec.rb10
99 files changed, 1797 insertions, 2920 deletions
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb
index e33c8dc606..9b772bffef 100644
--- a/spec/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler_spec.rb
@@ -457,6 +457,7 @@ MESSAGE
it "should use custom home path as root for other paths" do
ENV["BUNDLE_USER_HOME"] = bundle_user_home_custom.to_s
+ allow(Bundler.rubygems).to receive(:user_home).and_raise
expect(Bundler.user_bundle_path).to eq(bundle_user_home_custom)
expect(Bundler.user_bundle_path("home")).to eq(bundle_user_home_custom)
expect(Bundler.user_bundle_path("cache")).to eq(bundle_user_home_custom.join("cache"))
diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb
index e14442b25a..2e12fbfc6b 100644
--- a/spec/bundler/cli_spec.rb
+++ b/spec/bundler/cli_spec.rb
@@ -28,10 +28,10 @@ RSpec.describe "bundle executable" do
end
context "with no arguments" do
- it "prints a concise help message", :bundler => "2" do
+ it "prints a concise help message", :bundler => "3" do
bundle! ""
- expect(last_command.stderr).to be_empty
- expect(last_command.stdout).to include("Bundler version #{Bundler::VERSION}").
+ expect(err).to be_empty
+ expect(out).to include("Bundler version #{Bundler::VERSION}").
and include("\n\nBundler commands:\n\n").
and include("\n\n Primary commands:\n").
and include("\n\n Utilities:\n").
@@ -72,17 +72,17 @@ RSpec.describe "bundle executable" do
it "prints the running command" do
gemfile ""
bundle! "info bundler", :verbose => true
- expect(last_command.stdout).to start_with("Running `bundle info bundler --verbose` with bundler #{Bundler::VERSION}")
+ expect(out).to start_with("Running `bundle info bundler --verbose` with bundler #{Bundler::VERSION}")
end
it "doesn't print defaults" do
install_gemfile! "", :verbose => true
- expect(last_command.stdout).to start_with("Running `bundle install --retry 0 --verbose` with bundler #{Bundler::VERSION}")
+ expect(out).to start_with("Running `bundle install --retry 0 --verbose` with bundler #{Bundler::VERSION}")
end
it "doesn't print defaults" do
install_gemfile! "", :verbose => true
- expect(last_command.stdout).to start_with("Running `bundle install --retry 0 --verbose` with bundler #{Bundler::VERSION}")
+ expect(out).to start_with("Running `bundle install --retry 0 --verbose` with bundler #{Bundler::VERSION}")
end
end
@@ -125,7 +125,7 @@ RSpec.describe "bundle executable" do
let(:latest_version) { "222.0" }
it "prints the version warning" do
bundle "fail"
- expect(last_command.stdout).to start_with(<<-EOS.strip)
+ expect(err).to start_with(<<-EOS.strip)
The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
To install the latest version, run `gem install bundler`
EOS
@@ -150,7 +150,7 @@ To install the latest version, run `gem install bundler`
let(:latest_version) { "222.0.0.pre.4" }
it "prints the version warning" do
bundle "fail"
- expect(last_command.stdout).to start_with(<<-EOS.strip)
+ expect(err).to start_with(<<-EOS.strip)
The latest bundler is #{latest_version}, but you are currently running #{bundler_version}.
To install the latest version, run `gem install bundler --pre`
EOS
@@ -161,12 +161,12 @@ To install the latest version, run `gem install bundler --pre`
end
RSpec.describe "bundler executable" do
- it "shows the bundler version just as the `bundle` executable does", :bundler => "< 2" do
+ it "shows the bundler version just as the `bundle` executable does", :bundler => "< 3" do
bundler "--version"
expect(out).to eq("Bundler version #{Bundler::VERSION}")
end
- it "shows the bundler version just as the `bundle` executable does", :bundler => "2" do
+ it "shows the bundler version just as the `bundle` executable does", :bundler => "3" do
bundler "--version"
expect(out).to eq(Bundler::VERSION)
end
diff --git a/spec/bundler/definition_spec.rb b/spec/bundler/definition_spec.rb
index ceb7b4bf05..f048728a9f 100644
--- a/spec/bundler/definition_spec.rb
+++ b/spec/bundler/definition_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe Bundler::Definition do
end
describe "detects changes" do
- it "for a path gem with changes", :bundler => "< 2" do
+ it "for a path gem with changes", :bundler => "< 3" do
build_lib "foo", "1.0", :path => lib_path("foo")
install_gemfile <<-G
@@ -72,7 +72,7 @@ RSpec.describe Bundler::Definition do
G
end
- it "for a path gem with changes", :bundler => "2" do
+ it "for a path gem with changes", :bundler => "3" do
build_lib "foo", "1.0", :path => lib_path("foo")
install_gemfile <<-G
@@ -88,17 +88,17 @@ RSpec.describe Bundler::Definition do
expect(out).to match(/re-resolving dependencies/)
lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
PATH
remote: #{lib_path("foo")}
specs:
foo (1.0)
rack (= 1.0)
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
PLATFORMS
#{lockfile_platforms}
@@ -110,7 +110,7 @@ RSpec.describe Bundler::Definition do
G
end
- it "for a path gem with deps and no changes", :bundler => "< 2" do
+ it "for a path gem with deps and no changes" do
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
s.add_dependency "rack", "1.0"
s.add_development_dependency "net-ssh", "1.0"
@@ -137,43 +137,6 @@ RSpec.describe Bundler::Definition do
rack (1.0.0)
PLATFORMS
- ruby
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "for a path gem with deps and no changes", :bundler => "2" do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack", "1.0"
- s.add_development_dependency "net-ssh", "1.0"
- end
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "foo", :path => "#{lib_path("foo")}"
- G
-
- bundle :check, :env => { "DEBUG" => 1 }
-
- expect(out).to match(/using resolution from the lockfile/)
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PATH
- remote: #{lib_path("foo")}
- specs:
- foo (1.0)
- rack (= 1.0)
-
- PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb
index bc40ab94b2..a17bfd4938 100644
--- a/spec/bundler/dsl_spec.rb
+++ b/spec/bundler/dsl_spec.rb
@@ -61,20 +61,26 @@ RSpec.describe Bundler::Dsl do
it_behaves_like "the github DSL", "https"
end
- context "when github.https config is false" do
+ context "when github.https config is false", :bundler => "2" do
before { bundle "config set github.https false" }
it_behaves_like "the github DSL", "git"
end
- context "by default", :bundler => "< 2" do
- it_behaves_like "the github DSL", "git"
+ context "when github.https config is false", :bundler => "3" do
+ before { bundle "config set github.https false" }
+
+ pending "should show a proper message about the removed setting"
end
context "by default", :bundler => "2" do
it_behaves_like "the github DSL", "https"
end
+ context "by default", :bundler => "3" do
+ it_behaves_like "the github DSL", "https"
+ end
+
it "converts numeric :gist to :git" do
subject.gem("not-really-a-gem", :gist => 2_859_988)
github_uri = "https://gist.github.com/2859988.git"
@@ -266,7 +272,7 @@ RSpec.describe Bundler::Dsl do
# gem 'spree_api'
# gem 'spree_backend'
# end
- describe "#github", :bundler => "< 2" do
+ describe "#github", :bundler => "< 3" do
it "from github" do
spree_gems = %w[spree_core spree_api spree_backend]
subject.github "spree" do
@@ -274,12 +280,12 @@ RSpec.describe Bundler::Dsl do
end
subject.dependencies.each do |d|
- expect(d.source.uri).to eq("git://github.com/spree/spree.git")
+ expect(d.source.uri).to eq("https://github.com/spree/spree.git")
end
end
end
- describe "#github", :bundler => "2" do
+ describe "#github", :bundler => "3" do
it "from github" do
spree_gems = %w[spree_core spree_api spree_backend]
subject.github "spree" do
diff --git a/spec/bundler/env_spec.rb b/spec/bundler/env_spec.rb
index 20bd38b021..8323a9a7b3 100644
--- a/spec/bundler/env_spec.rb
+++ b/spec/bundler/env_spec.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
+require "openssl"
require "bundler/settings"
RSpec.describe Bundler::Env do
@@ -17,6 +18,54 @@ RSpec.describe Bundler::Env do
expect(out).to include(OpenSSL::OPENSSL_VERSION)
end
+ describe "rubygems paths" do
+ it "prints gem home" do
+ with_clear_paths("GEM_HOME", "/a/b/c") do
+ out = described_class.report
+ expect(out).to include("Gem Home /a/b/c")
+ end
+ end
+
+ it "prints gem path" do
+ with_clear_paths("GEM_PATH", "/a/b/c:/d/e/f") do
+ out = described_class.report
+ expect(out).to include("Gem Path /a/b/c:/d/e/f")
+ end
+ end
+
+ it "prints user home" do
+ with_clear_paths("HOME", "/a/b/c") do
+ out = described_class.report
+ expect(out).to include("User Home /a/b/c")
+ end
+ end
+
+ it "prints user path" do
+ with_clear_paths("HOME", "/a/b/c") do
+ out = described_class.report
+ expect(out).to include("User Path /a/b/c/.gem")
+ end
+ end
+
+ it "prints bin dir" do
+ with_clear_paths("GEM_HOME", "/a/b/c") do
+ out = described_class.report
+ expect(out).to include("Bin Dir /a/b/c/bin")
+ end
+ end
+
+ private
+
+ def with_clear_paths(env_var, env_value)
+ old_env_var = ENV[env_var]
+ ENV[env_var] = env_value
+ Gem.clear_paths
+ yield
+ ensure
+ ENV[env_var] = old_env_var
+ end
+ end
+
context "when there is a Gemfile and a lockfile and print_gemfile is true" do
before do
gemfile "gem 'rack', '1.0.0'"
diff --git a/spec/bundler/fetcher/downloader_spec.rb b/spec/bundler/fetcher/downloader_spec.rb
index 07b507266b..f985b88982 100644
--- a/spec/bundler/fetcher/downloader_spec.rb
+++ b/spec/bundler/fetcher/downloader_spec.rb
@@ -82,6 +82,15 @@ RSpec.describe Bundler::Fetcher::Downloader do
expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
/Authentication is required for www.uri-to-fetch.com/)
end
+
+ context "when the there are credentials provided in the request" do
+ let(:uri) { URI("http://user:password@www.uri-to-fetch.com") }
+
+ it "should raise a Bundler::Fetcher::BadAuthenticationError that doesn't contain the password" do
+ expect { subject.fetch(uri, options, counter) }.
+ to raise_error(Bundler::Fetcher::BadAuthenticationError, /Bad username or password for www.uri-to-fetch.com/)
+ end
+ end
end
context "when the request response is a Net::HTTPNotFound" do
diff --git a/spec/bundler/fetcher/index_spec.rb b/spec/bundler/fetcher/index_spec.rb
index 0cf0ae764e..d5ededae3e 100644
--- a/spec/bundler/fetcher/index_spec.rb
+++ b/spec/bundler/fetcher/index_spec.rb
@@ -35,9 +35,26 @@ RSpec.describe Bundler::Fetcher::Index do
context "when a 401 response occurs" do
let(:error_message) { "401" }
- it "should raise a Bundler::Fetcher::AuthenticationRequiredError" do
- expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
- %r{Authentication is required for http://remote-uri.org})
+ before do
+ allow(remote_uri).to receive(:userinfo).and_return(userinfo)
+ end
+
+ context "and there was userinfo" do
+ let(:userinfo) { double(:userinfo) }
+
+ it "should raise a Bundler::Fetcher::BadAuthenticationError" do
+ expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::BadAuthenticationError,
+ %r{Bad username or password for http://remote-uri.org})
+ end
+ end
+
+ context "and there was no userinfo" do
+ let(:userinfo) { nil }
+
+ it "should raise a Bundler::Fetcher::AuthenticationRequiredError" do
+ expect { subject.specs(gem_names) }.to raise_error(Bundler::Fetcher::AuthenticationRequiredError,
+ %r{Authentication is required for http://remote-uri.org})
+ end
end
end
diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb
index 4ca1e543c1..07ec196b86 100644
--- a/spec/bundler/friendly_errors_spec.rb
+++ b/spec/bundler/friendly_errors_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Bundler, "friendly errors" do
bundle :install, :env => { "DEBUG" => true }
- expect(last_command.stderr).to include("Failed to load #{home(".gemrc")}")
+ expect(err).to include("Failed to load #{home(".gemrc")}")
expect(exitstatus).to eq(0) if exitstatus
end
end
diff --git a/spec/bundler/gem_helper_spec.rb b/spec/bundler/gem_helper_spec.rb
index dc982c6ee7..315a2290c7 100644
--- a/spec/bundler/gem_helper_spec.rb
+++ b/spec/bundler/gem_helper_spec.rb
@@ -49,7 +49,7 @@ RSpec.describe Bundler::GemHelper do
end
end
- context "gem management" do
+ context "gem management", :ruby_repo do
def mock_confirm_message(message)
expect(Bundler.ui).to receive(:confirm).with(message)
end
diff --git a/spec/bundler/installer/gem_installer_spec.rb b/spec/bundler/installer/gem_installer_spec.rb
index f559c5e141..8f8d1c6d15 100644
--- a/spec/bundler/installer/gem_installer_spec.rb
+++ b/spec/bundler/installer/gem_installer_spec.rb
@@ -26,4 +26,15 @@ RSpec.describe Bundler::GemInstaller do
subject.install_from_spec
end
end
+
+ context "spec_settings is build option with spaces" do
+ it "invokes install method with build_args" do
+ allow(Bundler.settings).to receive(:[]).with(:bin)
+ allow(Bundler.settings).to receive(:[]).with(:inline)
+ allow(Bundler.settings).to receive(:[]).with(:forget_cli_options)
+ allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy --with-another-dummy-config")
+ expect(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => ["--with-dummy-config=dummy", "--with-another-dummy-config"])
+ subject.install_from_spec
+ end
+ end
end
diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb
index 445bc18265..f42d9ed485 100644
--- a/spec/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/shared_helpers_spec.rb
@@ -389,7 +389,7 @@ RSpec.describe Bundler::SharedHelpers do
context "bundle executable in ENV['BUNDLE_BIN_PATH'] does not exist" do
before { ENV["BUNDLE_BIN_PATH"] = "/does/not/exist" }
- before { Bundler.rubygems.replace_bin_path [], [] }
+ before { Bundler.rubygems.replace_bin_path [] }
it "sets BUNDLE_BIN_PATH to the bundle executable file" do
subject.set_bundle_environment
diff --git a/spec/bundler/source_list_spec.rb b/spec/bundler/source_list_spec.rb
index 729311421a..a78b80ec3b 100644
--- a/spec/bundler/source_list_spec.rb
+++ b/spec/bundler/source_list_spec.rb
@@ -115,7 +115,7 @@ RSpec.describe Bundler::SourceList do
end
end
- describe "#add_rubygems_remote", :bundler => "< 2" do
+ describe "#add_rubygems_remote", :bundler => "< 3" do
let!(:returned_source) { source_list.add_rubygems_remote("https://rubygems.org/") }
it "returns the aggregate rubygems source" do
@@ -372,7 +372,7 @@ RSpec.describe Bundler::SourceList do
source_list.add_git_source("uri" => "git://first-git.org/path.git")
end
- it "combines the rubygems sources into a single instance, removing duplicate remotes from the end", :bundler => "< 2" do
+ it "combines the rubygems sources into a single instance, removing duplicate remotes from the end", :bundler => "< 3" do
expect(source_list.lock_sources).to eq [
Bundler::Source::Git.new("uri" => "git://first-git.org/path.git"),
Bundler::Source::Git.new("uri" => "git://second-git.org/path.git"),
@@ -391,21 +391,21 @@ RSpec.describe Bundler::SourceList do
]
end
- it "returns all sources, without combining rubygems sources", :bundler => "2" do
+ it "returns all sources, without combining rubygems sources", :bundler => "3" do
expect(source_list.lock_sources).to eq [
- Bundler::Source::Rubygems.new,
- Bundler::Source::Rubygems.new("remotes" => ["https://duplicate-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://first-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://second-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://third-rubygems.org"]),
Bundler::Source::Git.new("uri" => "git://first-git.org/path.git"),
Bundler::Source::Git.new("uri" => "git://second-git.org/path.git"),
Bundler::Source::Git.new("uri" => "git://third-git.org/path.git"),
+ ASourcePlugin.new("uri" => "https://second-plugin.org/random"),
+ ASourcePlugin.new("uri" => "https://third-bar.org/foo"),
Bundler::Source::Path.new("path" => "/first/path/to/gem"),
Bundler::Source::Path.new("path" => "/second/path/to/gem"),
Bundler::Source::Path.new("path" => "/third/path/to/gem"),
- ASourcePlugin.new("uri" => "https://second-plugin.org/random"),
- ASourcePlugin.new("uri" => "https://third-bar.org/foo"),
+ Bundler::Source::Rubygems.new,
+ Bundler::Source::Rubygems.new("remotes" => ["https://duplicate-rubygems.org"]),
+ Bundler::Source::Rubygems.new("remotes" => ["https://first-rubygems.org"]),
+ Bundler::Source::Rubygems.new("remotes" => ["https://second-rubygems.org"]),
+ Bundler::Source::Rubygems.new("remotes" => ["https://third-rubygems.org"]),
]
end
end
diff --git a/spec/bundler/ssl_certs/certificate_manager_spec.rb b/spec/bundler/ssl_certs/certificate_manager_spec.rb
deleted file mode 100644
index 8403b554b5..0000000000
--- a/spec/bundler/ssl_certs/certificate_manager_spec.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/ssl_certs/certificate_manager"
-
-RSpec.describe Bundler::SSLCerts::CertificateManager do
- let(:rubygems_path) { root }
- let(:stub_cert) { File.join(root.to_s, "lib", "rubygems", "ssl_certs", "rubygems.org", "ssl-cert.pem") }
- let(:rubygems_certs_dir) { File.join(root.to_s, "lib", "rubygems", "ssl_certs", "rubygems.org") }
-
- subject { described_class.new(rubygems_path) }
-
- # Pretend bundler root is rubygems root
- before do
- # Backing up rubygems certificates
- FileUtils.mv(rubygems_certs_dir, rubygems_certs_dir + ".back") if ruby_core?
-
- FileUtils.mkdir_p(rubygems_certs_dir)
- FileUtils.touch(stub_cert)
- end
-
- after do
- FileUtils.rm_rf(rubygems_certs_dir)
-
- # Restore rubygems certificates
- FileUtils.mv(rubygems_certs_dir + ".back", rubygems_certs_dir) if ruby_core?
- end
-
- describe "#update_from" do
- let(:cert_manager) { double(:cert_manager) }
-
- before { allow(described_class).to receive(:new).with(rubygems_path).and_return(cert_manager) }
-
- it "should update the certs through a new certificate manager" do
- allow(cert_manager).to receive(:update!)
- expect(described_class.update_from!(rubygems_path)).to be_nil
- end
- end
-
- describe "#initialize" do
- it "should set bundler_cert_path as path of the subdir with bundler ssl certs" do
- expect(subject.bundler_cert_path).to eq(File.join(root, "lib/bundler/ssl_certs"))
- end
-
- it "should set bundler_certs as the paths of the bundler ssl certs" do
- expect(subject.bundler_certs).to include(File.join(root, "lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem"))
- expect(subject.bundler_certs).to include(File.join(root, "lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem"))
- end
-
- context "when rubygems_path is not nil" do
- it "should set rubygems_certs" do
- expect(subject.rubygems_certs).to include(File.join(root, "lib", "rubygems", "ssl_certs", "rubygems.org", "ssl-cert.pem"))
- end
- end
- end
-
- describe "#up_to_date?" do
- context "when bundler certs and rubygems certs are the same" do
- before do
- bundler_certs = Dir[File.join(root.to_s, "lib", "bundler", "ssl_certs", "**", "*.pem")]
- FileUtils.rm(stub_cert)
- FileUtils.cp(bundler_certs, rubygems_certs_dir)
- end
-
- it "should return true" do
- expect(subject).to be_up_to_date
- end
- end
-
- context "when bundler certs and rubygems certs are not the same" do
- it "should return false" do
- expect(subject).to_not be_up_to_date
- end
- end
- end
-
- describe "#update!" do
- context "when certificate manager is not up to date" do
- before do
- allow(subject).to receive(:up_to_date?).and_return(false)
- allow(bundler_fileutils).to receive(:rm)
- allow(bundler_fileutils).to receive(:cp)
- end
-
- it "should remove the current bundler certs" do
- expect(bundler_fileutils).to receive(:rm).with(subject.bundler_certs)
- subject.update!
- end
-
- it "should copy the rubygems certs into bundler certs" do
- expect(bundler_fileutils).to receive(:cp).with(subject.rubygems_certs, subject.bundler_cert_path)
- subject.update!
- end
-
- it "should return nil" do
- expect(subject.update!).to be_nil
- end
- end
-
- context "when certificate manager is up to date" do
- before { allow(subject).to receive(:up_to_date?).and_return(true) }
-
- it "should return nil" do
- expect(subject.update!).to be_nil
- end
- end
- end
-
- describe "#connect_to" do
- let(:host) { "http://www.host.com" }
- let(:http) { Net::HTTP.new(host, 443) }
- let(:cert_store) { OpenSSL::X509::Store.new }
- let(:http_header_response) { double(:http_header_response) }
-
- before do
- allow(Net::HTTP).to receive(:new).with(host, 443).and_return(http)
- allow(OpenSSL::X509::Store).to receive(:new).and_return(cert_store)
- allow(http).to receive(:head).with("/").and_return(http_header_response)
- end
-
- it "should use ssl for the http request" do
- expect(http).to receive(:use_ssl=).with(true)
- subject.connect_to(host)
- end
-
- it "use verify peer mode" do
- expect(http).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
- subject.connect_to(host)
- end
-
- it "set its cert store as a OpenSSL::X509::Store populated with bundler certs" do
- expect(cert_store).to receive(:add_file).at_least(:once)
- expect(http).to receive(:cert_store=).with(cert_store)
- subject.connect_to(host)
- end
-
- it "return the headers of the request response" do
- expect(subject.connect_to(host)).to eq(http_header_response)
- end
- end
-end
diff --git a/spec/bundler/ui/shell_spec.rb b/spec/bundler/ui/shell_spec.rb
index 951a446aff..632477096e 100644
--- a/spec/bundler/ui/shell_spec.rb
+++ b/spec/bundler/ui/shell_spec.rb
@@ -21,20 +21,9 @@ RSpec.describe Bundler::UI::Shell do
describe "#warn" do
before { subject.level = "warn" }
- it "prints to stdout", :bundler => "< 2" do
- expect { subject.warn("warning") }.to output("warning\n").to_stdout
- end
-
- it "prints to stderr", :bundler => "2" do
+ it "prints to stderr" do
expect { subject.warn("warning") }.to output("warning\n").to_stderr
end
-
- context "when stderr flag is enabled" do
- before { Bundler.settings.temporary(:error_on_stderr => true) }
- it "prints to stderr" do
- expect { subject.warn("warning!") }.to output("warning!\n").to_stderr
- end
- end
end
describe "#debug" do
@@ -46,27 +35,16 @@ RSpec.describe Bundler::UI::Shell do
describe "#error" do
before { subject.level = "error" }
- it "prints to stdout", :bundler => "< 2" do
- expect { subject.error("error!!!") }.to output("error!!!\n").to_stdout
- end
-
- it "prints to stderr", :bundler => "2" do
+ it "prints to stderr" do
expect { subject.error("error!!!") }.to output("error!!!\n").to_stderr
end
- context "when stderr flag is enabled" do
- before { Bundler.settings.temporary(:error_on_stderr => true) }
- it "prints to stderr" do
- expect { subject.error("error!!!") }.to output("error!!!\n").to_stderr
- end
-
- context "when stderr is closed" do
- it "doesn't report anything" do
- output = capture(:stderr, :closed => true) do
- subject.error("Something went wrong")
- end
- expect(output).to_not eq("Something went wrong\n")
+ context "when stderr is closed" do
+ it "doesn't report anything" do
+ output = capture(:stderr, :closed => true) do
+ subject.error("Something went wrong")
end
+ expect(output).to_not eq("Something went wrong\n")
end
end
end
diff --git a/spec/cache/gems_spec.rb b/spec/cache/gems_spec.rb
index 5c184c81f3..4fc43a50a0 100644
--- a/spec/cache/gems_spec.rb
+++ b/spec/cache/gems_spec.rb
@@ -74,12 +74,12 @@ RSpec.describe "bundle cache" do
end
context "using system gems" do
- before { bundle! "config path.system true" }
+ before { bundle! "config set path.system true" }
it_behaves_like "when there are only gemsources"
end
context "installing into a local path" do
- before { bundle! "config path ./.bundle" }
+ before { bundle! "config set path ./.bundle" }
it_behaves_like "when there are only gemsources"
end
@@ -97,7 +97,7 @@ RSpec.describe "bundle cache" do
end
it "uses builtin gems when installing to system gems" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
install_gemfile %(gem 'builtin_gem', '1.0.2')
expect(the_bundle).to include_gems("builtin_gem 1.0.2")
end
@@ -129,7 +129,7 @@ RSpec.describe "bundle cache" do
end
it "errors if the builtin gem isn't available to cache" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
install_gemfile <<-G
gem 'builtin_gem', '1.0.2'
@@ -196,7 +196,7 @@ RSpec.describe "bundle cache" do
it "adds and removes when gems are updated" do
update_repo2
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(cached_gem("rack-1.2")).to exist
expect(cached_gem("rack-1.0.0")).not_to exist
end
diff --git a/spec/cache/git_spec.rb b/spec/cache/git_spec.rb
index 33387dbbb2..d31d607d25 100644
--- a/spec/cache/git_spec.rb
+++ b/spec/cache/git_spec.rb
@@ -59,7 +59,7 @@ end
bundle! "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true)
bundle! "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true)
- expect(last_command.stdout).to include "Updating files in vendor/cache"
+ expect(out).to include "Updating files in vendor/cache"
FileUtils.rm_rf lib_path("foo-1.0")
expect(the_bundle).to include_gems "foo 1.0"
end
@@ -81,7 +81,7 @@ end
ref = git.ref_for("master", 11)
expect(ref).not_to eq(old_ref)
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
bundle! "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true)
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
@@ -127,7 +127,7 @@ end
gem "foo", :git => '#{lib_path("foo-invalid")}', :branch => :master
G
- bundle %(config local.foo #{lib_path("foo-1.0")})
+ bundle %(config set local.foo #{lib_path("foo-1.0")})
bundle "install"
bundle "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true)
@@ -168,7 +168,7 @@ end
expect(the_bundle).to include_gems "has_submodule 1.0"
end
- it "displays warning message when detecting git repo in Gemfile", :bundler => "< 2" do
+ it "displays warning message when detecting git repo in Gemfile", :bundler => "< 3" do
build_git "foo"
install_gemfile <<-G
@@ -177,7 +177,7 @@ end
bundle "#{cmd}"
- expect(out).to include("Your Gemfile contains path and git dependencies.")
+ expect(err).to include("Your Gemfile contains path and git dependencies.")
end
it "does not display warning message if cache_all is set in bundle config" do
@@ -190,7 +190,7 @@ end
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
bundle cmd
- expect(out).not_to include("Your Gemfile contains path and git dependencies.")
+ expect(err).not_to include("Your Gemfile contains path and git dependencies.")
end
it "caches pre-evaluated gemspecs" do
diff --git a/spec/cache/path_spec.rb b/spec/cache/path_spec.rb
index 8c6a843476..0d7b154a37 100644
--- a/spec/cache/path_spec.rb
+++ b/spec/cache/path_spec.rb
@@ -86,7 +86,7 @@
expect(bundled_app("vendor/cache/bar-1.0")).not_to exist
end
- it "raises a warning without --all", :bundler => "< 2" do
+ it "raises a warning without --all", :bundler => "< 3" do
build_lib "foo"
install_gemfile <<-G
@@ -94,7 +94,7 @@
G
bundle cmd
- expect(out).to match(/please pass the \-\-all flag/)
+ expect(err).to match(/please pass the \-\-all flag/)
expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
end
diff --git a/spec/cache/platform_spec.rb b/spec/cache/platform_spec.rb
index c0622a3c94..b3c4643ef5 100644
--- a/spec/cache/platform_spec.rb
+++ b/spec/cache/platform_spec.rb
@@ -41,7 +41,7 @@ RSpec.describe "bundle cache with multiple platforms" do
end
it "ensures that a successful bundle update does not delete gems for other platforms" do
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/activesupport-2.3.5.gem")).to exist
diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb
index dac1d0f6b9..f5b3f49bb1 100644
--- a/spec/commands/add_spec.rb
+++ b/spec/commands/add_spec.rb
@@ -11,6 +11,8 @@ RSpec.describe "bundle add" do
build_gem "dog", "1.1.3.pre"
end
+ build_git "foo", "2.0"
+
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "weakling", "~> 0.0.1"
@@ -21,7 +23,7 @@ RSpec.describe "bundle add" do
it "shows error" do
bundle "add"
- expect(last_command.bundler_err).to include("Please specify gems to add")
+ expect(err).to include("Please specify gems to add")
end
end
@@ -89,6 +91,28 @@ RSpec.describe "bundle add" do
end
end
+ describe "with --git" do
+ it "adds dependency with specified github source" do
+ bundle "add foo --git=#{lib_path("foo-2.0")}"
+
+ expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}"/)
+ expect(the_bundle).to include_gems "foo 2.0"
+ end
+ end
+
+ describe "with --git and --branch" do
+ before do
+ update_git "foo", "2.0", :branch => "test"
+ end
+
+ it "adds dependency with specified github source and branch" do
+ bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test"
+
+ expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test"/)
+ expect(the_bundle).to include_gems "foo 2.0"
+ end
+ end
+
describe "with --skip-install" do
it "adds gem to Gemfile but is not installed" do
bundle "add foo --skip-install --version=2.0"
diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb
index 9126b29592..4f310784c7 100644
--- a/spec/commands/binstubs_spec.rb
+++ b/spec/commands/binstubs_spec.rb
@@ -70,7 +70,7 @@ RSpec.describe "bundle binstubs <gem>" do
bundle "binstubs rack", :all => true
expect(last_command).to be_failure
- expect(last_command.bundler_err).to include("Cannot specify --all with specific gems")
+ expect(err).to include("Cannot specify --all with specific gems")
end
context "when generating bundle binstub outside bundler" do
@@ -88,7 +88,7 @@ RSpec.describe "bundle binstubs <gem>" do
sys_exec "bin/rackup"
- expect(last_command.stderr).to include("was not generated by Bundler")
+ expect(err).to include("was not generated by Bundler")
end
end
@@ -135,7 +135,7 @@ RSpec.describe "bundle binstubs <gem>" do
it "runs the correct version of bundler" do
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:").
+ expect(err).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
@@ -145,7 +145,7 @@ RSpec.describe "bundle binstubs <gem>" 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:").
+ expect(err).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
@@ -154,7 +154,7 @@ RSpec.describe "bundle binstubs <gem>" do
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:").
+ expect(err).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
@@ -163,7 +163,7 @@ RSpec.describe "bundle binstubs <gem>" do
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:").
+ expect(err).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
@@ -173,13 +173,13 @@ RSpec.describe "bundle binstubs <gem>" do
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"])
+ expect(out).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:").
+ expect(err).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
@@ -202,10 +202,10 @@ RSpec.describe "bundle binstubs <gem>" do
context "when requesting a different bundler version" do
before { lockfile lockfile.gsub(Bundler::VERSION, "999.999.999") }
- it "attempts to load that version", :ruby_repo do
+ 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:").
+ expect(err).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
@@ -294,7 +294,7 @@ RSpec.describe "bundle binstubs <gem>" do
expect(bundled_app("exec/rackup")).to exist
end
- it "setting is saved for bundle install", :bundler => "< 2" do
+ it "setting is saved for bundle install", :bundler => "< 3" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb
index b16cfc37e7..cf88736612 100644
--- a/spec/commands/check_spec.rb
+++ b/spec/commands/check_spec.rb
@@ -92,7 +92,7 @@ RSpec.describe "bundle check" do
expect(err).to include("Bundler can't satisfy your Gemfile's dependencies.")
end
- it "remembers --without option from install", :bundler => "< 2" do
+ it "remembers --without option from install", :bundler => "< 3" do
gemfile <<-G
source "file://#{gem_repo1}"
group :foo do
@@ -106,7 +106,7 @@ RSpec.describe "bundle check" do
end
it "uses the without setting" do
- bundle! "config without foo"
+ bundle! "config set without foo"
install_gemfile! <<-G
source "file://#{gem_repo1}"
group :foo do
@@ -238,7 +238,7 @@ RSpec.describe "bundle check" do
expect(last_command).to be_failure
end
- context "--path", :bundler => "< 2" do
+ context "--path", :bundler => "< 3" do
before do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -254,7 +254,7 @@ RSpec.describe "bundle check" do
expect(out).to include("The Gemfile's dependencies are satisfied")
end
- it "should write to .bundle/config", :bundler => "< 2" do
+ it "should write to .bundle/config", :bundler => "< 3" do
bundle "check --path vendor/bundle"
bundle! "check"
end
@@ -338,7 +338,7 @@ RSpec.describe "bundle check" do
it "does not change the lock but warns" do
lockfile lock_with(Bundler::VERSION.succ)
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})")
+ expect(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/commands/clean_spec.rb b/spec/commands/clean_spec.rb
index 6cd796f694..0053947c85 100644
--- a/spec/commands/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
@@ -142,7 +142,7 @@ RSpec.describe "bundle clean" do
bundle :clean
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}")
+ cache_path = Bundler::VERSION.start_with?("2.") ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}")
expect(cache_path).to exist
end
@@ -201,7 +201,7 @@ RSpec.describe "bundle clean" do
update_git "foo", :path => lib_path("foo-bar")
revision2 = revision_for(lib_path("foo-bar"))
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
bundle! :clean
expect(out).to include("Removing foo-bar (#{revision[0..11]})")
@@ -276,7 +276,7 @@ RSpec.describe "bundle clean" do
end
it "displays an error when used without --path" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
install_gemfile <<-G
source "file://#{gem_repo1}"
@@ -320,9 +320,7 @@ RSpec.describe "bundle clean" do
end
it "does not call clean automatically when using system gems" do
- bundle! "config path.system true"
-
- bundle! "config list"
+ bundle! "config set path.system true"
install_gemfile! <<-G
source "file://#{gem_repo1}"
@@ -331,8 +329,6 @@ RSpec.describe "bundle clean" do
gem "rack"
G
- bundle! "info thin"
-
install_gemfile! <<-G
source "file://#{gem_repo1}"
@@ -344,7 +340,7 @@ RSpec.describe "bundle clean" do
expect(out).to include("rack (1.0.0)").and include("thin (1.0)")
end
- it "--clean should override the bundle setting on install", :bundler => "< 2" do
+ it "--clean should override the bundle setting on install", :bundler => "< 3" do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -364,7 +360,7 @@ RSpec.describe "bundle clean" do
should_not_have_gems "thin-1.0"
end
- it "--clean should override the bundle setting on update", :bundler => "< 2" do
+ it "--clean should override the bundle setting on update", :bundler => "< 3" do
build_repo2
gemfile <<-G
@@ -378,13 +374,13 @@ RSpec.describe "bundle clean" do
build_gem "foo", "1.0.1"
end
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
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
+ it "automatically cleans when path has not been set", :bundler => "3" do
build_repo2
install_gemfile! <<-G
@@ -441,12 +437,12 @@ RSpec.describe "bundle clean" do
build_gem "foo", "1.0.1"
end
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
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"
+ bundle! "config set path.system true"
build_repo2
@@ -460,7 +456,7 @@ RSpec.describe "bundle clean" do
update_repo2 do
build_gem "foo", "1.0.1"
end
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
sys_exec! "#{gem} list"
@@ -468,7 +464,7 @@ RSpec.describe "bundle clean" do
end
it "cleans system gems when --force is used" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
gemfile <<-G
source "file://#{gem_repo1}"
@@ -560,7 +556,7 @@ RSpec.describe "bundle clean" do
end
it "when using --force on system gems, it doesn't remove binaries" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
build_repo2
update_repo2 do
@@ -707,7 +703,7 @@ RSpec.describe "bundle clean" do
gem "weakling"
G
- bundle! "config auto_install 1"
+ bundle! "config set 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"
@@ -770,4 +766,43 @@ RSpec.describe "bundle clean" do
expect(very_simple_binary_extensions_dir).not_to exist
expect(simple_binary_extensions_dir).to exist
end
+
+ it "removes git extension directories", :ruby_repo do
+ build_git "very_simple_git_binary", &:add_c_extension
+
+ revision = revision_for(lib_path("very_simple_git_binary-1.0"))
+ short_revision = revision[0..11]
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "thin"
+ gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
+ G
+
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
+
+ very_simple_binary_extensions_dir =
+ Pathname.glob("#{vendored_gems}/bundler/gems/extensions/*/*/very_simple_git_binary-1.0-#{short_revision}").first
+
+ expect(very_simple_binary_extensions_dir).to exist
+
+ gemfile <<-G
+ gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
+ G
+
+ bundle! "install"
+ bundle! :clean
+ expect(out).to include("Removing thin (1.0)")
+ expect(very_simple_binary_extensions_dir).to exist
+
+ gemfile <<-G
+ G
+
+ bundle! "install"
+ bundle! :clean
+ expect(out).to eq("Removing very_simple_git_binary-1.0 (#{short_revision})")
+
+ expect(very_simple_binary_extensions_dir).not_to exist
+ end
end
diff --git a/spec/commands/config_spec.rb b/spec/commands/config_spec.rb
index 878b75f865..40fab95803 100644
--- a/spec/commands/config_spec.rb
+++ b/spec/commands/config_spec.rb
@@ -389,88 +389,88 @@ E
end
describe "subcommands" do
- it "list" do
+ it "list", :ruby_repo do
bundle! "config list"
- expect(last_command.stdout).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\""
+ expect(out).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\""
bundle! "config list", :parseable => true
- expect(last_command.stdout).to eq "spec_run=true"
+ expect(out).to eq "spec_run=true"
end
it "get" do
ENV["BUNDLE_BAR"] = "bar_val"
bundle! "config get foo"
- expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
+ expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
ENV["BUNDLE_FOO"] = "foo_val"
bundle! "config get foo --parseable"
- expect(last_command.stdout).to eq "foo=foo_val"
+ expect(out).to eq "foo=foo_val"
bundle! "config get foo"
- expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nSet via BUNDLE_FOO: \"foo_val\""
+ expect(out).to eq "Settings for `foo` in order of priority. The top value will be used\nSet via BUNDLE_FOO: \"foo_val\""
end
it "set" do
bundle! "config set foo 1"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set --local foo 2"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set --global foo 3"
- expect(last_command.stdout).to eq "Your application has set foo to \"2\". This will override the global value you are currently setting"
+ expect(out).to eq "Your application has set foo to \"2\". This will override the global value you are currently setting"
bundle! "config set --parseable --local foo 4"
- expect(last_command.stdout).to eq "foo=4"
+ expect(out).to eq "foo=4"
bundle! "config set --local foo 4.1"
- expect(last_command.stdout).to eq "You are replacing the current local value of foo, which is currently \"4\""
+ expect(out).to eq "You are replacing the current local value of foo, which is currently \"4\""
bundle "config set --global --local foo 5"
expect(last_command).to be_failure
- expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time."
+ expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time."
end
it "unset" do
bundle! "config unset foo"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set foo 1"
bundle! "config unset foo --parseable"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
bundle! "config set --local foo 1"
bundle! "config set --global foo 2"
bundle! "config unset foo"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
bundle! "config set --local foo 1"
bundle! "config set --global foo 2"
bundle! "config unset foo --local"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for the current user (#{home(".bundle/config")}): \"2\""
bundle! "config unset foo --global"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
bundle! "config set --local foo 1"
bundle! "config set --global foo 2"
bundle! "config unset foo --global"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for your local app (#{bundled_app(".bundle/config")}): \"1\""
bundle! "config unset foo --local"
- expect(last_command.stdout).to eq ""
+ expect(out).to eq ""
expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
bundle "config unset foo --local --global"
expect(last_command).to be_failure
- expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time."
+ expect(err).to eq "The options global and local were specified. Please only use one of the switches at a time."
end
end
end
@@ -488,7 +488,7 @@ RSpec.describe "setting gemfile via config" do
bundle "config set --local gemfile #{bundled_app("NotGemfile")}"
expect(File.exist?(".bundle/config")).to eq(true)
- bundle "config"
+ bundle "config list"
expect(out).to include("NotGemfile")
end
end
diff --git a/spec/commands/console_spec.rb b/spec/commands/console_spec.rb
index 41fc56c919..cba618db80 100644
--- a/spec/commands/console_spec.rb
+++ b/spec/commands/console_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "bundle console", :bundler => "< 2" do
+RSpec.describe "bundle console", :bundler => "< 3" do
before :each do
install_gemfile <<-G
source "file://#{gem_repo1}"
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index d339486ed1..24aa5f46fe 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -88,14 +88,14 @@ RSpec.describe "bundle exec" do
sys_exec "#{Gem.ruby} #{command.path}"
expect(out).to eq("")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "accepts --keep-file-descriptors" do
install_gemfile ""
bundle "exec --keep-file-descriptors echo foobar"
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "can run a command named --verbose" do
@@ -140,6 +140,112 @@ RSpec.describe "bundle exec" do
end
end
+ context "with default gems" do
+ let(:system_gems_to_install) { [] }
+
+ let(:default_irb_version) { ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION" }
+
+ context "when not specified in Gemfile" do
+ before do
+ skip "irb isn't a default gem" if default_irb_version.empty?
+
+ install_gemfile ""
+ end
+
+ it "uses version provided by ruby" do
+ bundle! "exec irb --version"
+
+ expect(out).to include(default_irb_version)
+ expect(err).to be_empty
+ end
+ end
+
+ context "when specified in Gemfile directly" do
+ let(:specified_irb_version) { "0.9.6" }
+
+ before do
+ skip "irb isn't a default gem" if default_irb_version.empty?
+
+ build_repo2 do
+ build_gem "irb", specified_irb_version do |s|
+ s.executables = "irb"
+ end
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "irb", "#{specified_irb_version}"
+ G
+ end
+
+ it "uses version specified" do
+ bundle! "exec irb --version"
+
+ expect(out).to include(specified_irb_version)
+ expect(err).to be_empty
+ end
+ end
+
+ context "when specified in Gemfile indirectly" do
+ let(:indirect_irb_version) { "0.9.6" }
+
+ before do
+ skip "irb isn't a default gem" if default_irb_version.empty?
+
+ build_repo2 do
+ build_gem "irb", indirect_irb_version do |s|
+ s.executables = "irb"
+ end
+
+ build_gem "gem_depending_on_old_irb" do |s|
+ s.add_dependency "irb", indirect_irb_version
+ end
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "gem_depending_on_old_irb"
+ G
+
+ bundle! "exec irb --version"
+ end
+
+ it "uses resolved version" do
+ expect(out).to include(indirect_irb_version)
+ expect(err).to be_empty
+ end
+ end
+ end
+
+ it "warns about executable conflicts" do
+ build_repo2 do
+ build_gem "rack_two", "1.0.0" do |s|
+ s.executables = "rackup"
+ end
+ end
+
+ bundle "config set path.system true"
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", "0.9.1"
+ G
+
+ Dir.chdir bundled_app2 do
+ install_gemfile bundled_app2("Gemfile"), <<-G
+ source "file://#{gem_repo2}"
+ gem "rack_two", "1.0.0"
+ G
+ end
+
+ bundle! "exec rackup"
+
+ expect(last_command.stderr).to eq(
+ "Bundler is using a binstub that was created for a different gem (rack).\n" \
+ "You should run `bundle binstub rack_two` to work around a system/bundle conflict."
+ )
+ end
+
it "handles gems installed with --without" do
install_gemfile <<-G, forgotten_command_line_options(:without => "middleware")
source "file://#{gem_repo1}"
@@ -220,15 +326,15 @@ RSpec.describe "bundle exec" do
end
it "raises a helpful error when exec'ing to something outside of the bundle", :ruby_repo do
- bundle! "config clean false" # want to keep the rackup binstub
+ bundle! "config set clean false" # want to keep the rackup binstub
install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "with_license"
G
[true, false].each do |l|
- bundle! "config disable_exec_load #{l}"
+ bundle! "config set disable_exec_load #{l}"
bundle "exec rackup"
- 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?"
+ 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?"
end
end
@@ -424,7 +530,7 @@ RSpec.describe "bundle exec" do
expect(out).to include("Installing foo 1.0")
end
- describe "with gems bundled via :path with invalid gemspecs", :ruby_repo do
+ describe "with gems bundled via :path with invalid gemspecs" do
it "outputs the gemspec validation errors" do
build_lib "foo"
@@ -446,8 +552,8 @@ RSpec.describe "bundle exec" do
bundle "exec irb"
- expect(last_command.stderr).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid")
- expect(last_command.stderr).to match('"TODO" is not a summary')
+ expect(err).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid")
+ expect(err).to match('"TODO" is not a summary')
end
end
@@ -508,8 +614,8 @@ RSpec.describe "bundle exec" do
it "like a normally executed executable" do
subject
expect(exitstatus).to eq(exit_code) if exitstatus
- expect(last_command.stderr).to eq(expected_err)
- expect(last_command.stdout).to eq(expected)
+ expect(err).to eq(expected_err)
+ expect(out).to eq(expected)
end
end
@@ -544,17 +650,7 @@ RSpec.describe "bundle exec" do
it_behaves_like "it runs"
end
- context "the executable is empty", :bundler => "< 2" do
- let(:executable) { "" }
-
- let(:exit_code) { 0 }
- let(:expected) { "#{path} is empty" }
- let(:expected_err) { "" }
-
- it_behaves_like "it runs"
- end
-
- context "the executable is empty", :bundler => "2" do
+ context "the executable is empty" do
let(:executable) { "" }
let(:exit_code) { 0 }
@@ -563,18 +659,7 @@ 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) { super() << "\nbundler: failed to load command: #{path} (#{path})" }
- let(:expected_err) do
- "RuntimeError: ERROR\n #{path}:10" +
- (Bundler.current_ruby.ruby_18? ? "" : ":in `<top (required)>'")
- end
- it_behaves_like "it runs"
- end
-
- context "the executable raises", :bundler => "2" do
+ context "the executable raises" do
let(:executable) { super() << "\nraise 'ERROR'" }
let(:exit_code) { 1 }
let(:expected_err) do
@@ -584,16 +669,7 @@ RSpec.describe "bundle exec" do
it_behaves_like "it runs"
end
- context "the executable raises an error without a backtrace", :bundler => "< 2" do
- let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" }
- let(:exit_code) { 1 }
- let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" }
- let(:expected_err) { "Err: Err" }
-
- it_behaves_like "it runs"
- end
-
- context "the executable raises an error without a backtrace", :bundler => "2" do
+ context "the executable raises an error without a backtrace" do
let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" }
let(:exit_code) { 1 }
let(:expected_err) { "bundler: failed to load command: #{path} (#{path})\nErr: Err" }
@@ -607,7 +683,7 @@ RSpec.describe "bundle exec" do
it_behaves_like "it runs"
end
- context "when Bundler.setup fails", :bundler => "< 2" do
+ context "when Bundler.setup fails", :bundler => "< 3" do
before do
gemfile <<-G
gem 'rack', '2'
@@ -616,7 +692,8 @@ RSpec.describe "bundle exec" do
end
let(:exit_code) { Bundler::GemNotFound.new.status_code }
- let(:expected) { <<-EOS.strip }
+ let(:expected) { "" }
+ let(:expected_err) { <<-EOS.strip }
\e[31mCould not find gem 'rack (= 2)' in any of the gem sources listed in your Gemfile.\e[0m
\e[33mRun `bundle install` to install missing gems.\e[0m
EOS
@@ -624,7 +701,7 @@ RSpec.describe "bundle exec" do
it_behaves_like "it runs"
end
- context "when Bundler.setup fails", :bundler => "2" do
+ context "when Bundler.setup fails", :bundler => "3" do
before do
gemfile <<-G
gem 'rack', '2'
@@ -759,9 +836,7 @@ __FILE__: #{path.to_s.inspect}
bundle :install, :system_bundler => true, :path => "vendor/bundler"
end
- it "overrides disable_shared_gems so bundler can be found", :rubygems => ">= 2.6.2" do
- skip "bundler 1.16.x is not support with Ruby 2.6 on Travis CI" if RUBY_VERSION >= "2.6"
-
+ it "overrides disable_shared_gems so bundler can be found", :ruby_repo, :rubygems => ">= 2.6.2" do
system_gems :bundler
file = bundled_app("file_that_bundle_execs.rb")
create_file(file, <<-RB)
@@ -811,7 +886,7 @@ __FILE__: #{path.to_s.inspect}
# sanity check that we get the newer, custom version without bundler
sys_exec("#{Gem.ruby} #{file}")
- expect(last_command.stderr).to include("custom openssl should not be loaded")
+ expect(err).to include("custom openssl should not be loaded")
end
end
end
diff --git a/spec/commands/info_spec.rb b/spec/commands/info_spec.rb
index 20fe0038a6..f0f4b5f87d 100644
--- a/spec/commands/info_spec.rb
+++ b/spec/commands/info_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "bundle info" do
- context "info from specific gem in gemfile" do
+ context "with a standard Gemfile" do
before do
install_gemfile <<-G
source "file://#{gem_repo1}"
@@ -9,19 +9,35 @@ RSpec.describe "bundle info" do
G
end
- it "prints information about the current gem" do
+ it "creates a Gemfile.lock when invoked with a gem name" do
+ FileUtils.rm("Gemfile.lock")
+
+ bundle "info rails"
+
+ expect(bundled_app("Gemfile.lock")).to exist
+ end
+
+ it "prints information if gem exists in bundle" do
bundle "info rails"
expect(out).to include "* rails (2.3.2)
\tSummary: This is just a fake gem for testing
-\tHomepage: http://example.com"
- expect(out).to match(%r{Path\: .*\/rails\-2\.3\.2})
+\tHomepage: http://example.com
+\tPath: #{default_bundle_path("gems", "rails-2.3.2")}"
end
- context "given a gem that is not installed" do
- it "prints missing gem error" do
- bundle "info foo"
- expect(err).to eq "Could not find gem 'foo'."
- end
+ it "prints path if gem exists in bundle" do
+ bundle "info rails --path"
+ expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
+ end
+
+ it "prints the path to the running bundler" do
+ bundle "info bundler --path"
+ expect(out).to eq(root.to_s)
+ end
+
+ it "complains if gem not in bundle" do
+ bundle "info missing"
+ expect(err).to eq("Could not find gem 'missing'.")
end
context "given a default gem shippped in ruby", :ruby_repo do
@@ -46,12 +62,84 @@ RSpec.describe "bundle info" do
expect(out).to_not include("Homepage:")
end
end
+ end
+
+ context "with a git repo in the Gemfile" do
+ before :each do
+ @git = build_git "foo", "1.0"
+ end
+
+ it "prints out git info" do
+ install_gemfile <<-G
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
+ G
+ expect(the_bundle).to include_gems "foo 1.0"
+
+ bundle "info foo"
+ expect(out).to include("foo (1.0 #{@git.ref_for("master", 6)}")
+ end
- context "given --path option" do
- it "prints the path to the gem" do
- bundle "info rails"
- expect(out).to match(%r{.*\/rails\-2\.3\.2})
+ it "prints out branch names other than master" do
+ update_git "foo", :branch => "omg" do |s|
+ s.write "lib/foo.rb", "FOO = '1.0.omg'"
end
+ @revision = revision_for(lib_path("foo-1.0"))[0...6]
+
+ install_gemfile <<-G
+ gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg"
+ G
+ expect(the_bundle).to include_gems "foo 1.0.omg"
+
+ bundle "info foo"
+ expect(out).to include("foo (1.0 #{@git.ref_for("omg", 6)}")
+ end
+
+ it "doesn't print the branch when tied to a ref" do
+ sha = revision_for(lib_path("foo-1.0"))
+ install_gemfile <<-G
+ gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{sha}"
+ G
+
+ bundle "info foo"
+ expect(out).to include("foo (1.0 #{sha[0..6]})")
+ end
+
+ it "handles when a version is a '-' prerelease", :rubygems => "2.1" do
+ @git = build_git("foo", "1.0.0-beta.1", :path => lib_path("foo"))
+ install_gemfile <<-G
+ gem "foo", "1.0.0-beta.1", :git => "#{lib_path("foo")}"
+ G
+ expect(the_bundle).to include_gems "foo 1.0.0.pre.beta.1"
+
+ bundle! "info foo"
+ expect(out).to include("foo (1.0.0.pre.beta.1")
+ end
+ end
+
+ context "with a valid regexp for gem name", :ruby_repo do
+ it "presents alternatives" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ gem "rack-obama"
+ G
+
+ bundle "info rac"
+ expect(out).to eq "1 : rack\n2 : rack-obama\n0 : - exit -\n>"
+ end
+ end
+
+ context "with an invalid regexp for gem name" do
+ it "does not find the gem" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rails"
+ G
+
+ invalid_regexp = "[]"
+
+ bundle "info #{invalid_regexp}"
+ expect(err).to include("Could not find gem '#{invalid_regexp}'.")
end
end
end
diff --git a/spec/commands/init_spec.rb b/spec/commands/init_spec.rb
index 3685cd9c36..7960ce85bd 100644
--- a/spec/commands/init_spec.rb
+++ b/spec/commands/init_spec.rb
@@ -1,19 +1,13 @@
# frozen_string_literal: true
RSpec.describe "bundle init" do
- it "generates a Gemfile", :bundler => "< 2" do
+ it "generates a Gemfile" 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", :bundler => "< 2" do
+ context "when a Gemfile already exists" do
before do
create_file "Gemfile", <<-G
gem "rails"
@@ -30,24 +24,7 @@ RSpec.describe "bundle init" do
end
end
- context "when gems.rb already exists", :bundler => ">= 2" 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(err).to include("gems.rb already exists")
- end
- end
-
- context "when a Gemfile exists in a parent directory", :bundler => "< 2" do
+ context "when a Gemfile exists in a parent directory" do
let(:subdir) { "child_dir" }
it "lets users generate a Gemfile in a child directory" do
@@ -82,24 +59,7 @@ RSpec.describe "bundle init" do
end
end
- context "when a gems.rb file exists in a parent directory", :bundler => ">= 2" do
- let(:subdir) { "child_dir" }
-
- it "lets users generate a Gemfile in a child directory" do
- bundle! :init
-
- FileUtils.mkdir bundled_app(subdir)
-
- Dir.chdir bundled_app(subdir) do
- bundle! :init
- end
-
- expect(out).to include("Writing new gems.rb")
- expect(bundled_app("#{subdir}/gems.rb")).to be_file
- end
- end
-
- context "given --gemspec option", :bundler => "< 2" do
+ context "given --gemspec option" do
let(:spec_file) { tmp.join("test.gemspec") }
it "should generate from an existing gemspec" do
@@ -115,11 +75,7 @@ RSpec.describe "bundle init" do
bundle :init, :gemspec => spec_file
- gemfile = if Bundler::VERSION[0, 2] == "1."
- bundled_app("Gemfile").read
- else
- bundled_app("gems.rb").read
- end
+ gemfile = bundled_app("Gemfile").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)
@@ -138,7 +94,7 @@ RSpec.describe "bundle init" do
end
bundle :init, :gemspec => spec_file
- expect(last_command.bundler_err).to include("There was an error while loading `test.gemspec`")
+ expect(err).to include("There was an error while loading `test.gemspec`")
end
end
end
@@ -146,7 +102,47 @@ RSpec.describe "bundle init" do
context "when init_gems_rb setting is enabled" do
before { bundle "config set init_gems_rb true" }
- context "given --gemspec option", :bundler => "< 2" do
+ it "generates a gems.rb" do
+ bundle! :init
+ expect(out).to include("Writing new gems.rb")
+ expect(bundled_app("gems.rb")).to be_file
+ 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(err).to include("gems.rb already exists")
+ end
+ end
+
+ context "when a gems.rb file exists in a parent directory" do
+ let(:subdir) { "child_dir" }
+
+ it "lets users generate a Gemfile in a child directory" do
+ bundle! :init
+
+ FileUtils.mkdir bundled_app(subdir)
+
+ Dir.chdir bundled_app(subdir) do
+ bundle! :init
+ end
+
+ expect(out).to include("Writing new gems.rb")
+ expect(bundled_app("#{subdir}/gems.rb")).to be_file
+ end
+ end
+
+ context "given --gemspec option" do
let(:spec_file) { tmp.join("test.gemspec") }
before do
diff --git a/spec/commands/inject_spec.rb b/spec/commands/inject_spec.rb
index b7ffc89a34..da31849be7 100644
--- a/spec/commands/inject_spec.rb
+++ b/spec/commands/inject_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "bundle inject", :bundler => "< 2" do
+RSpec.describe "bundle inject", :bundler => "< 3" do
before :each do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -37,14 +37,14 @@ RSpec.describe "bundle inject", :bundler => "< 2" do
context "with injected gems already in the Gemfile" do
it "doesn't add existing gems" do
bundle "inject 'rack' '> 0'"
- expect(out).to match(/cannot specify the same gem twice/i)
+ expect(err).to match(/cannot specify the same gem twice/i)
end
end
context "incorrect arguments" do
it "fails when more than 2 arguments are passed" do
bundle "inject gem_name 1 v"
- expect(out).to eq(<<-E.strip)
+ expect(err).to eq(<<-E.strip)
ERROR: "bundle inject" was called with arguments ["gem_name", "1", "v"]
Usage: "bundle inject GEM VERSION"
E
@@ -79,10 +79,10 @@ Usage: "bundle inject GEM VERSION"
context "when frozen" do
before do
bundle "install"
- if Bundler.feature_flag.bundler_2_mode?
- bundle! "config --local deployment true"
+ if Bundler.feature_flag.bundler_3_mode?
+ bundle! "config set --local deployment true"
else
- bundle! "config --local frozen true"
+ bundle! "config set --local frozen true"
end
end
@@ -109,7 +109,7 @@ Usage: "bundle inject GEM VERSION"
gem "rack-obama"
G
bundle "inject 'rack' '> 0'"
- expect(out).to match(/trying to install in deployment mode after changing/)
+ expect(err).to match(/trying to install in deployment mode after changing/)
expect(bundled_app("Gemfile.lock").read).not_to match(/rack-obama/)
end
diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb
index c198797862..1a027a77c9 100644
--- a/spec/commands/install_spec.rb
+++ b/spec/commands/install_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe "bundle install with gem sources" do
raise StandardError, "FAIL"
G
- expect(last_command.bundler_err).to include('StandardError, "FAIL"')
+ expect(err).to include('StandardError, "FAIL"')
expect(bundled_app("Gemfile.lock")).not_to exist
end
@@ -29,7 +29,7 @@ RSpec.describe "bundle install with gem sources" do
expect(bundled_app("Gemfile.lock")).to exist
end
- it "does not create ./.bundle by default", :bundler => "< 2" do
+ it "does not create ./.bundle by default", :bundler => "< 3" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -275,14 +275,14 @@ RSpec.describe "bundle install with gem sources" do
expect(the_bundle).to include_gems "rack 1.0"
end
- it "allows running bundle install --system without deleting foo", :bundler => "< 2" do
+ it "allows running bundle install --system without deleting foo", :bundler => "< 3" 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", :bundler => "< 2" do
+ it "allows running bundle install --system after deleting foo", :bundler => "< 3" do
bundle "install", forgotten_command_line_options(:path => "vendor")
FileUtils.rm_rf(bundled_app("vendor"))
bundle "install", forgotten_command_line_options(:system => true)
@@ -290,7 +290,7 @@ RSpec.describe "bundle install with gem sources" do
end
end
- it "finds gems in multiple sources", :bundler => "< 2" do
+ it "finds gems in multiple sources", :bundler => "< 3" do
build_repo2
update_repo2
@@ -404,7 +404,7 @@ RSpec.describe "bundle install with gem sources" do
G
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.").
+ expect(err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue.").
and include(normalize_uri_file("Make sure that `gem install ajp-rails -v '0.0.0' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling."))
end
diff --git a/spec/commands/list_spec.rb b/spec/commands/list_spec.rb
index fcce34cc72..346b47517e 100644
--- a/spec/commands/list_spec.rb
+++ b/spec/commands/list_spec.rb
@@ -1,15 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "bundle list", :bundler => "2" do
- before do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
-
- gem "rack"
- gem "rspec", :group => [:test]
- G
- end
-
+RSpec.describe "bundle list" do
context "with name-only and paths option" do
it "raises an error" do
bundle "list --name-only --paths"
@@ -27,6 +18,15 @@ RSpec.describe "bundle list", :bundler => "2" do
end
describe "with without-group option" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
context "when group is present" do
it "prints the gems not in the specified group" do
bundle! "list --without-group test"
@@ -46,6 +46,15 @@ RSpec.describe "bundle list", :bundler => "2" do
end
describe "with only-group option" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
context "when group is present" do
it "prints the gems in the specified group" do
bundle! "list --only-group default"
@@ -65,6 +74,15 @@ RSpec.describe "bundle list", :bundler => "2" do
end
context "with name-only option" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
it "prints only the name of the gems in the bundle" do
bundle "list --name-only"
@@ -82,7 +100,6 @@ RSpec.describe "bundle list", :bundler => "2" do
build_git "git_test", "1.0.0", :path => lib_path("git_test")
build_lib("gemspec_test", :path => tmp.join("gemspec_test")) do |s|
- s.write("Gemfile", "source :rubygems\ngemspec")
s.add_dependency "bar", "=1.0.0"
end
@@ -93,8 +110,6 @@ RSpec.describe "bundle list", :bundler => "2" do
gem "git_test", :git => "#{lib_path("git_test")}"
gemspec :path => "#{tmp.join("gemspec_test")}"
G
-
- bundle! "install"
end
it "prints the path of each gem in the bundle" do
@@ -119,13 +134,35 @@ RSpec.describe "bundle list", :bundler => "2" do
end
end
- it "lists gems installed in the bundle" do
- bundle "list"
- expect(out).to include(" * rack (1.0.0)")
+ context "without options" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
+ it "lists gems installed in the bundle" do
+ bundle "list"
+ expect(out).to include(" * rack (1.0.0)")
+ end
end
- it "aliases the ls command to list" do
- bundle "ls"
- expect(out).to include("Gems included by the bundle")
+ context "when using the ls alias" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
+ it "runs the list command" do
+ bundle "ls"
+ expect(out).to include("Gems included by the bundle")
+ end
end
end
diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb
index f876d719cc..7aaf5c178e 100644
--- a/spec/commands/lock_spec.rb
+++ b/spec/commands/lock_spec.rb
@@ -242,7 +242,7 @@ RSpec.describe "bundle lock" do
it "errors when removing all platforms" do
bundle "lock --remove-platform #{local_platforms.join(" ")}"
- expect(last_command.bundler_err).to include("Removing all platforms from the bundle is not allowed")
+ expect(err).to include("Removing all platforms from the bundle is not allowed")
end
# from https://github.com/bundler/bundler/issues/4896
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index 0d1058ad11..dcd36d3fe4 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -178,7 +178,7 @@ RSpec.describe "bundle gem" do
end
end
- it "generates a valid gemspec" do
+ it "generates a valid gemspec", :ruby_repo do
in_app_root
bundle! "gem newgem --bin"
@@ -770,22 +770,22 @@ RSpec.describe "bundle gem" do
it "fails gracefully with a ." do
bundle "gem foo.gemspec"
- expect(last_command.bundler_err).to end_with("Invalid gem name foo.gemspec -- `Foo.gemspec` is an invalid constant name")
+ expect(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(last_command.bundler_err).to end_with("Invalid gem name ^ -- `^` is an invalid constant name")
+ expect(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(last_command.bundler_err).to end_with("Invalid gem name foo bar -- `Foo bar` is an invalid constant name")
+ expect(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(last_command.bundler_err).to eq(<<-E.strip)
+ expect(err).to eq(<<-E.strip)
ERROR: "bundle gem" was called with arguments ["foo", "bar", "baz"]
Usage: "bundle gem NAME [OPTIONS]"
E
@@ -876,7 +876,7 @@ Usage: "bundle gem NAME [OPTIONS]"
FileUtils.touch("conflict-foobar")
end
bundle "gem conflict-foobar"
- expect(last_command.bundler_err).to include("Errno::ENOTDIR")
+ expect(err).to include("Errno::ENOTDIR")
expect(exitstatus).to eql(32) if exitstatus
end
end
@@ -887,7 +887,7 @@ Usage: "bundle gem NAME [OPTIONS]"
FileUtils.mkdir_p("conflict-foobar/Gemfile")
end
bundle! "gem conflict-foobar"
- expect(last_command.stdout).to include("file_clash conflict-foobar/Gemfile").
+ expect(out).to include("file_clash conflict-foobar/Gemfile").
and include "Initializing git repo in #{bundled_app("conflict-foobar")}"
end
end
diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb
index 6d43f50d74..f0c2927218 100644
--- a/spec/commands/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
@@ -206,7 +206,7 @@ RSpec.describe "bundle outdated" do
build_gem "activesupport", "2.3.4"
end
- bundle! "config clean false"
+ bundle! "config set clean false"
install_gemfile <<-G
source "file://#{gem_repo2}"
@@ -418,12 +418,12 @@ RSpec.describe "bundle outdated" do
gem "foo"
G
- bundle "config auto_install 1"
+ bundle "config set auto_install 1"
bundle :outdated
expect(out).to include("Installing foo 1.0")
end
- context "after bundle install --deployment", :bundler => "< 2" do
+ context "after bundle install --deployment", :bundler => "< 3" do
before do
install_gemfile <<-G, forgotten_command_line_options(:deployment => true)
source "file://#{gem_repo2}"
diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb
index db8a96005c..b9cc079c5c 100644
--- a/spec/commands/package_spec.rb
+++ b/spec/commands/package_spec.rb
@@ -141,7 +141,7 @@ RSpec.describe "bundle package" do
end
end
- context "with --path", :bundler => "< 2" do
+ context "with --path", :bundler => "< 3" do
it "sets root directory for gems" do
gemfile <<-D
source "file://#{gem_repo1}"
@@ -179,6 +179,18 @@ RSpec.describe "bundle package" do
expect(the_bundle).to include_gems "rack 1.0.0"
end
+
+ it "does not prevent installing gems with bundle update" do
+ gemfile <<-D
+ source "file://#{gem_repo1}"
+ gem "rack", "1.0.0"
+ D
+
+ bundle! "package --no-install"
+ bundle! "update --all"
+
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
end
context "with --all-platforms" do
@@ -205,7 +217,7 @@ RSpec.describe "bundle package" do
subject { bundle :package, forgotten_command_line_options(:frozen => true) }
it "tries to install with frozen" do
- bundle! "config deployment true"
+ bundle! "config set deployment true"
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -266,7 +278,7 @@ RSpec.describe "bundle install with gem sources" do
end
bundle :install
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(the_bundle).to include_gems "rack 1.0"
end
diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb
index d747fb9844..93eb81f2af 100644
--- a/spec/commands/pristine_spec.rb
+++ b/spec/commands/pristine_spec.rb
@@ -48,7 +48,14 @@ RSpec.describe "bundle pristine", :ruby_repo do
bundle! "install"
bundle! "pristine", :system_bundler => true
bundle! "-v", :system_bundler => true
- expect(out).to end_with(Bundler::VERSION)
+
+ expected = if Bundler::VERSION < "3.0"
+ "Bundler version"
+ else
+ Bundler::VERSION
+ end
+
+ expect(out).to start_with(expected)
end
end
diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb
index 298618747f..6e1986e35f 100644
--- a/spec/commands/show_spec.rb
+++ b/spec/commands/show_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "bundle show" do
+RSpec.describe "bundle show", :bundler => "< 3" do
context "with a standard Gemfile" do
before :each do
install_gemfile <<-G
@@ -30,7 +30,7 @@ RSpec.describe "bundle show" do
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
- it "prints deprecation", :bundler => "2" do
+ it "prints deprecation" do
bundle "show rails"
expect(err).to eq("[DEPRECATED] use `bundle info rails` instead of `bundle show rails`")
end
@@ -40,7 +40,7 @@ RSpec.describe "bundle show" do
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
- it "prints deprecation when called with a gem and the --paths option", :bundler => "2" do
+ it "prints deprecation when called with a gem and the --paths option" do
bundle "show rails --paths"
expect(err).to eq("[DEPRECATED] use `bundle info rails --path` instead of `bundle show rails --paths`")
end
@@ -59,7 +59,7 @@ RSpec.describe "bundle show" do
expect(out).to eq(root.to_s)
end
- it "prints deprecation when called with bundler", :bundler => "2" do
+ it "prints deprecation when called with bundler" do
bundle "show bundler"
expect(err).to eq("[DEPRECATED] use `bundle info bundler` instead of `bundle show bundler`")
end
@@ -79,7 +79,7 @@ RSpec.describe "bundle show" do
expect(gem_list).to eq(gem_list.sort)
end
- it "prints a deprecation when called with the --paths option", :bundler => 2 do
+ it "prints a deprecation when called with the --paths option" do
bundle "show --paths"
expect(err).to eq("[DEPRECATED] use `bundle list` instead of `bundle show --paths`")
@@ -172,6 +172,19 @@ RSpec.describe "bundle show" do
expect(out).to include("Installing foo 1.0")
end
+ context "with a valid regexp for gem name" do
+ it "presents alternatives", :ruby_repo do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ gem "rack-obama"
+ G
+
+ bundle "show rac"
+ expect(out).to eq "1 : rack\n2 : rack-obama\n0 : - exit -\n>"
+ end
+ end
+
context "with an invalid regexp for gem name" do
it "does not find the gem" do
install_gemfile <<-G
@@ -213,3 +226,7 @@ RSpec.describe "bundle show" do
end
end
end
+
+RSpec.describe "bundle show", :bundler => "3" do
+ pending "shows a friendly error about the command removal"
+end
diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb
index 25e4401e7b..735d8cd8de 100644
--- a/spec/commands/update_spec.rb
+++ b/spec/commands/update_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe "bundle update" do
G
end
- describe "with no arguments", :bundler => "< 2" do
+ describe "with no arguments", :bundler => "< 3" do
it "updates the entire bundle" do
update_repo2 do
build_gem "activesupport", "3.0"
@@ -35,7 +35,7 @@ RSpec.describe "bundle update" do
end
end
- describe "with --all", :bundler => "2" do
+ describe "with --all", :bundler => "3" do
it "updates the entire bundle" do
update_repo2 do
build_gem "activesupport", "3.0"
@@ -65,14 +65,14 @@ RSpec.describe "bundle update" do
gem "rack", "1.0"
G
- bundle! "update --gemfile OmgFile", :all => bundle_update_requires_all?
+ bundle! "update --gemfile OmgFile", :all => true
expect(bundled_app("OmgFile.lock")).to exist
end
end
context "when update_requires_all_flag is set" do
- before { bundle! "config update_requires_all_flag true" }
+ before { bundle! "config set update_requires_all_flag true" }
it "errors when passed nothing" do
install_gemfile! ""
@@ -133,7 +133,7 @@ RSpec.describe "bundle update" do
describe "when a possible resolve requires an older version of a locked gem" do
context "and only_update_to_newer_versions is set" do
before do
- bundle! "config only_update_to_newer_versions true"
+ bundle! "config set only_update_to_newer_versions true"
end
it "does not go to an older version" do
@@ -167,7 +167,7 @@ RSpec.describe "bundle update" do
end
end
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
expect(the_bundle).to include_gems("slim 3.0.9", "slim-rails 3.1.3", "slim_lint 0.16.1")
end
@@ -280,32 +280,32 @@ RSpec.describe "bundle update" do
end
describe "in a frozen bundle" do
- it "should fail loudly", :bundler => "< 2" do
+ it "should fail loudly", :bundler => "< 3" do
bundle! "install --deployment"
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
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(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
+ expect(err).to match(/freeze \nby running `bundle install --no-deployment`./m)
end
- 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).
+ it "should suggest different command when frozen is set globally", :bundler => "< 3" do
+ bundle! "config set --global frozen 1"
+ bundle "update", :all => true
+ expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
and match(/freeze \nby running `bundle config unset 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?
+ it "should suggest different command when frozen is set globally", :bundler => "3" do
+ bundle! "config set --global deployment true"
+ bundle "update", :all => true
expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
and match(/freeze \nby running `bundle config unset 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", :bundler => "< 2" do
+ it "should not update gems not included in the source that happen to have the same name", :bundler => "< 3" do
install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "activesupport"
@@ -316,7 +316,7 @@ RSpec.describe "bundle update" do
expect(the_bundle).to include_gem "activesupport 3.0"
end
- it "should not update gems not included in the source that happen to have the same name", :bundler => "2" do
+ it "should not update gems not included in the source that happen to have the same name", :bundler => "3" do
install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "activesupport"
@@ -328,7 +328,7 @@ RSpec.describe "bundle update" do
end
context "with unlock_source_unlocks_spec set to false" do
- before { bundle! "config unlock_source_unlocks_spec false" }
+ before { bundle! "config set 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
@@ -359,7 +359,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", :bundler => "< 2" do
+ it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 3" do
update_repo2 do
build_gem "fred", "2.0"
build_gem "harry", "2.0" do |s|
@@ -372,7 +372,7 @@ RSpec.describe "bundle update" do
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
+ it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "3" do
update_repo2 do
build_gem "fred", "2.0"
build_gem "harry", "2.0" do |s|
@@ -404,7 +404,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", :bundler => "< 2" do
+ it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "< 3" do
update_repo2 do
build_gem "george", "2.0"
build_gem "harry", "2.0" do |s|
@@ -418,7 +418,7 @@ RSpec.describe "bundle update" do
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
+ it "should not update the child dependencies of a gem that has the same name as the source", :bundler => "3" do
update_repo2 do
build_gem "george", "2.0"
build_gem "harry", "2.0" do |s|
@@ -473,6 +473,39 @@ RSpec.describe "bundle update in more complicated situations" do
expect(the_bundle).to include_gems "thin 2.0", "rack 10.0", "rack-obama 1.0"
end
+ it "will not warn when an explicitly updated git gem changes sha but not version" do
+ build_git "foo"
+
+ install_gemfile! <<-G
+ gem "foo", :git => '#{lib_path("foo-1.0")}'
+ G
+
+ update_git "foo" do |s|
+ s.write "lib/foo2.rb", "puts :foo2"
+ end
+
+ bundle! "update foo"
+
+ expect(last_command.stdboth).not_to include "attempted to update"
+ end
+
+ it "will not warn when changing gem sources but not versions" do
+ build_git "rack"
+
+ install_gemfile! <<-G
+ gem "rack", :git => '#{lib_path("rack-1.0")}'
+ G
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle! "update rack"
+
+ expect(last_command.stdboth).not_to include "attempted to update"
+ end
+
it "will update only from pinned source" do
install_gemfile <<-G
source "file://#{gem_repo2}"
@@ -542,7 +575,7 @@ RSpec.describe "bundle update without a Gemfile.lock" do
gem "rack", "1.0"
G
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -562,23 +595,23 @@ RSpec.describe "bundle update when a gem depends on a newer version of bundler"
G
end
- it "should explain that bundler conflicted", :bundler => "< 2" do
- bundle "update", :all => bundle_update_requires_all?
+ it "should explain that bundler conflicted", :bundler => "< 3" do
+ bundle "update", :all => true
expect(last_command.stdboth).not_to match(/in snapshot/i)
- expect(last_command.bundler_err).to match(/current Bundler version/i).
+ expect(err).to match(/current Bundler version/i).
and match(/perhaps you need to update bundler/i)
end
- it "should warn that the newer version of Bundler would conflict", :bundler => "2" do
+ it "should warn that the newer version of Bundler would conflict", :bundler => "3" do
bundle! "update", :all => true
- expect(last_command.bundler_err).to include("rails (3.0.1) has dependency bundler").
+ expect(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", :bundler => "< 2" do
+ it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 3" do
build_repo2
install_gemfile <<-G
@@ -586,19 +619,19 @@ RSpec.describe "bundle update" do
gem "activesupport"
G
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(out).to include("Using activesupport 2.3.5")
update_repo2 do
build_gem "activesupport", "3.0"
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
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" }
+ before { bundle! "config set suppress_install_using_messages true" }
it "only prints `Using` for versions that have changed" do
build_repo4 do
@@ -612,7 +645,7 @@ RSpec.describe "bundle update" do
gem "foo"
G
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
out.gsub!(/RubyGems [\d\.]+ is not threadsafe.*\n?/, "")
expect(out).to include "Resolving dependencies...\nBundle updated!"
@@ -620,7 +653,7 @@ RSpec.describe "bundle update" do
build_gem "foo", "2.0"
end
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
out.sub!("Removing foo (1.0)\n", "")
out.gsub!(/RubyGems [\d\.]+ is not threadsafe.*\n?/, "")
expect(out).to include strip_whitespace(<<-EOS).strip
@@ -811,7 +844,7 @@ RSpec.describe "bundle update conservative" do
context "with patch set as default update level in config" do
it "should do a patch level update" do
- bundle! "config --local prefer_patch true"
+ bundle! "config set --local prefer_patch true"
bundle! "update foo"
expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.0"
@@ -826,7 +859,7 @@ RSpec.describe "bundle update conservative" do
end
it "update all" do
- bundle! "update --patch", :all => bundle_update_requires_all?
+ bundle! "update --patch", :all => true
expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.1"
end
@@ -848,7 +881,7 @@ RSpec.describe "bundle update conservative" do
end
it "minor preferred" do
- bundle! "update --minor --strict", :all => bundle_update_requires_all?
+ bundle! "update --minor --strict", :all => true
expect(the_bundle).to include_gems "foo 1.5.0", "bar 2.1.1", "qux 1.1.0"
end
@@ -945,9 +978,9 @@ RSpec.describe "bundle update conservative" do
end
it "raises if too many flags are provided" do
- bundle "update --patch --minor", :all => bundle_update_requires_all?
+ bundle "update --patch --minor", :all => true
- expect(last_command.bundler_err).to eq "Provide only one of the following options: minor, patch"
+ expect(err).to eq "Provide only one of the following options: minor, patch"
end
end
end
diff --git a/spec/commands/version_spec.rb b/spec/commands/version_spec.rb
index b919c25e0f..66c7930397 100644
--- a/spec/commands/version_spec.rb
+++ b/spec/commands/version_spec.rb
@@ -2,36 +2,36 @@
RSpec.describe "bundle version" do
context "with -v" do
- it "outputs the version", :bundler => "< 2" do
+ it "outputs the version", :bundler => "< 3" do
bundle! "-v"
expect(out).to eq("Bundler version #{Bundler::VERSION}")
end
- it "outputs the version", :bundler => "2" do
+ it "outputs the version", :bundler => "3" do
bundle! "-v"
expect(out).to eq(Bundler::VERSION)
end
end
context "with --version" do
- it "outputs the version", :bundler => "< 2" do
+ it "outputs the version", :bundler => "< 3" do
bundle! "--version"
expect(out).to eq("Bundler version #{Bundler::VERSION}")
end
- it "outputs the version", :bundler => "2" do
+ it "outputs the version", :bundler => "3" 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
+ it "outputs the version with build metadata", :bundler => "< 3" 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
+ it "outputs the version with build metadata", :bundler => "3" 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
diff --git a/spec/install/allow_offline_install_spec.rb b/spec/install/allow_offline_install_spec.rb
index 4c6d77d6f3..8af88b7efe 100644
--- a/spec/install/allow_offline_install_spec.rb
+++ b/spec/install/allow_offline_install_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe "bundle install with :allow_offline_install" do
it "will install from the compact index" do
system_gems ["rack-1.0.0"], :path => :bundle_path
- bundle! "config clean false"
+ bundle! "config set clean false"
install_gemfile! <<-G, :artifice => "compact_index"
source "http://testgemserver.local"
gem "rack-obama"
diff --git a/spec/install/binstubs_spec.rb b/spec/install/binstubs_spec.rb
index 23eb691ab8..daa20693c7 100644
--- a/spec/install/binstubs_spec.rb
+++ b/spec/install/binstubs_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "bundle install", :bundler => "< 2" do
+RSpec.describe "bundle install" do
describe "when system_bindir is set" do
# On OS X, Gem.bindir defaults to /usr/bin, so system_bindir is useful if
# you want to avoid sudo installs for system gems with OS X's default ruby
@@ -20,7 +20,7 @@ RSpec.describe "bundle install", :bundler => "< 2" do
end
end
- describe "when multiple gems contain the same exe", :bundler => "< 2" do
+ describe "when multiple gems contain the same exe" do
before do
build_repo2 do
build_gem "fake", "14" do |s|
@@ -28,16 +28,25 @@ RSpec.describe "bundle install", :bundler => "< 2" do
end
end
- install_gemfile <<-G, :binstubs => true
+ install_gemfile <<-G
source "file://#{gem_repo2}"
gem "fake"
gem "rack"
G
end
- it "loads the correct spec's executable" do
- gembin("rackup")
- expect(out).to eq("1.2")
+ it "warns about the situation" do
+ bundle! "exec rackup"
+
+ expect(last_command.stderr).to include(
+ "The `rackup` executable in the `fake` gem is being loaded, but it's also present in other gems (rack).\n" \
+ "If you meant to run the executable for another gem, make sure you use a project specific binstub (`bundle binstub <gem_name>`).\n" \
+ "If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names."
+ ).or include(
+ "The `rackup` executable in the `rack` gem is being loaded, but it's also present in other gems (fake).\n" \
+ "If you meant to run the executable for another gem, make sure you use a project specific binstub (`bundle binstub <gem_name>`).\n" \
+ "If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names."
+ )
end
end
end
diff --git a/spec/install/bundler_spec.rb b/spec/install/bundler_spec.rb
index 9ec737deb5..90f7c63330 100644
--- a/spec/install/bundler_spec.rb
+++ b/spec/install/bundler_spec.rb
@@ -48,7 +48,7 @@ RSpec.describe "bundle install" do
Could not find gem 'bundler (= 0.9.2)' in any
E
- expect(last_command.bundler_err).to include(nice_error)
+ expect(err).to include(nice_error)
end
it "works for gems with multiple versions in its dependencies" do
@@ -104,7 +104,7 @@ RSpec.describe "bundle install" do
rails_fail was resolved to 1.0, which depends on
activesupport (= 1.2.3)
E
- expect(last_command.bundler_err).to include(nice_error)
+ expect(err).to include(nice_error)
end
it "causes a conflict if a child dependency conflicts with the Gemfile" do
@@ -122,11 +122,11 @@ RSpec.describe "bundle install" do
rails_fail was resolved to 1.0, which depends on
activesupport (= 1.2.3)
E
- expect(last_command.bundler_err).to include(nice_error)
+ expect(err).to include(nice_error)
end
it "can install dependencies with newer bundler version with system gems" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "rails", "3.0"
@@ -139,8 +139,8 @@ RSpec.describe "bundle install" do
end
it "can install dependencies with newer bundler version with a local path" do
- bundle! "config path .bundle"
- bundle! "config global_path_appends_ruby_scope true"
+ bundle! "config set path .bundle"
+ bundle! "config set global_path_appends_ruby_scope true"
install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "rails", "3.0"
@@ -153,7 +153,7 @@ RSpec.describe "bundle install" do
end
context "with allow_bundler_dependency_conflicts set" do
- before { bundle! "config allow_bundler_dependency_conflicts true" }
+ before { bundle! "config set allow_bundler_dependency_conflicts true" }
it "are forced to the current bundler version with warnings when no compatible version is found" do
build_repo4 do
diff --git a/spec/install/deploy_spec.rb b/spec/install/deploy_spec.rb
index ca1ba0ae58..9569b4d54c 100644
--- a/spec/install/deploy_spec.rb
+++ b/spec/install/deploy_spec.rb
@@ -8,29 +8,29 @@ RSpec.describe "install with --deployment or --frozen" do
G
end
- context "with CLI flags", :bundler => "< 2" do
+ context "with CLI flags", :bundler => "< 3" do
it "fails without a lockfile and says that --deployment requires a lock" do
bundle "install --deployment"
- expect(out).to include("The --deployment flag requires a Gemfile.lock")
+ expect(err).to include("The --deployment flag requires a Gemfile.lock")
end
it "fails without a lockfile and says that --frozen requires a lock" do
bundle "install --frozen"
- expect(out).to include("The --frozen flag requires a Gemfile.lock")
+ expect(err).to include("The --frozen flag requires a Gemfile.lock")
end
it "disallows --deployment --system" do
bundle "install --deployment --system"
- expect(out).to include("You have specified both --deployment")
- expect(out).to include("Please choose only one option")
+ expect(err).to include("You have specified both --deployment")
+ expect(err).to include("Please choose only one option")
expect(exitstatus).to eq(15) if exitstatus
end
it "disallows --deployment --path --system" do
bundle "install --deployment --path . --system"
- expect(out).to include("You have specified both --path")
- expect(out).to include("as well as --system")
- expect(out).to include("Please choose only one option")
+ expect(err).to include("You have specified both --path")
+ expect(err).to include("as well as --system")
+ expect(err).to include("Please choose only one option")
expect(exitstatus).to eq(15) if exitstatus
end
@@ -64,7 +64,7 @@ RSpec.describe "install with --deployment or --frozen" do
bundle! :install, forgotten_command_line_options(:deployment => true, :without => "test")
end
- it "works when you bundle exec bundle", :ruby_repo do
+ it "works when you bundle exec bundle" do
bundle :install
bundle "install --deployment"
bundle! "exec bundle check"
@@ -109,11 +109,11 @@ RSpec.describe "install with --deployment or --frozen" do
bundle "install"
end
- it "works with the --deployment flag if you didn't change anything", :bundler => "< 2" do
+ it "works with the --deployment flag if you didn't change anything", :bundler => "< 3" do
bundle! "install --deployment"
end
- it "works with the --frozen flag if you didn't change anything", :bundler => "< 2" do
+ it "works with the --frozen flag if you didn't change anything", :bundler => "< 3" do
bundle! "install --frozen"
end
@@ -165,7 +165,7 @@ RSpec.describe "install with --deployment or --frozen" do
expect(err).to include("The path `#{lib_path("path_gem-1.0")}` does not exist.")
end
- it "can have --frozen set via an environment variable", :bundler => "< 2" do
+ it "can have --frozen set via an environment variable", :bundler => "< 3" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -174,11 +174,11 @@ RSpec.describe "install with --deployment or --frozen" do
ENV["BUNDLE_FROZEN"] = "1"
bundle "install"
- expect(out).to include("deployment mode")
- expect(out).to include("You have added to the Gemfile")
- expect(out).to include("* rack-obama")
- expect(out).not_to include("You have deleted from the Gemfile")
- expect(out).not_to include("You have changed in the Gemfile")
+ expect(err).to include("deployment mode")
+ expect(err).to include("You have added to the Gemfile")
+ expect(err).to include("* rack-obama")
+ expect(err).not_to include("You have deleted from the Gemfile")
+ expect(err).not_to include("You have changed in the Gemfile")
end
it "can have --deployment set via an environment variable" do
@@ -212,21 +212,6 @@ RSpec.describe "install with --deployment or --frozen" do
expect(out).not_to include("* rack-obama")
end
- it "explodes with the --frozen flag if you make a change and don't check in the lockfile", :bundler => "< 2" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- gem "rack-obama", "1.1"
- G
-
- bundle :install, forgotten_command_line_options(:frozen => true)
- expect(err).to include("deployment mode")
- expect(err).to include("You have added to the Gemfile")
- expect(err).to include("* rack-obama (= 1.1)")
- expect(err).not_to include("You have deleted from the Gemfile")
- expect(err).not_to include("You have changed in the Gemfile")
- end
-
it "explodes if you remove a gem and don't check in the lockfile" do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -297,11 +282,7 @@ RSpec.describe "install with --deployment or --frozen" do
context "when replacing a host with the same host with credentials" do
let(:success_message) do
- if Bundler::VERSION.split(".", 2).first == "1"
- "Could not reach host localgemserver.test"
- else
- "Bundle complete!"
- end
+ "Bundle complete!"
end
before do
@@ -322,29 +303,31 @@ RSpec.describe "install with --deployment or --frozen" do
DEPENDENCIES
rack
G
+
+ bundle! "config set --local deployment true"
end
it "prevents the replace by default" do
- bundle :install, forgotten_command_line_options(:deployment => true)
+ bundle :install
expect(err).to match(/The list of sources changed/)
end
context "when allow_deployment_source_credential_changes is true" do
- before { bundle! "config allow_deployment_source_credential_changes true" }
+ before { bundle! "config set allow_deployment_source_credential_changes true" }
it "allows the replace" do
- bundle :install, forgotten_command_line_options(:deployment => true)
+ bundle :install
expect(out).to match(/#{success_message}/)
end
end
context "when allow_deployment_source_credential_changes is false" do
- before { bundle! "config allow_deployment_source_credential_changes false" }
+ before { bundle! "config set allow_deployment_source_credential_changes false" }
it "prevents the replace" do
- bundle :install, forgotten_command_line_options(:deployment => true)
+ bundle :install
expect(err).to match(/The list of sources changed/)
end
@@ -354,7 +337,7 @@ RSpec.describe "install with --deployment or --frozen" do
before { ENV["BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES"] = "true" }
it "allows the replace" do
- bundle :install, forgotten_command_line_options(:deployment => true)
+ bundle :install
expect(out).to match(/#{success_message}/)
end
@@ -364,7 +347,7 @@ RSpec.describe "install with --deployment or --frozen" do
before { ENV["BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES"] = "false" }
it "prevents the replace" do
- bundle :install, forgotten_command_line_options(:deployment => true)
+ bundle :install
expect(err).to match(/The list of sources changed/)
end
@@ -374,7 +357,7 @@ RSpec.describe "install with --deployment or --frozen" do
it "remembers that the bundle is frozen at runtime" do
bundle! :lock
- bundle! "config deployment true"
+ bundle! "config set --local deployment true"
gemfile <<-G
source "file://#{gem_repo1}"
@@ -383,7 +366,7 @@ RSpec.describe "install with --deployment or --frozen" do
G
expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(last_command.stderr).to include strip_whitespace(<<-E).strip
+ expect(err).to include strip_whitespace(<<-E).strip
The dependencies in your gemfile changed
You have added to the Gemfile:
@@ -412,7 +395,8 @@ You have deleted from the Gemfile:
expect(out).to include("Updating files in vendor/cache")
simulate_new_machine
- bundle! "install --verbose", forgotten_command_line_options(:deployment => true)
+ bundle! "config set --local deployment true"
+ bundle! "install --verbose"
expect(out).not_to include("You are trying to install in deployment mode after changing your Gemfile")
expect(out).not_to include("You have added to the Gemfile")
expect(out).not_to include("You have deleted from the Gemfile")
diff --git a/spec/install/failure_spec.rb b/spec/install/failure_spec.rb
index 49e2771dca..ac3c707187 100644
--- a/spec/install/failure_spec.rb
+++ b/spec/install/failure_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe "bundle install" do
source "file:\/\/localhost#{gem_repo2}"
gem "rails"
G
- expect(last_command.bundler_err).to end_with(normalize_uri_file(<<-M.strip))
+ expect(err).to end_with(normalize_uri_file(<<-M.strip))
An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
Make sure that `gem install activesupport -v '2.3.2' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling.
@@ -46,7 +46,7 @@ In Gemfile:
gem "activesupport", :git => "#{lib_path("activesupport")}"
G
- expect(last_command.bundler_err).to end_with(<<-M.strip)
+ expect(err).to end_with(<<-M.strip)
An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
In Gemfile:
@@ -77,7 +77,7 @@ In Gemfile:
end
G
- expect(last_command.bundler_err).to end_with(<<-M.strip)
+ expect(err).to end_with(<<-M.strip)
An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
@@ -111,7 +111,7 @@ In Gemfile:
gem "rails"
end
G
- expect(last_command.bundler_err).to end_with(normalize_uri_file(<<-M.strip))
+ expect(err).to end_with(normalize_uri_file(<<-M.strip))
An error occurred while installing activesupport (2.3.2), and Bundler cannot continue.
Make sure that `gem install activesupport -v '2.3.2' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling.
diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb
index ff0f7a8445..bf1f4d7b9a 100644
--- a/spec/install/gemfile/gemspec_spec.rb
+++ b/spec/install/gemfile/gemspec_spec.rb
@@ -65,7 +65,7 @@ RSpec.describe "bundle install from an existing gemspec" do
source "file://#{gem_repo2}"
gemspec :path => '#{tmp.join("foo")}'
G
- expect(last_command.bundler_err).to match(/There are no gemspecs at #{tmp.join('foo')}/)
+ expect(err).to match(/There are no gemspecs at #{tmp.join('foo')}/)
end
it "should raise if there are too many gemspecs available" do
@@ -77,7 +77,7 @@ RSpec.describe "bundle install from an existing gemspec" do
source "file://#{gem_repo2}"
gemspec :path => '#{tmp.join("foo")}'
G
- expect(last_command.bundler_err).to match(/There are multiple gemspecs at #{tmp.join('foo')}/)
+ expect(err).to match(/There are multiple gemspecs at #{tmp.join('foo')}/)
end
it "should pick a specific gemspec" do
@@ -447,7 +447,7 @@ RSpec.describe "bundle install from an existing gemspec" do
end
end
- context "on ruby", :bundler => "< 2" do
+ context "on ruby" do
before do
simulate_platform("ruby")
bundle :install
@@ -547,107 +547,6 @@ RSpec.describe "bundle install from an existing gemspec" do
end
end
end
-
- context "on ruby", :bundler => "2" do
- before do
- simulate_platform("ruby")
- bundle :install
- end
-
- context "as a runtime dependency" do
- it "keeps java dependencies in the lockfile" do
- expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
- expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L))
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
- platform_specific (1.0)
- platform_specific (1.0-java)
-
- PATH
- remote: .
- specs:
- foo (1.0)
- platform_specific
-
- PLATFORMS
- java
- ruby
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
-
- context "as a development dependency" do
- let(:platform_specific_type) { :development }
-
- it "keeps java dependencies in the lockfile" do
- expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
- expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L))
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
- platform_specific (1.0)
- platform_specific (1.0-java)
-
- PATH
- remote: .
- specs:
- foo (1.0)
-
- PLATFORMS
- java
- ruby
-
- DEPENDENCIES
- foo!
- platform_specific
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
-
- context "with an indirect platform-specific development dependency" do
- let(:platform_specific_type) { :development }
- let(:dependency) { "indirect_platform_specific" }
-
- it "keeps java dependencies in the lockfile" do
- expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY"
- expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L))
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
- indirect_platform_specific (1.0)
- platform_specific
- platform_specific (1.0)
- platform_specific (1.0-java)
-
- PATH
- remote: .
- specs:
- foo (1.0)
-
- PLATFORMS
- java
- ruby
-
- DEPENDENCIES
- foo!
- indirect_platform_specific
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
- end
end
end
diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb
index 2cb6c7485f..8ca22f1d87 100644
--- a/spec/install/gemfile/git_spec.rb
+++ b/spec/install/gemfile/git_spec.rb
@@ -26,13 +26,13 @@ RSpec.describe "bundle install with git sources" do
expect(out).to eq("WIN")
end
- it "caches the git repo", :bundler => "< 2" do
+ it "caches the git repo", :bundler => "< 3" do
expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"]).to have_attributes :size => 1
end
it "caches the git repo globally" do
simulate_new_machine
- bundle! "config global_gem_cache true"
+ bundle! "config set global_gem_cache true"
bundle! :install
expect(Dir["#{home}/.bundle/cache/git/foo-1.0-*"]).to have_attributes :size => 1
end
@@ -204,7 +204,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo"
end
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
run <<-RUBY
require 'foo'
@@ -234,7 +234,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo"
end
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
run! <<-RUBY
require 'foo'
@@ -270,7 +270,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo"
end
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
run! <<-RUBY
require 'foo'
@@ -285,7 +285,7 @@ RSpec.describe "bundle install with git sources" do
sys_exec!('git update-ref -m "Bundler Spec!" refs/bundler/1 master~1')
end
- bundle! "config global_gem_cache true"
+ bundle! "config set global_gem_cache true"
install_gemfile! <<-G
git "#{lib_path("foo-1.0")}" do
@@ -294,7 +294,7 @@ RSpec.describe "bundle install with git sources" do
G
# ensure we also git fetch after cloning
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
Dir.chdir(Dir[home(".bundle/cache/git/foo-*")].first) do
sys_exec("git ls-remote .")
@@ -406,7 +406,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle! %(config local.rack #{lib_path("local-rack")})
+ bundle! %(config set local.rack #{lib_path("local-rack")})
bundle! :install
run "require 'rack'"
@@ -427,7 +427,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
run "require 'rack'"
expect(out).to eq("LOCAL")
end
@@ -447,7 +447,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle! %(config local.rack #{lib_path("local-rack")})
+ bundle! %(config set local.rack #{lib_path("local-rack")})
bundle! :install
run! "require 'rack'"
expect(out).to eq("LOCAL")
@@ -470,7 +470,7 @@ RSpec.describe "bundle install with git sources" do
s.add_dependency "nokogiri", "1.4.2"
end
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
run "require 'rack'"
lockfile1 = File.read(bundled_app("Gemfile.lock"))
@@ -490,7 +490,7 @@ RSpec.describe "bundle install with git sources" do
FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
update_git "rack", "0.8", :path => lib_path("local-rack")
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle :install
lockfile1 = File.read(bundled_app("Gemfile.lock"))
@@ -505,7 +505,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle :install
expect(err).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
@@ -515,7 +515,7 @@ RSpec.describe "bundle install with git sources" do
bundle solution
bundle :install
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "explodes and gives correct solution if branch is not given on install" do
@@ -527,7 +527,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle :install
expect(err).to match(/Cannot use local override for rack-0.8 at #{Regexp.escape(lib_path('local-rack').to_s)} because :branch is not specified in Gemfile/)
@@ -537,7 +537,7 @@ RSpec.describe "bundle install with git sources" do
bundle solution
bundle :install
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "does not explode if disable_local_branch_check is given" do
@@ -549,8 +549,8 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}"
G
- bundle %(config local.rack #{lib_path("local-rack")})
- bundle %(config disable_local_branch_check true)
+ bundle %(config set local.rack #{lib_path("local-rack")})
+ bundle %(config set disable_local_branch_check true)
bundle :install
expect(out).to match(/Bundle complete!/)
end
@@ -569,7 +569,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle :install
expect(err).to match(/is using branch another but Gemfile specifies master/)
end
@@ -586,7 +586,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle :install
expect(err).to match(/The Gemfile lock is pointing to revision \w+/)
end
@@ -725,7 +725,7 @@ RSpec.describe "bundle install with git sources" do
build_lib "bar", :path => lib_path("foo/bar"), :gemspec => false do |s|
s.write lib_path("foo/bar/lib/version.rb"), %(BAR_VERSION = '1.0')
s.write "bar.gemspec", <<-G
- $:.unshift Dir.pwd # For 1.9
+ $:.unshift Dir.pwd
require 'lib/version'
Gem::Specification.new do |s|
s.name = 'bar'
@@ -814,14 +814,14 @@ RSpec.describe "bundle install with git sources" do
s.write "lib/forced.rb", "FORCED = '1.1'"
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "forced 1.1"
Dir.chdir(lib_path("forced-1.0")) do
`git reset --hard HEAD^`
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "forced 1.0"
end
@@ -1197,7 +1197,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo", :git => "#{lib_path("foo-1.0")}"
G
- expect(last_command.bundler_err).to end_with(<<-M.strip)
+ expect(err).to end_with(<<-M.strip)
An error occurred while installing foo (1.0), and Bundler cannot continue.
In Gemfile:
@@ -1247,7 +1247,7 @@ In Gemfile:
expect(out).to eq(installed_time)
end
- it "does not reinstall the extension when changing another gem" do
+ it "does not reinstall the extension when changing another gem", :ruby_repo do
build_git "foo" do |s|
s.add_dependency "rake"
s.extensions << "Rakefile"
@@ -1290,7 +1290,7 @@ In Gemfile:
expect(out).to eq(installed_time)
end
- it "does reinstall the extension when changing refs" do
+ it "does reinstall the extension when changing refs", :ruby_repo do
build_git "foo" do |s|
s.add_dependency "rake"
s.extensions << "Rakefile"
@@ -1378,9 +1378,9 @@ In Gemfile:
G
with_path_as("") do
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
end
- expect(last_command.bundler_err).
+ expect(err).
to include("You need to install git to be able to use gems from git repositories. For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git")
end
@@ -1402,7 +1402,7 @@ In Gemfile:
describe "when the git source is overridden with a local git repo" do
before do
- bundle! "config --global local.foo #{lib_path("foo")}"
+ bundle! "config set --global local.foo #{lib_path("foo")}"
end
describe "and git output is colorized" do
@@ -1437,7 +1437,7 @@ In Gemfile:
G
expect(last_command.stdboth).to_not include("password1")
- expect(last_command.stdout).to include("Fetching https://user1@github.com/company/private-repo")
+ expect(out).to include("Fetching https://user1@github.com/company/private-repo")
end
end
@@ -1452,7 +1452,7 @@ In Gemfile:
G
expect(last_command.stdboth).to_not include("oauth_token")
- expect(last_command.stdout).to include("Fetching https://x-oauth-basic@github.com/company/private-repo")
+ expect(out).to include("Fetching https://x-oauth-basic@github.com/company/private-repo")
end
end
end
diff --git a/spec/install/gemfile/groups_spec.rb b/spec/install/gemfile/groups_spec.rb
index 2787172057..f836499148 100644
--- a/spec/install/gemfile/groups_spec.rb
+++ b/spec/install/gemfile/groups_spec.rb
@@ -192,22 +192,22 @@ RSpec.describe "bundle install with groups" do
expect(the_bundle).not_to include_gems "thin 1.0"
end
- it "does remove groups from without when passed at --with", :bundler => "< 2" do
+ it "does remove groups from without when passed at --with", :bundler => "< 3" do
bundle :install, forgotten_command_line_options(:without => "emo")
bundle :install, forgotten_command_line_options(:with => "emo")
expect(the_bundle).to include_gems "activesupport 2.3.5"
end
- it "does remove groups from with when passed at --without", :bundler => "< 2" do
+ it "does remove groups from with when passed at --without", :bundler => "< 3" do
bundle :install, forgotten_command_line_options(:with => "debugging")
bundle :install, forgotten_command_line_options(:without => "debugging")
expect(the_bundle).not_to include_gem "thin 1.0"
end
- it "errors out when passing a group to with and without via CLI flags", :bundler => "< 2" do
+ it "errors out when passing a group to with and without via CLI flags", :bundler => "< 3" do
bundle :install, forgotten_command_line_options(:with => "emo debugging", :without => "emo")
expect(last_command).to be_failure
- expect(out).to include("The offending groups are: emo")
+ expect(err).to include("The offending groups are: emo")
end
it "allows the BUNDLE_WITH setting to override BUNDLE_WITHOUT" do
diff --git a/spec/install/gemfile/lockfile_spec.rb b/spec/install/gemfile/lockfile_spec.rb
index dc1baca6ea..96cd5067be 100644
--- a/spec/install/gemfile/lockfile_spec.rb
+++ b/spec/install/gemfile/lockfile_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe "bundle install with a lockfile present" do
context "with plugins disabled" do
before do
- bundle! "config plugins false"
+ bundle! "config set plugins false"
subject
end
diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb
index 40c137cd4a..c6856ac974 100644
--- a/spec/install/gemfile/path_spec.rb
+++ b/spec/install/gemfile/path_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "bundle install with explicit source paths" do
- it "fetches gems with a global path source", :bundler => "< 2" do
+ it "fetches gems with a global path source", :bundler => "< 3" do
build_lib "foo"
install_gemfile <<-G
@@ -313,7 +313,7 @@ RSpec.describe "bundle install with explicit source paths" do
install_gemfile <<-G
gem 'foo', '1.0', :path => "#{lib_path("foo-1.0")}"
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "removes the .gem file after installing" do
diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb
index f157e9b263..891f766cc0 100644
--- a/spec/install/gemfile/platform_spec.rb
+++ b/spec/install/gemfile/platform_spec.rb
@@ -230,7 +230,7 @@ RSpec.describe "bundle install across platforms" do
expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
end
- it "works with gems that have extra platform-specific runtime dependencies", :bundler => "< 2" do
+ it "works with gems that have extra platform-specific runtime dependencies", :bundler => "< 3" do
simulate_platform x64_mac
update_repo2 do
@@ -248,7 +248,7 @@ RSpec.describe "bundle install across platforms" do
gem "facter"
G
- expect(out).to include "Unable to use the platform-specific (universal-darwin) version of facter (2.4.6) " \
+ expect(err).to include "Unable to use the platform-specific (universal-darwin) version of facter (2.4.6) " \
"because it has different dependencies from the ruby version. " \
"To use the platform-specific version of the gem, run `bundle config set specific_platform true` and install again."
@@ -265,8 +265,7 @@ RSpec.describe "bundle install across platforms" do
bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
- new_version = Gem::ConfigMap[:ruby_version] == "1.8" ? "1.9.1" : "1.8"
- FileUtils.mv(vendored_gems, bundled_app("vendor/bundle", Gem.ruby_engine, new_version))
+ FileUtils.mv(vendored_gems, bundled_app("vendor/bundle", Gem.ruby_engine, "1.8"))
bundle! :install
expect(vendored_gems("gems/rack-1.0.0")).to exist
@@ -391,7 +390,7 @@ The dependency #{Gem::Dependency.new("rack", ">= 0")} will be unused by any of t
end
context "when disable_platform_warnings is true" do
- before { bundle! "config disable_platform_warnings true" }
+ before { bundle! "config set disable_platform_warnings true" }
it "does not print the warning when a dependency is unused on any platform" do
simulate_platform "ruby"
diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb
index 2ab1f29de5..8e1205dfa3 100644
--- a/spec/install/gemfile/sources_spec.rb
+++ b/spec/install/gemfile/sources_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
- context "with multiple toplevel sources", :bundler => "< 2" do
+ context "with multiple toplevel sources", :bundler => "< 3" do
let(:repo3_rack_version) { "1.0.0" }
before do
@@ -27,13 +27,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
G
end
- xit "shows a deprecation" do
- bundle :install
-
- expect(deprecations).to include("Your Gemfile contains multiple primary sources.")
- end
-
- it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first" do
+ it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first", :bundler => "2" do
bundle :install
expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
@@ -41,15 +35,14 @@ RSpec.describe "bundle install with gems on multiple sources" do
expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
end
- it "errors when disable_multisource is set" do
- bundle "config set disable_multisource true"
+ it "fails", :bundler => "3" do
bundle :install
expect(err).to include("Each source after the first must include a block")
expect(exitstatus).to eq(4) if exitstatus
end
end
- context "when different versions of the same gem are in multiple sources", :bundler => "< 2" do
+ context "when different versions of the same gem are in multiple sources", :bundler => "< 3" do
let(:repo3_rack_version) { "1.2" }
before do
@@ -63,15 +56,16 @@ RSpec.describe "bundle install with gems on multiple sources" do
bundle :install
end
- xit "shows a deprecation" do
- expect(deprecations).to include("Your Gemfile contains multiple primary sources.")
- end
-
- it "warns about ambiguous gems, but installs anyway" do
+ it "warns about ambiguous gems, but installs anyway", :bundler => "2" do
expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(err).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo1}"))
expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
end
+
+ it "fails", :bundler => "3" do
+ expect(err).to include("Each source after the first must include a block")
+ expect(exitstatus).to eq(4) if exitstatus
+ end
end
end
@@ -193,10 +187,9 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
- context "when lockfile_uses_separate_rubygems_sources is set" do
+ context "when disable_multisource is set" do
before do
- bundle! "config lockfile_uses_separate_rubygems_sources true"
- bundle! "config disable_multisource true"
+ bundle! "config set disable_multisource true"
end
it "installs from the same source without any warning" do
@@ -243,7 +236,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
- context "and in yet another source", :bundler => "< 2" do
+ context "and in yet another source", :bundler => "< 3" do
before do
gemfile <<-G
source "file://localhost#{gem_repo1}"
@@ -256,18 +249,19 @@ RSpec.describe "bundle install with gems on multiple sources" do
bundle :install
end
- xit "shows a deprecation" do
- expect(deprecations).to include("Your Gemfile contains multiple primary sources.")
- end
-
- it "installs from the other source and warns about ambiguous gems" do
+ it "installs from the other source and warns about ambiguous gems", :bundler => "2" do
expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(err).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo2}"))
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
+
+ it "fails", :bundler => "3" do
+ expect(err).to include("Each source after the first must include a block")
+ expect(exitstatus).to eq(4) if exitstatus
+ end
end
- context "and only the dependency is pinned", :bundler => "< 2" do
+ context "and only the dependency is pinned", :bundler => "< 3" do
before do
# need this to be broken to check for correct source ordering
build_repo gem_repo2 do
@@ -285,7 +279,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
G
end
- it "installs the dependency from the pinned source without warning" do
+ it "installs the dependency from the pinned source without warning", :bundler => "2" do
bundle :install
expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.")
@@ -299,15 +293,20 @@ RSpec.describe "bundle install with gems on multiple sources" do
expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.")
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
+
+ it "fails", :bundler => "3" do
+ bundle :install
+ expect(err).to include("Each source after the first must include a block")
+ expect(exitstatus).to eq(4) if exitstatus
+ end
end
end
end
context "when a top-level gem has an indirect dependency" do
- context "when lockfile_uses_separate_rubygems_sources is set" do
+ context "when disable_multisource is set" do
before do
- bundle! "config lockfile_uses_separate_rubygems_sources true"
- bundle! "config disable_multisource true"
+ bundle! "config set disable_multisource true"
end
before do
@@ -626,7 +625,39 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
- context "when a gem is available from multiple ambiguous sources", :bundler => "2" do
+ describe "source changed to one containing a higher version of a dependency" do
+ before do
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ G
+
+ build_repo2 do
+ build_gem "bar"
+ end
+
+ build_lib("gemspec_test", :path => tmp.join("gemspec_test")) do |s|
+ s.add_dependency "bar", "=1.0.0"
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "rack"
+ gemspec :path => "#{tmp.join("gemspec_test")}"
+ G
+ end
+
+ it "keeps the old version", :bundler => "2" do
+ expect(the_bundle).to include_gems("rack 1.0.0")
+ end
+
+ it "installs the higher version in the new repo", :bundler => "3" do
+ expect(the_bundle).to include_gems("rack 1.2")
+ end
+ end
+
+ context "when a gem is available from multiple ambiguous sources", :bundler => "3" do
it "raises, suggesting a source block" do
build_repo4 do
build_gem "depends_on_rack" do |s|
diff --git a/spec/install/gemfile_spec.rb b/spec/install/gemfile_spec.rb
index 5d8cdb0163..c26fbd74e7 100644
--- a/spec/install/gemfile_spec.rb
+++ b/spec/install/gemfile_spec.rb
@@ -68,22 +68,6 @@ RSpec.describe "bundle install" do
end
end
- context "with prefer_gems_rb set" do
- before { bundle! "config prefer_gems_rb true" }
-
- it "prefers gems.rb to Gemfile" do
- create_file("gems.rb", "gem 'bundler'")
- create_file("Gemfile", "raise 'wrong Gemfile!'")
-
- bundle! :install
-
- expect(bundled_app("gems.rb")).to be_file
- expect(bundled_app("Gemfile.lock")).not_to be_file
-
- expect(the_bundle).to include_gem "bundler #{Bundler::VERSION}"
- end
- end
-
context "with engine specified in symbol" do
it "does not raise any error parsing Gemfile" do
simulate_ruby_version "2.3.0" do
diff --git a/spec/install/gems/compact_index_spec.rb b/spec/install/gems/compact_index_spec.rb
index 01ad1f991f..e35b630306 100644
--- a/spec/install/gems/compact_index_spec.rb
+++ b/spec/install/gems/compact_index_spec.rb
@@ -60,7 +60,7 @@ RSpec.describe "compact index api" do
# can't use `include_gems` here since the `require` will conflict on a
# case-insensitive FS
run! "Bundler.require; puts Gem.loaded_specs.values_at('rack', 'Rack').map(&:full_name)"
- expect(last_command.stdout).to eq("rack-1.0\nRack-0.1")
+ expect(out).to eq("rack-1.0\nRack-0.1")
end
it "should handle multiple gem dependencies on the same gem" do
@@ -247,7 +247,7 @@ The checksum of /versions does not match the checksum provided by the server! So
gem "rack"
G
- bundle! "update --full-index", :artifice => "compact_index", :all => bundle_update_requires_all?
+ bundle! "update --full-index", :artifice => "compact_index", :all => true
expect(out).to include("Fetching source index from #{source_uri}")
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -255,7 +255,7 @@ The checksum of /versions does not match the checksum provided by the server! So
it "does not double check for gems that are only installed locally" do
system_gems %w[rack-1.0.0 thin-1.0 net_a-1.0]
- bundle! "config --local path.system true"
+ bundle! "config set --local path.system true"
ENV["BUNDLER_SPEC_ALL_REQUESTS"] = strip_whitespace(<<-EOS).strip
#{source_uri}/versions
#{source_uri}/info/rack
@@ -269,7 +269,7 @@ The checksum of /versions does not match the checksum provided by the server! So
expect(last_command.stdboth).not_to include "Double checking"
end
- it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 2" do
+ it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 3" do
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -328,7 +328,7 @@ The checksum of /versions does not match the checksum provided by the server! So
expect(the_bundle).to include_gems "rack 1.2"
end
- it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 2" do
+ it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 3" do
# In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that
# exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0
# of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other
@@ -352,7 +352,7 @@ The checksum of /versions does not match the checksum provided by the server! So
expect(the_bundle).to include_gems "activesupport 1.2.3"
end
- it "considers all possible versions of dependencies from all api gem sources when using blocks", :bundler => "< 2" do
+ it "considers all possible versions of dependencies from all api gem sources when using blocks", :bundler => "< 3" do
# In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that
# exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0
# of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other
@@ -458,7 +458,7 @@ The checksum of /versions does not match the checksum provided by the server! So
expect(the_bundle).to include_gems "foo 1.0"
end
- it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 2" do
+ it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 3" do
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -522,7 +522,7 @@ The checksum of /versions does not match the checksum provided by the server! So
expect(the_bundle).to include_gems "rails 2.3.2"
end
- it "installs the binstubs", :bundler => "< 2" do
+ it "installs the binstubs", :bundler => "< 3" do
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -534,7 +534,7 @@ The checksum of /versions does not match the checksum provided by the server! So
expect(out).to eq("1.0.0")
end
- it "installs the bins when using --path and uses autoclean", :bundler => "< 2" do
+ it "installs the bins when using --path and uses autoclean", :bundler => "< 3" do
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -545,7 +545,7 @@ The checksum of /versions does not match the checksum provided by the server! So
expect(vendored_gems("bin/rackup")).to exist
end
- it "installs the bins when using --path and uses bundle clean", :bundler => "< 2" do
+ it "installs the bins when using --path and uses bundle clean", :bundler => "< 3" do
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -620,7 +620,7 @@ The checksum of /versions does not match the checksum provided by the server! So
expect(out).not_to include("#{user}:#{password}")
end
- it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 2" do
+ it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do
gemfile <<-G
source "#{basic_auth_source_uri}"
source "file://#{gem_repo1}"
@@ -628,8 +628,8 @@ The checksum of /versions does not match the checksum provided by the server! So
G
bundle! :install, :artifice => "compact_index_basic_authentication"
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).not_to include("#{user}:#{password}")
+ expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
+ expect(err).not_to include("#{user}:#{password}")
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -894,7 +894,7 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "does not raise when disable_checksum_validation is set" do
- bundle! "config disable_checksum_validation true"
+ bundle! "config set disable_checksum_validation true"
install_gemfile! <<-G, :artifice => "compact_index_wrong_gem_checksum"
source "#{source_uri}"
gem "rack"
diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb
index f4b218849c..0dc1ee87f2 100644
--- a/spec/install/gems/dependency_api_spec.rb
+++ b/spec/install/gems/dependency_api_spec.rb
@@ -237,13 +237,13 @@ RSpec.describe "gemcutter's dependency API" do
gem "rack"
G
- bundle! "update --full-index", :artifice => "endpoint", :all => bundle_update_requires_all?
+ bundle! "update --full-index", :artifice => "endpoint", :all => true
expect(out).to include("Fetching source index from #{source_uri}")
expect(the_bundle).to include_gems "rack 1.0.0"
end
end
- it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 2" do
+ it "fetches again when more dependencies are found in subsequent sources", :bundler => "< 3" do
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -302,7 +302,7 @@ RSpec.describe "gemcutter's dependency API" do
expect(the_bundle).to include_gems "rack 1.2"
end
- it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 2" do
+ it "considers all possible versions of dependencies from all api gem sources", :bundler => "< 3" do
# In this scenario, the gem "somegem" only exists in repo4. It depends on specific version of activesupport that
# exists only in repo1. There happens also be a version of activesupport in repo4, but not the one that version 1.0.0
# of somegem wants. This test makes sure that bundler actually finds version 1.2.3 of active support in the other
@@ -372,7 +372,7 @@ RSpec.describe "gemcutter's dependency API" do
expect(out).to include("Fetching source index from http://localgemserver.test/extra")
end
- it "does not fetch every spec if the index of gems is large when doing back deps", :bundler => "< 2" do
+ it "does not fetch every spec if the index of gems is large when doing back deps", :bundler => "< 3" do
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -432,7 +432,7 @@ RSpec.describe "gemcutter's dependency API" do
expect(the_bundle).to include_gems "foo 1.0"
end
- it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 2" do
+ it "fetches again when more dependencies are found in subsequent sources using --deployment", :bundler => "< 3" do
build_repo2 do
build_gem "back_deps" do |s|
s.add_dependency "foo"
@@ -496,7 +496,7 @@ RSpec.describe "gemcutter's dependency API" do
expect(the_bundle).to include_gems "rails 2.3.2"
end
- it "installs the binstubs", :bundler => "< 2" do
+ it "installs the binstubs", :bundler => "< 3" do
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -508,7 +508,7 @@ RSpec.describe "gemcutter's dependency API" do
expect(out).to eq("1.0.0")
end
- it "installs the bins when using --path and uses autoclean", :bundler => "< 2" do
+ it "installs the bins when using --path and uses autoclean", :bundler => "< 3" do
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -519,7 +519,7 @@ RSpec.describe "gemcutter's dependency API" do
expect(vendored_gems("bin/rackup")).to exist
end
- it "installs the bins when using --path and uses bundle clean", :bundler => "< 2" do
+ it "installs the bins when using --path and uses bundle clean", :bundler => "< 3" do
gemfile <<-G
source "#{source_uri}"
gem "rack"
@@ -594,7 +594,7 @@ RSpec.describe "gemcutter's dependency API" do
expect(out).not_to include("#{user}:#{password}")
end
- it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 2" do
+ it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do
gemfile <<-G
source "#{basic_auth_source_uri}"
source "file://#{gem_repo1}"
@@ -602,8 +602,8 @@ RSpec.describe "gemcutter's dependency API" do
G
bundle :install, :artifice => "endpoint_basic_authentication"
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).not_to include("#{user}:#{password}")
+ expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
+ expect(err).not_to include("#{user}:#{password}")
expect(the_bundle).to include_gems "rack 1.0.0"
end
diff --git a/spec/install/gems/flex_spec.rb b/spec/install/gems/flex_spec.rb
index 12bc2877ff..d15841124a 100644
--- a/spec/install/gems/flex_spec.rb
+++ b/spec/install/gems/flex_spec.rb
@@ -188,7 +188,7 @@ RSpec.describe "bundle flex_install" do
ruby <<-RUBY
require 'bundler/setup'
RUBY
- expect(last_command.stderr).to match(/could not find gem 'rack-obama/i)
+ expect(err).to match(/could not find gem 'rack-obama/i)
end
it "suggests bundle update when the Gemfile requires different versions than the lock" do
@@ -209,7 +209,7 @@ RSpec.describe "bundle flex_install" do
E
bundle :install, :retry => 0
- expect(last_command.bundler_err).to end_with(nice_error)
+ expect(err).to end_with(nice_error)
end
end
@@ -244,7 +244,7 @@ RSpec.describe "bundle flex_install" do
end
describe "when adding a new source" do
- it "updates the lockfile", :bundler => "< 2" do
+ it "updates the lockfile", :bundler => "< 3" do
build_repo2
install_gemfile! <<-G
source "file://localhost#{gem_repo1}"
@@ -264,7 +264,7 @@ RSpec.describe "bundle flex_install" do
rack (1.0.0)
PLATFORMS
- ruby
+ #{lockfile_platforms}
DEPENDENCIES
rack
@@ -274,7 +274,7 @@ RSpec.describe "bundle flex_install" do
L
end
- it "updates the lockfile", :bundler => "2" do
+ it "updates the lockfile", :bundler => "3" do
build_repo2
install_gemfile! <<-G
source "file://localhost#{gem_repo1}"
diff --git a/spec/install/gems/native_extensions_spec.rb b/spec/install/gems/native_extensions_spec.rb
index 7a43252f84..9176a07084 100644
--- a/spec/install/gems/native_extensions_spec.rb
+++ b/spec/install/gems/native_extensions_spec.rb
@@ -76,7 +76,48 @@ RSpec.describe "installing a gem with native extensions", :ruby_repo do
C
end
- bundle! "config build.c_extension --with-c_extension=hello"
+ bundle! "config set build.c_extension --with-c_extension=hello"
+
+ install_gemfile! <<-G
+ gem "c_extension", :git => #{lib_path("c_extension-1.0").to_s.dump}
+ G
+
+ expect(out).not_to include("extconf.rb failed")
+
+ run! "Bundler.require; puts CExtension.new.its_true"
+ expect(out).to eq("true")
+ end
+
+ it "install with multiple build flags" do
+ build_git "c_extension" do |s|
+ s.extensions = ["ext/extconf.rb"]
+ s.write "ext/extconf.rb", <<-E
+ require "mkmf"
+ name = "c_extension_bundle"
+ dir_config(name)
+ raise "OMG" unless with_config("c_extension") == "hello" && with_config("c_extension_bundle-dir") == "hola"
+ create_makefile(name)
+ E
+
+ s.write "ext/c_extension.c", <<-C
+ #include "ruby.h"
+
+ VALUE c_extension_true(VALUE self) {
+ return Qtrue;
+ }
+
+ void Init_c_extension_bundle() {
+ VALUE c_Extension = rb_define_class("CExtension", rb_cObject);
+ rb_define_method(c_Extension, "its_true", c_extension_true, 0);
+ }
+ C
+
+ s.write "lib/c_extension.rb", <<-C
+ require "c_extension_bundle"
+ C
+ end
+
+ bundle! "config set build.c_extension --with-c_extension=hello --with-c_extension_bundle-dir=hola"
install_gemfile! <<-G
gem "c_extension", :git => #{lib_path("c_extension-1.0").to_s.dump}
diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb
index cf3aaa719e..7bab676cea 100644
--- a/spec/install/gems/resolving_spec.rb
+++ b/spec/install/gems/resolving_spec.rb
@@ -77,7 +77,7 @@ RSpec.describe "bundle install with install-time dependencies" do
bundle :install, :env => { "DEBUG_RESOLVER" => "1" }
- expect(last_command.stderr).to include("Creating possibility state for net_c")
+ expect(err).to include("Creating possibility state for net_c")
end
end
@@ -91,7 +91,7 @@ RSpec.describe "bundle install with install-time dependencies" do
bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1" }
- expect(last_command.stderr).to include(" net_b").
+ expect(err).to include(" net_b").
and include("Starting resolution").
and include("Finished resolution").
and include("Attempting to activate")
@@ -171,7 +171,7 @@ RSpec.describe "bundle install with install-time dependencies" do
Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation
E
- expect(last_command.bundler_err).to end_with(nice_error)
+ expect(err).to end_with(nice_error)
end
end
diff --git a/spec/install/gems/standalone_spec.rb b/spec/install/gems/standalone_spec.rb
index 2c7dd09f91..68796977a4 100644
--- a/spec/install/gems/standalone_spec.rb
+++ b/spec/install/gems/standalone_spec.rb
@@ -175,8 +175,8 @@ RSpec.shared_examples "bundle install --standalone" do
RUBY
end
- expect(last_command.stdout).to eq("2.3.2")
- expect(last_command.stderr).to eq("ZOMG LOAD ERROR")
+ expect(out).to eq("2.3.2")
+ expect(err).to eq("ZOMG LOAD ERROR")
end
it "allows --without to limit the groups used in a standalone" do
@@ -193,11 +193,11 @@ RSpec.shared_examples "bundle install --standalone" do
RUBY
end
- expect(last_command.stdout).to eq("2.3.2")
- expect(last_command.stderr).to eq("ZOMG LOAD ERROR")
+ expect(out).to eq("2.3.2")
+ expect(err).to eq("ZOMG LOAD ERROR")
end
- it "allows --path to change the location of the standalone bundle", :bundler => "< 2" do
+ it "allows --path to change the location of the standalone bundle", :bundler => "< 3" do
bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true)
Dir.chdir(bundled_app) do
@@ -210,10 +210,10 @@ RSpec.shared_examples "bundle install --standalone" do
RUBY
end
- expect(last_command.stdout).to eq("2.3.2")
+ expect(out).to eq("2.3.2")
end
- it "allows --path to change the location of the standalone bundle", :bundler => "2" do
+ it "allows --path to change the location of the standalone bundle", :bundler => "3" do
bundle! "install", forgotten_command_line_options(:path => "path/to/bundle").merge(:standalone => true)
path = File.expand_path("path/to/bundle")
@@ -227,7 +227,7 @@ RSpec.shared_examples "bundle install --standalone" do
RUBY
end
- expect(last_command.stdout).to eq("2.3.2")
+ expect(out).to eq("2.3.2")
end
it "allows remembered --without to limit the groups used in a standalone" do
@@ -245,8 +245,8 @@ RSpec.shared_examples "bundle install --standalone" do
RUBY
end
- expect(last_command.stdout).to eq("2.3.2")
- expect(last_command.stderr).to eq("ZOMG LOAD ERROR")
+ expect(out).to eq("2.3.2")
+ expect(err).to eq("ZOMG LOAD ERROR")
end
end
@@ -273,7 +273,7 @@ RSpec.shared_examples "bundle install --standalone" do
end
end
- describe "with --binstubs", :bundler => "< 2" do
+ describe "with --binstubs", :bundler => "< 3" do
before do
gemfile <<-G
source "file://#{gem_repo1}"
diff --git a/spec/install/gems/sudo_spec.rb b/spec/install/gems/sudo_spec.rb
index 58f51841a0..fb41f63a07 100644
--- a/spec/install/gems/sudo_spec.rb
+++ b/spec/install/gems/sudo_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe "when using sudo", :sudo => true do
describe "and BUNDLE_PATH is writable" do
context "but BUNDLE_PATH/build_info is not writable" do
before do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
subdir = system_gem_path("cache")
subdir.mkpath
sudo "chmod u-w #{subdir}"
@@ -25,7 +25,7 @@ RSpec.describe "when using sudo", :sudo => true do
describe "and GEM_HOME is owned by root" do
before :each do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
chown_system_gems_to_root
end
@@ -52,7 +52,7 @@ RSpec.describe "when using sudo", :sudo => true do
end
it "installs when BUNDLE_PATH is owned by root" do
- bundle! "config global_path_appends_ruby_scope false" # consistency in tests between 1.x and 2.x modes
+ bundle! "config set global_path_appends_ruby_scope false" # consistency in tests between 1.x and 2.x modes
bundle_path = tmp("owned_by_root")
FileUtils.mkdir_p bundle_path
@@ -70,7 +70,7 @@ RSpec.describe "when using sudo", :sudo => true do
end
it "installs when BUNDLE_PATH does not exist" do
- bundle! "config global_path_appends_ruby_scope false" # consistency in tests between 1.x and 2.x modes
+ bundle! "config set global_path_appends_ruby_scope false" # consistency in tests between 1.x and 2.x modes
root_path = tmp("owned_by_root")
FileUtils.mkdir_p root_path
@@ -133,7 +133,7 @@ RSpec.describe "when using sudo", :sudo => true do
describe "and GEM_HOME is not writable" do
it "installs" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
gem_home = tmp("sudo_gem_home")
sudo "mkdir -p #{gem_home}"
sudo "chmod ugo-w #{gem_home}"
diff --git a/spec/install/gemspecs_spec.rb b/spec/install/gemspecs_spec.rb
index c9878ccae8..55c7a67b4b 100644
--- a/spec/install/gemspecs_spec.rb
+++ b/spec/install/gemspecs_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe "bundle install" do
gem "yaml_spec"
G
bundle :install
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "still installs correctly when using path" do
@@ -23,7 +23,7 @@ RSpec.describe "bundle install" do
install_gemfile <<-G
gem 'yaml_spec', :path => "#{lib_path("yaml_spec-1.0")}"
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb
index 6ae718c2a4..68b2f47c10 100644
--- a/spec/install/git_spec.rb
+++ b/spec/install/git_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe "bundle install" do
context "git sources" do
- it "displays the revision hash of the gem repository", :bundler => "< 2" do
+ it "displays the revision hash of the gem repository", :bundler => "< 3" do
build_git "foo", "1.0", :path => lib_path("foo")
install_gemfile <<-G
@@ -14,7 +14,7 @@ RSpec.describe "bundle install" do
expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}"
end
- it "displays the ref of the gem repository when using branch~num as a ref", :bundler => "< 2" do
+ it "displays the ref of the gem repository when using branch~num as a ref", :bundler => "< 3" do
build_git "foo", "1.0", :path => lib_path("foo")
rev = revision_for(lib_path("foo"))[0..6]
update_git "foo", "2.0", :path => lib_path("foo"), :gemspec => true
@@ -31,7 +31,7 @@ RSpec.describe "bundle install" do
update_git "foo", "4.0", :path => lib_path("foo"), :gemspec => true
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
expect(out).to include("Using foo 2.0 (was 1.0) from #{lib_path("foo")} (at master~2@#{rev2})")
expect(the_bundle).to include_gems "foo 2.0", :source => "git@#{lib_path("foo")}"
end
diff --git a/spec/install/global_cache_spec.rb b/spec/install/global_cache_spec.rb
index e1f5a3074a..345ad86db8 100644
--- a/spec/install/global_cache_spec.rb
+++ b/spec/install/global_cache_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "global gem caching" do
- before { bundle! "config global_gem_cache true" }
+ before { bundle! "config set global_gem_cache true" }
describe "using the cross-application user cache" do
let(:source) { "http://localgemserver.test" }
@@ -220,7 +220,7 @@ RSpec.describe "global gem caching" do
gem_binary_cache.join("very_simple_binary_c.rb").open("w") {|f| f << "puts File.basename(__FILE__)" }
git_binary_cache.join("very_simple_git_binary_c.rb").open("w") {|f| f << "puts File.basename(__FILE__)" }
- bundle! "config --local path different_path"
+ bundle! "config set --local path different_path"
bundle! :install
expect(Dir[home(".bundle", "cache", "extensions", "**", "*binary_c*")]).to all(end_with(".rb"))
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index 8127c853c3..aac697fb23 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe "bundle install" do
G
end
- it "does not use available system gems with bundle --path vendor/bundle", :bundler => "< 2" do
+ it "does not use available system gems with bundle --path vendor/bundle", :bundler => "< 3" do
bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -35,13 +35,13 @@ RSpec.describe "bundle install" do
expect(out).to include("gems are installed into `./vendor/bundle`")
end
- it "disallows --path vendor/bundle --system", :bundler => "< 2" do
+ it "disallows --path vendor/bundle --system", :bundler => "< 3" do
bundle "install --path vendor/bundle --system"
- expect(out).to include("Please choose only one option.")
+ expect(err).to include("Please choose only one option.")
expect(exitstatus).to eq(15) if exitstatus
end
- it "remembers to disable system gems after the first time with bundle --path vendor/bundle", :bundler => "< 2" do
+ it "remembers to disable system gems after the first time with bundle --path vendor/bundle", :bundler => "< 3" do
bundle "install --path vendor/bundle"
FileUtils.rm_rf bundled_app("vendor")
bundle "install"
@@ -51,9 +51,9 @@ RSpec.describe "bundle install" do
end
context "with path_relative_to_cwd set to true" do
- before { bundle! "config path_relative_to_cwd true" }
+ before { bundle! "config set path_relative_to_cwd true" }
- it "installs the bundle relatively to current working directory", :bundler => "< 2" do
+ it "installs the bundle relatively to current working directory", :bundler => "< 3" do
Dir.chdir(bundled_app.parent) do
bundle! "install --gemfile='#{bundled_app}/Gemfile' --path vendor/bundle"
expect(out).to include("installed into `./vendor/bundle`")
@@ -98,7 +98,7 @@ RSpec.describe "bundle install" do
if type == :env
ENV["BUNDLE_PATH"] = location
elsif type == :global
- bundle! "config path #{location}", "no-color" => nil
+ bundle! "config set path #{location}", "no-color" => nil
end
end
@@ -113,10 +113,10 @@ RSpec.describe "bundle install" do
expect(the_bundle).to include_gems "rack 1.0.0"
end
- context "with global_path_appends_ruby_scope set", :bundler => "2" do
+ context "with global_path_appends_ruby_scope set", :bundler => "3" do
it "installs gems to ." do
set_bundle_path(type, ".")
- bundle! "config --global disable_shared_gems true"
+ bundle! "config set --global disable_shared_gems true"
bundle! :install
@@ -147,10 +147,10 @@ RSpec.describe "bundle install" do
end
end
- context "with global_path_appends_ruby_scope unset", :bundler => "< 2" do
+ context "with global_path_appends_ruby_scope unset", :bundler => "< 3" do
it "installs gems to ." do
set_bundle_path(type, ".")
- bundle! "config --global disable_shared_gems true"
+ bundle! "config set --global disable_shared_gems true"
bundle! :install
@@ -226,7 +226,7 @@ RSpec.describe "bundle install" do
vendored_gems("extensions").rmtree
run "require 'very_simple_binary_c'"
- expect(last_command.stderr).to include("Bundler::GemNotFound")
+ expect(err).to include("Bundler::GemNotFound")
bundle :install, forgotten_command_line_options(:path => "./vendor/bundle")
diff --git a/spec/install/post_bundle_message_spec.rb b/spec/install/post_bundle_message_spec.rb
index 0ca866e526..1efd0b8146 100644
--- a/spec/install/post_bundle_message_spec.rb
+++ b/spec/install/post_bundle_message_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe "post bundle message" do
let(:bundle_complete_message) { "Bundle complete!" }
let(:bundle_updated_message) { "Bundle updated!" }
let(:installed_gems_stats) { "4 Gemfile dependencies, 5 gems now installed." }
- let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 2 ? bundle_show_system_message : bundle_show_path_message }
+ let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 3 ? bundle_show_system_message : bundle_show_path_message }
describe "for fresh bundle install" do
it "without any options" do
@@ -101,16 +101,16 @@ RSpec.describe "post bundle message" do
end
describe "with misspelled or non-existent gem name" do
- it "should report a helpful error message", :bundler => "< 2" do
+ it "should report a helpful error message", :bundler => "< 3" do
install_gemfile <<-G
source "file://localhost#{gem_repo1}"
gem "rack"
gem "not-a-gem", :group => :development
G
- expect(out).to include("Could not find gem 'not-a-gem' in any of the gem sources listed in your Gemfile.")
+ expect(err).to include("Could not find gem 'not-a-gem' in any of the gem sources listed in your Gemfile.")
end
- it "should report a helpful error message", :bundler => "2" do
+ it "should report a helpful error message", :bundler => "3" do
install_gemfile <<-G
source "file://localhost#{gem_repo1}"
gem "rack"
@@ -177,28 +177,28 @@ The source does not contain any versions of 'not-a-gem'
describe "for bundle update" do
it "without any options" do
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
expect(out).not_to include("Gems in the groups")
expect(out).to include(bundle_updated_message)
end
it "with --without one group" do
bundle! :install, forgotten_command_line_options(:without => "emo")
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
expect(out).to include("Gems in the group emo were not installed")
expect(out).to include(bundle_updated_message)
end
it "with --without two groups" do
bundle! :install, forgotten_command_line_options(:without => "emo test")
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
expect(out).to include("Gems in the groups emo and test were not installed")
expect(out).to include(bundle_updated_message)
end
it "with --without more groups" do
bundle! :install, forgotten_command_line_options(:without => "emo obama test")
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
expect(out).to include("Gems in the groups emo, obama and test were not installed")
expect(out).to include(bundle_updated_message)
end
diff --git a/spec/install/redownload_spec.rb b/spec/install/redownload_spec.rb
index de726c4562..2a0cdc9473 100644
--- a/spec/install/redownload_spec.rb
+++ b/spec/install/redownload_spec.rb
@@ -56,30 +56,20 @@ RSpec.describe "bundle install" do
end
end
- describe "with --force" do
+ describe "with --force", :bundler => 2 do
it_behaves_like "an option to force redownloading gems" do
let(:flag) { "force" }
end
- it "shows a deprecation when single flag passed", :bundler => 2 do
+ it "shows a deprecation when single flag passed" do
bundle! "install --force"
expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
- it "shows a deprecation when multiple flags passed", :bundler => 2 do
+ it "shows a deprecation when multiple flags passed" do
bundle! "install --no-color --force"
expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
-
- it "does not show a deprecation when single flag passed", :bundler => "< 2" do
- bundle! "install --force"
- expect(out).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
-
- it "does not show a deprecation when multiple flags passed", :bundler => "< 2" do
- bundle! "install --no-color --force"
- expect(out).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
end
describe "with --redownload" do
diff --git a/spec/install/security_policy_spec.rb b/spec/install/security_policy_spec.rb
index 6e94c3f7ce..ad76162aac 100644
--- a/spec/install/security_policy_spec.rb
+++ b/spec/install/security_policy_spec.rb
@@ -32,8 +32,7 @@ RSpec.describe "policies with unsigned gems" do
expect(err).to include("security policy didn't allow")
end
- # This spec will fail on RubyGems 2 rc1 due to a bug in policy.rb. the bug is fixed in rc3.
- it "will fail with Medium Security setting due to presence of unsigned gem", :unless => ENV["RGV"] == "v2.0.0.rc.1" do
+ it "will fail with Medium Security setting due to presence of unsigned gem" do
bundle "install --trust-policy=MediumSecurity"
expect(err).to include("security policy didn't allow")
end
diff --git a/spec/lock/lockfile_bundler_1_spec.rb b/spec/lock/lockfile_bundler_1_spec.rb
deleted file mode 100644
index d44b076cb7..0000000000
--- a/spec/lock/lockfile_bundler_1_spec.rb
+++ /dev/null
@@ -1,1388 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "the lockfile format", :bundler => "< 2" do
- include Bundler::GemHelpers
-
- before { ENV["BUNDLER_SPEC_IGNORE_COMPATIBILITY_GUARD"] = "TRUE" }
-
- it "generates a simple lockfile for a single source, gem" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "updates the lockfile's bundler version if current ver. is newer" do
- lockfile <<-L
- GIT
- remote: git://github.com/nex3/haml.git
- revision: 8a2271f
- specs:
-
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- omg!
- rack
-
- BUNDLED WITH
- 1.8.2
- L
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not update the lockfile's bundler version if nothing changed during bundle install", :ruby_repo do
- version = "#{Bundler::VERSION.split(".").first}.0.0.0.a"
-
- lockfile normalize_uri_file(<<-L)
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{version}
- L
-
- install_gemfile normalize_uri_file(<<-G)
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
-
- lockfile_should_be normalize_uri_file(<<-G)
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{version}
- G
- end
-
- it "updates the lockfile's bundler version if not present" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
- L
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack", "> 0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack (> 0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "outputs a warning if the current is older than lockfile's bundler version" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 9999999.1.0
- L
-
- simulate_bundler_version "9999999.0.0" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
- end
-
- warning_message = "the running version of Bundler (9999999.0.0) is older " \
- "than the version that created the lockfile (9999999.1.0). " \
- "We suggest you to upgrade to the version that created the " \
- "lockfile by running `gem install bundler:9999999.1.0`."
- expect(last_command.stderr.scan(warning_message).size).to eq(1)
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
- #{specific_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 9999999.1.0
- G
- end
-
- it "errors if the current is a major version older than lockfile's bundler version" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 9999999.0.0
- L
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
-
- expect(exitstatus > 0) if exitstatus
- expect(out).to include("You must use Bundler 9999999 or greater with this lockfile.")
- end
-
- it "shows a friendly error when running with a new bundler 2 lockfile" do
- lockfile <<-L
- GEM
- remote: https://rails-assets.org/
- specs:
- rails-assets-bootstrap (3.3.4)
- rails-assets-jquery (>= 1.9.1)
- rails-assets-jquery (2.1.4)
-
- GEM
- remote: https://rubygems.org/
- specs:
- rake (10.4.2)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rails-assets-bootstrap!
- rake
-
- BUNDLED WITH
- 9999999.0.0
- L
-
- install_gemfile <<-G
- source 'https://rubygems.org'
- gem 'rake'
-
- source 'https://rails-assets.org' do
- gem 'rails-assets-bootstrap'
- end
- G
-
- expect(exitstatus > 0) if exitstatus
- expect(err).to include("You must use Bundler 9999999 or greater with this lockfile.")
- end
-
- it "warns when updating bundler major version" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 1.10.0
- L
-
- simulate_bundler_version "9999999.0.0" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
- end
-
- expect(last_command.stderr).to include("Warning: the lockfile is being updated to Bundler " \
- "9999999, after which you will be unable to return to Bundler 1.")
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
- #{specific_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 9999999.0.0
- G
- end
-
- it "generates a simple lockfile for a single source, gem with dependencies" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack-obama"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack-obama
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a simple lockfile for a single source, gem with a version requirement" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack-obama", ">= 1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack-obama (>= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a lockfile wihout credentials for a configured source" do
- bundle "config set http://localgemserver.test/ user:pass"
-
- install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
- source "http://localgemserver.test/"
- source "http://user:pass@othergemserver.test/"
-
- gem "rack-obama", ">= 1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: http://localgemserver.test/
- remote: http://user:pass@othergemserver.test/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack-obama (>= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates lockfiles with multiple requirements" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "net-sftp"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- net-sftp (1.1.1)
- net-ssh (>= 1.0.0, < 1.99.0)
- net-ssh (1.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- net-sftp
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
-
- expect(the_bundle).to include_gems "net-sftp 1.1.1", "net-ssh 1.0.0"
- end
-
- it "generates a simple lockfile for a single pinned source, gem with a version requirement" do
- git = build_git "foo"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("master")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not asplode when a platform specific dependency is present and the Gemfile has not been resolved on that platform" do
- build_lib "omg", :path => lib_path("omg")
-
- gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- platforms :#{not_local_tag} do
- gem "omg", :path => "#{lib_path("omg")}"
- end
-
- gem "rack"
- G
-
- lockfile <<-L
- GIT
- remote: git://github.com/nex3/haml.git
- revision: 8a2271f
- specs:
-
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{not_local}
-
- DEPENDENCIES
- omg!
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- bundle "install"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "serializes global git sources" do
- git = build_git "foo"
-
- install_gemfile <<-G
- git "#{lib_path("foo-1.0")}" do
- gem "foo"
- end
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("master")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a lockfile with a ref for a single pinned source, git gem with a branch requirement" do
- git = build_git "foo"
- update_git "foo", :branch => "omg"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("omg")}
- branch: omg
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a lockfile with a ref for a single pinned source, git gem with a tag requirement" do
- git = build_git "foo"
- update_git "foo", :tag => "omg"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}", :tag => "omg"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("omg")}
- tag: omg
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "serializes pinned path sources to the lockfile" do
- build_lib "foo"
-
- install_gemfile <<-G
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: #{lib_path("foo-1.0")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "serializes pinned path sources to the lockfile even when packaging" do
- build_lib "foo"
-
- install_gemfile! <<-G
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- G
-
- bundle! :package, forgotten_command_line_options([:all, :cache_all] => true)
- bundle! :install, :local => true
-
- lockfile_should_be <<-G
- PATH
- remote: #{lib_path("foo-1.0")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "sorts serialized sources by type" do
- build_lib "foo"
- bar = build_git "bar"
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- gem "bar", :git => "#{lib_path("bar-1.0")}"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("bar-1.0")}
- revision: #{bar.ref_for("master")}
- specs:
- bar (1.0)
-
- PATH
- remote: #{lib_path("foo-1.0")}
- specs:
- foo (1.0)
-
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- bar!
- foo!
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "lists gems alphabetically" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "thin"
- gem "actionpack"
- gem "rack-obama"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- actionpack (2.3.2)
- activesupport (= 2.3.2)
- activesupport (2.3.2)
- rack (1.0.0)
- rack-obama (1.0)
- rack
- thin (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- actionpack
- rack-obama
- thin
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "orders dependencies' dependencies in alphabetical order" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rails"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- actionmailer (2.3.2)
- activesupport (= 2.3.2)
- actionpack (2.3.2)
- activesupport (= 2.3.2)
- activerecord (2.3.2)
- activesupport (= 2.3.2)
- activeresource (2.3.2)
- activesupport (= 2.3.2)
- activesupport (2.3.2)
- rails (2.3.2)
- actionmailer (= 2.3.2)
- actionpack (= 2.3.2)
- activerecord (= 2.3.2)
- activeresource (= 2.3.2)
- rake (= 12.3.2)
- rake (12.3.2)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rails
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "orders dependencies by version" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem 'double_deps'
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- double_deps (1.0)
- net-ssh
- net-ssh (>= 1.0.0)
- net-ssh (1.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- double_deps
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add the :require option to the lockfile" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack-obama", ">= 1.0", :require => "rack/obama"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack-obama (>= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add the :group option to the lockfile" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack-obama", ">= 1.0", :group => :test
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack-obama (>= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided in a relative fashion and in Gemfile dir" do
- build_lib "foo", :path => bundled_app("foo")
-
- install_gemfile <<-G
- path "foo"
- gem "foo"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided in a relative fashion and is above Gemfile dir" do
- build_lib "foo", :path => bundled_app(File.join("..", "foo"))
-
- install_gemfile <<-G
- path "../foo"
- gem "foo"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: ../foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided in an absolute fashion but is relative" do
- build_lib "foo", :path => bundled_app("foo")
-
- install_gemfile <<-G
- path File.expand_path("../foo", __FILE__)
- gem "foo"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided for gemspec" do
- build_lib("foo", :path => tmp.join("foo"))
-
- install_gemfile <<-G
- gemspec :path => "../foo"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: ../foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "keeps existing platforms in the lockfile" do
- lockfile <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- java
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
-
- platforms = ["java", generic_local_platform.to_s].sort
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{platforms[0]}
- #{platforms[1]}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "persists the spec's platform to the lockfile" do
- build_gem "platform_specific", "1.0.0", :to_system => true do |s|
- s.platform = Gem::Platform.new("universal-java-16")
- end
-
- simulate_platform "universal-java-16"
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "platform_specific"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- platform_specific (1.0-java)
-
- PLATFORMS
- java
-
- DEPENDENCIES
- platform_specific
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate gems" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack"
- G
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack"
- gem "activesupport"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- activesupport (2.3.5)
- rack (1.0.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- activesupport
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate dependencies" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack"
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate dependencies with versions" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack", "1.0"
- gem "rack", "1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack (= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate dependencies in different groups" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack", "1.0", :group => :one
- gem "rack", "1.0", :group => :two
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack (= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "raises if two different versions are used" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack", "1.0"
- gem "rack", "1.1"
- G
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- expect(err).to include "rack (= 1.0) and rack (= 1.1)"
- end
-
- it "raises if two different sources are used" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack"
- gem "rack", :git => "git://hubz.com"
- G
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- expect(err).to include "rack (>= 0) should come from an unspecified source and git://hubz.com (at master)"
- end
-
- it "works correctly with multiple version dependencies" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack", "> 0.9", "< 1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (0.9.1)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack (> 0.9, < 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "captures the Ruby version in the lockfile" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- ruby '#{RUBY_VERSION}'
- gem "rack", "> 0.9", "< 1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (0.9.1)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack (> 0.9, < 1.0)
-
- RUBY VERSION
- ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- # Some versions of the Bundler 1.1 RC series introduced corrupted
- # lockfiles. There were two major problems:
- #
- # * multiple copies of the same GIT section appeared in the lockfile
- # * when this happened, those sections got multiple copies of gems
- # in those sections.
- it "fixes corrupted lockfiles" do
- build_git "omg", :path => lib_path("omg")
- revision = revision_for(lib_path("omg"))
-
- gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "omg", :git => "#{lib_path("omg")}", :branch => 'master'
- G
-
- bundle "install --path vendor"
- expect(the_bundle).to include_gems "omg 1.0"
-
- # Create a Gemfile.lock that has duplicate GIT sections
- lockfile <<-L
- GIT
- remote: #{lib_path("omg")}
- revision: #{revision}
- branch: master
- specs:
- omg (1.0)
-
- GIT
- remote: #{lib_path("omg")}
- revision: #{revision}
- branch: master
- specs:
- omg (1.0)
-
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
-
- PLATFORMS
- #{local}
-
- DEPENDENCIES
- omg!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- FileUtils.rm_rf(bundled_app("vendor"))
- bundle "install"
- expect(the_bundle).to include_gems "omg 1.0"
-
- # Confirm that duplicate specs do not appear
- lockfile_should_be(<<-L)
- GIT
- remote: #{lib_path("omg")}
- revision: #{revision}
- branch: master
- specs:
- omg (1.0)
-
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
-
- PLATFORMS
- #{local}
-
- DEPENDENCIES
- omg!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
-
- it "raises a helpful error message when the lockfile is missing deps" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack_middleware (1.0)
-
- PLATFORMS
- #{local}
-
- DEPENDENCIES
- rack_middleware
- L
-
- install_gemfile <<-G
- source "file:#{gem_repo1}"
- gem "rack_middleware"
- G
-
- expect(err).to include("Downloading rack_middleware-1.0 revealed dependencies not in the API or the lockfile (#{Gem::Dependency.new("rack", "= 0.9.1")}).").
- and include("Either installing with `--full-index` or running `bundle update rack_middleware` should fix the problem.")
- end
-
- describe "a line ending" do
- def set_lockfile_mtime_to_known_value
- time = Time.local(2000, 1, 1, 0, 0, 0)
- File.utime(time, time, bundled_app("Gemfile.lock"))
- end
- before(:each) do
- build_repo2
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo2}"
- gem "rack"
- G
- set_lockfile_mtime_to_known_value
- end
-
- it "generates Gemfile.lock with \\n line endings" do
- expect(File.read(bundled_app("Gemfile.lock"))).not_to match("\r\n")
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- context "during updates" do
- it "preserves Gemfile.lock \\n line endings" do
- update_repo2
-
- expect { bundle "update", :all => true }.to change { File.mtime(bundled_app("Gemfile.lock")) }
- expect(File.read(bundled_app("Gemfile.lock"))).not_to match("\r\n")
- expect(the_bundle).to include_gems "rack 1.2"
- end
-
- it "preserves Gemfile.lock \\n\\r line endings" do
- update_repo2
- win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
- File.open(bundled_app("Gemfile.lock"), "wb") {|f| f.puts(win_lock) }
- set_lockfile_mtime_to_known_value
-
- expect { bundle "update", :all => true }.to change { File.mtime(bundled_app("Gemfile.lock")) }
- expect(File.read(bundled_app("Gemfile.lock"))).to match("\r\n")
- expect(the_bundle).to include_gems "rack 1.2"
- end
- end
-
- context "when nothing changes" do
- it "preserves Gemfile.lock \\n line endings" do
- expect do
- ruby <<-RUBY
- require 'rubygems'
- require 'bundler'
- Bundler.setup
- RUBY
- end.not_to change { File.mtime(bundled_app("Gemfile.lock")) }
- end
-
- it "preserves Gemfile.lock \\n\\r line endings" do
- win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
- File.open(bundled_app("Gemfile.lock"), "wb") {|f| f.puts(win_lock) }
- set_lockfile_mtime_to_known_value
-
- expect do
- ruby <<-RUBY
- require 'rubygems'
- require 'bundler'
- Bundler.setup
- RUBY
- end.not_to change { File.mtime(bundled_app("Gemfile.lock")) }
- end
- end
- end
-
- it "refuses to install if Gemfile.lock contains conflict markers" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- <<<<<<<
- rack (1.0.0)
- =======
- rack (1.0.1)
- >>>>>>>
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- install_gemfile(<<-G)
- source "file://localhost#{gem_repo1}"
- gem "rack"
- G
-
- expect(last_command.bundler_err).to match(/your Gemfile.lock contains merge conflicts/i)
- expect(last_command.bundler_err).to match(/git checkout HEAD -- Gemfile.lock/i)
- end
-end
diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb
index 0809258859..c2d44e5cf1 100644
--- a/spec/lock/lockfile_spec.rb
+++ b/spec/lock/lockfile_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "the lockfile format", :bundler => "2" do
+RSpec.describe "the lockfile format" do
include Bundler::GemHelpers
before { ENV["BUNDLER_SPEC_IGNORE_COMPATIBILITY_GUARD"] = "TRUE" }
@@ -76,7 +76,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do
end
it "does not update the lockfile's bundler version if nothing changed during bundle install" do
- version = "#{Bundler::VERSION.split(".").first}.0.0.0.a"
+ version = "#{Bundler::VERSION.split(".").first}.0.0.a"
lockfile <<-L
GEM
@@ -154,7 +154,10 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
end
- it "outputs a warning if the current is older than lockfile's bundler version" do
+ it "warns if the current is older than lockfile's bundler version" do
+ current_version = Bundler::VERSION
+ newer_minor = bump_minor(current_version)
+
lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
@@ -162,28 +165,27 @@ RSpec.describe "the lockfile format", :bundler => "2" do
rack (1.0.0)
PLATFORMS
- #{generic_local_platform}
+ #{lockfile_platforms}
DEPENDENCIES
rack
BUNDLED WITH
- 9999999.1.0
+ #{newer_minor}
L
- simulate_bundler_version "9999999.0.0" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
+ install_gemfile <<-G
+ source "file://localhost#{gem_repo1}"
- gem "rack"
- G
- end
+ gem "rack"
+ G
- warning_message = "the running version of Bundler (9999999.0.0) is older " \
- "than the version that created the lockfile (9999999.1.0). " \
+ pre_flag = prerelease?(newer_minor) ? " --pre" : ""
+ warning_message = "the running version of Bundler (#{current_version}) is older " \
+ "than the version that created the lockfile (#{newer_minor}). " \
"We suggest you to upgrade to the version that created the " \
- "lockfile by running `gem install bundler:9999999.1.0`."
- expect(last_command.bundler_err).to include warning_message
+ "lockfile by running `gem install bundler:#{newer_minor}#{pre_flag}`."
+ expect(err).to include warning_message
lockfile_should_be <<-G
GEM
@@ -198,11 +200,14 @@ RSpec.describe "the lockfile format", :bundler => "2" do
rack
BUNDLED WITH
- 9999999.1.0
+ #{newer_minor}
G
end
- it "errors if the current is a major version older than lockfile's bundler version" do
+ it "warns when updating bundler major version" do
+ current_version = Bundler::VERSION
+ older_major = previous_major(current_version)
+
lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
@@ -216,7 +221,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do
rack
BUNDLED WITH
- 9999999.0.0
+ #{older_major}
L
install_gemfile <<-G
@@ -225,98 +230,59 @@ RSpec.describe "the lockfile format", :bundler => "2" do
gem "rack"
G
- expect(last_command).to be_failure
- expect(last_command.bundler_err).to include("You must use Bundler 9999999 or greater with this lockfile.")
- end
-
- it "shows a friendly error when running with a new bundler 2 lockfile" do
- lockfile <<-L
- GEM
- remote: https://rails-assets.org/
- specs:
- rails-assets-bootstrap (3.3.4)
- rails-assets-jquery (>= 1.9.1)
- rails-assets-jquery (2.1.4)
-
- GEM
- remote: https://rubygems.org/
- specs:
- rake (10.4.2)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rails-assets-bootstrap!
- rake
-
- BUNDLED WITH
- 9999999.0.0
- L
+ expect(err).to include(
+ "Warning: the lockfile is being updated to Bundler " \
+ "#{current_version.split(".").first}, after which you will be unable to return to Bundler #{older_major.split(".").first}."
+ )
- install_gemfile <<-G
- source 'https://rubygems.org'
- gem 'rake'
-
- source 'https://rails-assets.org' do
- gem 'rails-assets-bootstrap'
- end
- G
-
- expect(last_command).to be_failure
- expect(err).to include("You must use Bundler 9999999 or greater with this lockfile.")
- end
-
- it "warns when updating bundler major version" do
- lockfile <<-L
+ lockfile_should_be <<-G
GEM
remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
PLATFORMS
- #{generic_local_platform}
+ #{lockfile_platforms}
DEPENDENCIES
rack
BUNDLED WITH
- 1.10.0
- L
-
- simulate_bundler_version "9999999.0.0" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}/"
+ #{current_version}
+ G
+ end
- gem "rack"
- G
- end
+ it "generates a simple lockfile for a single source, gem with dependencies" do
+ install_gemfile <<-G
+ source "file://localhost#{gem_repo1}/"
- expect(err).to include("Warning: the lockfile is being updated to Bundler " \
- "9999999, after which you will be unable to return to Bundler 1.")
+ gem "rack-obama"
+ G
lockfile_should_be <<-G
GEM
remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
+ rack-obama (1.0)
+ rack
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
- rack
+ rack-obama
BUNDLED WITH
- 9999999.0.0
+ #{Bundler::VERSION}
G
end
- it "generates a simple lockfile for a single source, gem with dependencies" do
+ it "generates a simple lockfile for a single source, gem with a version requirement" do
install_gemfile <<-G
source "file://localhost#{gem_repo1}/"
- gem "rack-obama"
+ gem "rack-obama", ">= 1.0"
G
lockfile_should_be <<-G
@@ -331,23 +297,30 @@ RSpec.describe "the lockfile format", :bundler => "2" do
#{lockfile_platforms}
DEPENDENCIES
- rack-obama
+ rack-obama (>= 1.0)
BUNDLED WITH
#{Bundler::VERSION}
G
end
- it "generates a simple lockfile for a single source, gem with a version requirement" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}/"
+ it "generates a lockfile without credentials for a configured source", :bundler => "< 3" do
+ bundle "config set http://localgemserver.test/ user:pass"
- gem "rack-obama", ">= 1.0"
+ install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
+ source "http://localgemserver.test/" do
+
+ end
+
+ source "http://user:pass@othergemserver.test/" do
+ gem "rack-obama", ">= 1.0"
+ end
G
lockfile_should_be <<-G
GEM
- remote: file://localhost#{gem_repo1}/
+ remote: http://localgemserver.test/
+ remote: http://user:pass@othergemserver.test/
specs:
rack (1.0.0)
rack-obama (1.0)
@@ -357,14 +330,14 @@ RSpec.describe "the lockfile format", :bundler => "2" do
#{lockfile_platforms}
DEPENDENCIES
- rack-obama (>= 1.0)
+ rack-obama (>= 1.0)!
BUNDLED WITH
#{Bundler::VERSION}
G
end
- it "generates a lockfile without credentials for a configured source" do
+ it "generates a lockfile without credentials for a configured source", :bundler => "3" do
bundle "config set http://localgemserver.test/ user:pass"
install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
@@ -430,7 +403,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do
expect(the_bundle).to include_gems "net-sftp 1.1.1", "net-ssh 1.0.0"
end
- it "generates a simple lockfile for a single pinned source, gem with a version requirement", :bundler => "< 2" do
+ it "generates a simple lockfile for a single pinned source, gem with a version requirement", :bundler => "< 3" do
git = build_git "foo"
install_gemfile <<-G
@@ -466,15 +439,15 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
GIT
remote: #{lib_path("foo-1.0")}
revision: #{git.ref_for("master")}
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -535,15 +508,15 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
GIT
remote: #{lib_path("foo-1.0")}
revision: #{git.ref_for("master")}
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -564,9 +537,6 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
GIT
remote: #{lib_path("foo-1.0")}
revision: #{git.ref_for("omg")}
@@ -574,6 +544,9 @@ RSpec.describe "the lockfile format", :bundler => "2" do
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -594,9 +567,6 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
GIT
remote: #{lib_path("foo-1.0")}
revision: #{git.ref_for("omg")}
@@ -604,6 +574,9 @@ RSpec.describe "the lockfile format", :bundler => "2" do
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -623,14 +596,14 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: #{lib_path("foo-1.0")}
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -653,14 +626,14 @@ RSpec.describe "the lockfile format", :bundler => "2" do
bundle! :install, :local => true
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: #{lib_path("foo-1.0")}
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -685,11 +658,6 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
GIT
remote: #{lib_path("bar-1.0")}
revision: #{bar.ref_for("master")}
@@ -701,6 +669,11 @@ RSpec.describe "the lockfile format", :bundler => "2" do
specs:
foo (1.0)
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
PLATFORMS
#{lockfile_platforms}
@@ -876,14 +849,14 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: foo
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -905,14 +878,14 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: ../foo
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -934,14 +907,14 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: foo
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -961,14 +934,14 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: ../foo
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -980,7 +953,48 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
end
- it "keeps existing platforms in the lockfile" do
+ it "keeps existing platforms in the lockfile", :bundler => "< 3" do
+ lockfile <<-G
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
+ PLATFORMS
+ java
+
+ DEPENDENCIES
+ rack
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ G
+
+ install_gemfile <<-G
+ source "file://localhost#{gem_repo1}/"
+
+ gem "rack"
+ G
+
+ lockfile_should_be <<-G
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
+ PLATFORMS
+ java
+ #{generic_local_platform}
+
+ DEPENDENCIES
+ rack
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ G
+ end
+
+ it "keeps existing platforms in the lockfile", :bundler => "3" do
lockfile <<-G
GEM
remote: file://localhost#{gem_repo1}/
@@ -1010,7 +1024,9 @@ RSpec.describe "the lockfile format", :bundler => "2" do
rack (1.0.0)
PLATFORMS
- #{lockfile_platforms "java", generic_local_platform, specific_local_platform}
+ java
+ #{generic_local_platform}
+ #{specific_local_platform}
DEPENDENCIES
rack
@@ -1020,7 +1036,38 @@ RSpec.describe "the lockfile format", :bundler => "2" do
G
end
- it "persists the spec's platform to the lockfile" do
+ it "persists the spec's platform to the lockfile", :bundler => "< 3" do
+ build_repo2 do
+ build_gem "platform_specific", "1.0" do |s|
+ s.platform = Gem::Platform.new("universal-java-16")
+ end
+ end
+
+ simulate_platform "universal-java-16"
+
+ install_gemfile! <<-G
+ source "file://localhost#{gem_repo2}"
+ gem "platform_specific"
+ G
+
+ lockfile_should_be <<-G
+ GEM
+ remote: file://localhost#{gem_repo2}/
+ specs:
+ platform_specific (1.0-java)
+
+ PLATFORMS
+ java
+
+ DEPENDENCIES
+ platform_specific
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ G
+ end
+
+ it "persists the spec's platform and specific platform to the lockfile", :bundler => "3" do
build_repo2 do
build_gem "platform_specific", "1.0" do |s|
s.platform = Gem::Platform.new("universal-java-16")
@@ -1248,10 +1295,6 @@ RSpec.describe "the lockfile format", :bundler => "2" do
# Create a Gemfile.lock that has duplicate GIT sections
lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
-
GIT
remote: #{lib_path("omg")}
revision: #{revision}
@@ -1266,6 +1309,10 @@ RSpec.describe "the lockfile format", :bundler => "2" do
specs:
omg (1.0)
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -1282,10 +1329,6 @@ RSpec.describe "the lockfile format", :bundler => "2" do
# Confirm that duplicate specs do not appear
lockfile_should_be(<<-L)
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
-
GIT
remote: #{lib_path("omg")}
revision: #{revision}
@@ -1293,6 +1336,10 @@ RSpec.describe "the lockfile format", :bundler => "2" do
specs:
omg (1.0)
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -1421,7 +1468,25 @@ RSpec.describe "the lockfile format", :bundler => "2" do
gem "rack"
G
- expect(last_command.bundler_err).to match(/your Gemfile.lock contains merge conflicts/i)
- expect(last_command.bundler_err).to match(/git checkout HEAD -- Gemfile.lock/i)
+ expect(err).to match(/your Gemfile.lock contains merge conflicts/i)
+ expect(err).to match(/git checkout HEAD -- Gemfile.lock/i)
+ end
+
+private
+
+ def prerelease?(version)
+ Gem::Version.new(version).prerelease?
+ end
+
+ def previous_major(version)
+ version.split(".").map.with_index {|v, i| i == 0 ? v.to_i - 1 : v }.join(".")
+ end
+
+ def bump_minor(version)
+ bump(version, 1)
+ end
+
+ def bump(version, segment)
+ version.split(".").map.with_index {|v, i| i == segment ? v.to_i + 1 : v }.join(".")
end
end
diff --git a/spec/other/cli_dispatch_spec.rb b/spec/other/cli_dispatch_spec.rb
index d17819b394..548539ac89 100644
--- a/spec/other/cli_dispatch_spec.rb
+++ b/spec/other/cli_dispatch_spec.rb
@@ -3,27 +3,27 @@
RSpec.describe "bundle command names" do
it "work when given fully" do
bundle "install"
- expect(last_command.bundler_err).to eq("Could not locate Gemfile")
+ expect(err).to eq("Could not locate Gemfile")
expect(last_command.stdboth).not_to include("Ambiguous command")
end
it "work when not ambiguous" do
bundle "ins"
- expect(last_command.bundler_err).to eq("Could not locate Gemfile")
+ expect(err).to eq("Could not locate Gemfile")
expect(last_command.stdboth).not_to include("Ambiguous command")
end
it "print a friendly error when ambiguous" do
bundle "in"
- expect(last_command.bundler_err).to eq("Ambiguous command in matches [info, init, inject, install]")
+ expect(err).to eq("Ambiguous command in matches [info, init, inject, install]")
end
context "when cache_command_is_package is set" do
- before { bundle! "config cache_command_is_package true" }
+ before { bundle! "config set cache_command_is_package true" }
it "dispatches `bundle cache` to the package command" do
bundle "cache --verbose"
- expect(last_command.stdout).to start_with "Running `bundle package --verbose`"
+ expect(out).to start_with "Running `bundle package --verbose`"
end
end
end
diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb
index f4d55a450c..83944e4075 100644
--- a/spec/other/major_deprecation_spec.rb
+++ b/spec/other/major_deprecation_spec.rb
@@ -5,12 +5,10 @@ RSpec.describe "major deprecations" do
describe "Bundler" do
before do
- create_file "gems.rb", <<-G
+ install_gemfile! <<-G
source "file:#{gem_repo1}"
- ruby #{RUBY_VERSION.dump}
gem "rack"
G
- bundle! "install"
end
describe ".clean_env" do
@@ -19,190 +17,219 @@ RSpec.describe "major deprecations" do
bundle "exec ruby -e #{source.dump}"
end
- it "is not deprecated", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
-
it "is deprecated in favor of .unbundled_env", :bundler => "2" do
expect(deprecations).to include \
"`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
end
+
+ pending "is removed and shows a helpful error message about it", :bundler => "3"
end
- describe ".environment" do
+ describe ".with_clean_env" do
before do
- source = "Bundler.environment"
+ source = "Bundler.with_clean_env {}"
bundle "exec ruby -e #{source.dump}"
end
- it "is not deprecated", :bundler => "< 2" do
- expect(deprecations).to be_empty
+ it "is deprecated in favor of .unbundled_env", :bundler => "2" do
+ expect(deprecations).to include(
+ "`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
+ )
end
- it "is deprecated in favor of .load", :bundler => "2" do
- expect(deprecations).to include "Bundler.environment has been removed in favor of Bundler.load"
- end
+ pending "is removed and shows a helpful error message about it", :bundler => "3"
end
- describe "bundle update --quiet" do
- it "does not print any deprecations" do
- bundle :update, :quiet => true
- expect(deprecations).to be_empty
+ describe ".clean_system" do
+ before do
+ source = "Bundler.clean_system('ls')"
+ bundle "exec ruby -e #{source.dump}"
end
- end
-
- describe "bundle config" do
- describe "old list interface" do
- before do
- bundle! "config"
- end
- it "does not warn", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
-
- it "warns", :bundler => "2" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config list` instead.")
- end
+ it "is deprecated in favor of .unbundled_system", :bundler => "2" do
+ expect(deprecations).to include(
+ "`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \
+ "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`"
+ )
end
- describe "old get interface" do
- before do
- bundle! "config waka"
- end
+ pending "is removed and shows a helpful error message about it", :bundler => "3"
+ end
- it "does not warn", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
+ describe ".clean_exec" do
+ before do
+ source = "Bundler.clean_exec('ls')"
+ bundle "exec ruby -e #{source.dump}"
+ end
- it "warns", :bundler => "2" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config get waka` instead.")
- end
+ it "is deprecated in favor of .unbundled_exec", :bundler => "2" do
+ expect(deprecations).to include(
+ "`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \
+ "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`"
+ )
end
- describe "old set interface" do
- before do
- bundle! "config waka wakapun"
- end
+ pending "is removed and shows a helpful error message about it", :bundler => "3"
+ end
- it "does not warn", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
+ describe ".environment" do
+ before do
+ source = "Bundler.environment"
+ bundle "exec ruby -e #{source.dump}"
+ end
- it "warns", :bundler => "2" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set waka wakapun` instead.")
- end
+ it "is deprecated in favor of .load", :bundler => "2" do
+ expect(deprecations).to include "Bundler.environment has been removed in favor of Bundler.load"
end
- describe "old set interface with --local" do
- before do
- bundle! "config --local waka wakapun"
- end
+ pending "is removed and shows a helpful error message about it", :bundler => "3"
+ end
+ end
- it "does not warn", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
+ describe "bundle update --quiet" do
+ it "does not print any deprecations" do
+ bundle :update, :quiet => true
+ expect(deprecations).to be_empty
+ end
+ end
- it "warns", :bundler => "2" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --local waka wakapun` instead.")
- end
+ describe "bundle config" do
+ describe "old list interface" do
+ before do
+ bundle! "config"
end
- describe "old set interface with --global" do
- before do
- bundle! "config --global waka wakapun"
- end
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config list` instead.")
+ end
- it "does not warn", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
+ pending "fails with a helpful error", :bundler => "3"
+ end
- it "warns", :bundler => "2" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --global waka wakapun` instead.")
- end
+ describe "old get interface" do
+ before do
+ bundle! "config waka"
end
- describe "old unset interface" do
- before do
- bundle! "config --delete waka"
- end
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config get waka` instead.")
+ end
- it "does not warn", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
+ pending "fails with a helpful error", :bundler => "3"
+ end
- it "warns", :bundler => "2" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset waka` instead.")
- end
+ describe "old set interface" do
+ before do
+ bundle! "config waka wakapun"
end
- describe "old unset interface with --local" do
- before do
- bundle! "config --delete --local waka"
- end
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set waka wakapun` instead.")
+ end
- it "does not warn", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
+ pending "fails with a helpful error", :bundler => "3"
+ end
- it "warns", :bundler => "2" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --local waka` instead.")
- end
+ describe "old set interface with --local" do
+ before do
+ bundle! "config --local waka wakapun"
end
- describe "old unset interface with --global" do
- before do
- bundle! "config --delete --global waka"
- end
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --local waka wakapun` instead.")
+ end
- it "does not warn", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
+ pending "fails with a helpful error", :bundler => "3"
+ end
- it "warns", :bundler => "2" do
- expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --global waka` instead.")
- end
+ describe "old set interface with --global" do
+ before do
+ bundle! "config --global waka wakapun"
+ end
+
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --global waka wakapun` instead.")
end
+
+ pending "fails with a helpful error", :bundler => "3"
end
- describe "bundle update" do
+ describe "old unset interface" do
before do
- bundle! "install"
+ bundle! "config --delete waka"
end
- it "does not warn when no options are given", :bundler => "< 2" do
- bundle! "update"
- expect(deprecations).to be_empty
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset waka` instead.")
end
- it "warns when no options are given", :bundler => "2" do
- bundle! "update"
- expect(deprecations).to include("Pass --all to `bundle update` to update everything")
+ pending "fails with a helpful error", :bundler => "3"
+ end
+
+ describe "old unset interface with --local" do
+ before do
+ bundle! "config --delete --local waka"
end
- it "does not warn when --all is passed" do
- bundle! "update --all"
- expect(deprecations).to be_empty
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --local waka` instead.")
end
+
+ pending "fails with a helpful error", :bundler => "3"
end
- describe "bundle install --binstubs" do
+ describe "old unset interface with --global" do
before do
- bundle :install, :binstubs => true
+ bundle! "config --delete --global waka"
end
- it "should print no deprecations", :bundler => "< 2" do
- expect(deprecations).to be_empty
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --global waka` instead.")
end
- it "should output a deprecation warning", :bundler => "2" do
- expect(deprecations).to include("The --binstubs option will be removed in favor of `bundle binstubs`")
- end
+ pending "fails with a helpful error", :bundler => "3"
+ end
+ end
+
+ describe "bundle update" do
+ before do
+ install_gemfile <<-G
+ source "file:#{gem_repo1}"
+ gem "rack"
+ G
+ end
+
+ it "warns when no options are given", :bundler => "2" do
+ bundle! "update"
+ expect(deprecations).to include("Pass --all to `bundle update` to update everything")
+ end
+
+ pending "fails with a helpful error when no options are given", :bundler => "3"
+
+ it "does not warn when --all is passed" do
+ bundle! "update --all"
+ expect(deprecations).to be_empty
end
end
- context "when bundle install is run" do
+ describe "bundle install --binstubs" do
+ before do
+ install_gemfile <<-G, :binstubs => true
+ source "file:#{gem_repo1}"
+ gem "rack"
+ G
+ end
+
+ it "should output a deprecation warning", :bundler => "2" do
+ expect(deprecations).to include("The --binstubs option will be removed in favor of `bundle binstubs`")
+ end
+
+ pending "fails with a helpful error", :bundler => "3"
+ end
+
+ context "bundle install with both gems.rb and Gemfile present" do
it "should not warn about gems.rb" do
create_file "gems.rb", <<-G
source "file://#{gem_repo1}"
@@ -213,7 +240,7 @@ RSpec.describe "major deprecations" do
expect(deprecations).to be_empty
end
- it "should print a proper warning when both gems.rb and Gemfile present, and use Gemfile", :bundler => "< 2" do
+ it "should print a proper warning, and use gems.rb" do
create_file "gems.rb"
install_gemfile! <<-G
source "file://#{gem_repo1}"
@@ -221,72 +248,79 @@ RSpec.describe "major deprecations" do
G
expect(warnings).to include(
- "Multiple gemfiles (gems.rb and Gemfile) detected. The gems.rb and gems.rb.locked files are currently ignored, but they will get used as soon as you delete your Gemfile and Gemfile.lock files."
+ "Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked."
)
- expect(the_bundle).to include_gem "rack 1.0"
+ expect(the_bundle).not_to include_gem "rack 1.0"
end
+ end
- it "should print a proper warning when both gems.rb and Gemfile present, and use gems.rb", :bundler => "2" do
- create_file "gems.rb"
- install_gemfile! <<-G
+ context "bundle install with flags" do
+ before do
+ bundle "config set --local path vendor/bundle"
+
+ install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
-
- expect(warnings).to include(
- "Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked."
- )
-
- expect(the_bundle).not_to include_gem "rack 1.0"
end
- context "with flags" do
- before do
- install_gemfile <<-G, :path => "vendor/bundle"
- source "file://#{gem_repo1}"
- gem "rack"
- G
- end
-
- {
- :clean => true,
- :deployment => true,
- :frozen => true,
- :"no-cache" => true,
- :"no-prune" => true,
- :path => "vendor/bundle",
- :shebang => "ruby27",
- :system => true,
- :without => "development",
- :with => "development",
- }.each do |name, value|
- flag_name = "--#{name}"
-
- context "with the #{flag_name} flag", :bundler => "2" do
- it "should print a deprecation warning" do
- bundle "install #{flag_name} #{value}"
-
- expect(deprecations).to include(
- "The `#{flag_name}` flag is deprecated because it relies on " \
- "being remembered accross bundler invokations, which bundler " \
- "will no longer do in future versions. Instead please use " \
- "`bundle config #{name} '#{value}'`, and stop using this flag"
- )
- end
+ {
+ :clean => true,
+ :deployment => true,
+ :frozen => true,
+ :"no-cache" => true,
+ :"no-prune" => true,
+ :path => "vendor/bundle",
+ :shebang => "ruby27",
+ :system => true,
+ :without => "development",
+ :with => "development",
+ }.each do |name, value|
+ flag_name = "--#{name}"
+
+ context "with the #{flag_name} flag" do
+ before do
+ bundle "install" # to create a lockfile, which deployment or frozen need
+ bundle "install #{flag_name} #{value}"
end
- context "with the #{flag_name} flag", :bundler => "< 2" do
- it "should not print a deprecation warning" do
- bundle "install #{flag_name} #{value}"
-
- expect(deprecations).to be_empty
- end
+ it "should print a deprecation warning", :bundler => "2" do
+ expect(deprecations).to include(
+ "The `#{flag_name}` flag is deprecated because it relies on " \
+ "being remembered accross bundler invokations, which bundler " \
+ "will no longer do in future versions. Instead please use " \
+ "`bundle config #{name} '#{value}'`, and stop using this flag"
+ )
end
+
+ pending "should fail with a helpful error", :bundler => "3"
end
end
end
+ context "bundle install with multiple sources" do
+ before do
+ install_gemfile <<-G
+ source "file://localhost#{gem_repo3}"
+ source "file://localhost#{gem_repo1}"
+ G
+ end
+
+ it "shows a deprecation", :bundler => "2" do
+ expect(deprecations).to include(
+ "Your Gemfile contains multiple primary sources. " \
+ "Using `source` more than once without a block is a security risk, and " \
+ "may result in installing unexpected gems. To resolve this warning, use " \
+ "a block to indicate which gems should come from the secondary source. " \
+ "To upgrade this warning to an error, run `bundle config set " \
+ "disable_multisource true`."
+ )
+ end
+
+ pending "should fail with a helpful error", :bundler => "3"
+ end
+
context "when Bundler.setup is run in a ruby script" do
before do
create_file "gems.rb"
@@ -306,13 +340,7 @@ RSpec.describe "major deprecations" do
RUBY
end
- it "should print a single deprecation warning", :bundler => "< 2" do
- expect(warnings).to include(
- "Multiple gemfiles (gems.rb and Gemfile) detected. The gems.rb and gems.rb.locked files are currently ignored, but they will get used as soon as you delete your Gemfile and Gemfile.lock files."
- )
- end
-
- it "should print a single deprecation warning", :bundler => "2" do
+ it "should print a single deprecation warning" do
expect(warnings).to include(
"Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked."
)
@@ -326,16 +354,14 @@ RSpec.describe "major deprecations" do
RUBY
end
- it "should not print a capistrano deprecation warning", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
-
it "should print a capistrano deprecation warning", :bundler => "2" do
expect(deprecations).to include("Bundler no longer integrates " \
"with Capistrano, but Capistrano provides " \
"its own integration with Bundler via the " \
"capistrano-bundler gem. Use it instead.")
end
+
+ pending "should fail with a helpful error", :bundler => "3"
end
describe Bundler::Dsl do
@@ -367,14 +393,6 @@ The :github git source is deprecated, and will be removed in the future. Change
github_uri = "https://github.com/indirect/sparks.git"
expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
-
- it "upgrades to https on request", :bundler => "< 2" do
- Bundler.settings.temporary "github.https" => true
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
- subject.gem("sparks", :github => "indirect/sparks")
- github_uri = "https://github.com/indirect/sparks.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
- end
end
context "with bitbucket gems" do
@@ -416,17 +434,55 @@ The :gist git source is deprecated, and will be removed in the future. Add this
source "file://#{gem_repo1}"
gem "rack"
G
+ end
+
+ context "without flags" do
+ before do
+ bundle! :show
+ end
+
+ it "prints a deprecation warning recommending `bundle list`", :bundler => "2" do
+ expect(deprecations).to include("use `bundle list` instead of `bundle show`")
+ end
- bundle! :show
+ pending "fails with a helpful message", :bundler => "3"
end
- it "does not print a deprecation warning", :bundler => "< 2" do
- expect(deprecations).to be_empty
+ context "with --outdated flag" do
+ before do
+ bundle! "show --outdated"
+ end
+
+ it "prints a deprecation warning informing about its removal", :bundler => "2" do
+ expect(deprecations).to include("the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement")
+ end
+
+ pending "fails with a helpful message", :bundler => "3"
end
- it "prints a deprecation warning", :bundler => "2" do
- expect(deprecations).to include("use `bundle list` instead of `bundle show`")
+ context "with --verbose flag" do
+ before do
+ bundle! "show --verbose"
+ end
+
+ it "prints a deprecation warning informing about its removal", :bundler => "2" do
+ expect(deprecations).to include("the `--verbose` flag to `bundle show` was undocumented and will be removed without replacement")
+ end
+
+ pending "fails with a helpful message", :bundler => "3"
+ end
+
+ context "with a gem argument" do
+ before do
+ bundle! "show rack"
+ end
+
+ it "prints a deprecation warning recommending `bundle info`", :bundler => "2" do
+ expect(deprecations).to include("use `bundle info rack` instead of `bundle show rack`")
+ end
end
+
+ pending "fails with a helpful message", :bundler => "3"
end
context "bundle console" do
@@ -434,14 +490,12 @@ The :gist git source is deprecated, and will be removed in the future. Add this
bundle "console"
end
- it "does not print a deprecation warning", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
-
it "prints a deprecation warning", :bundler => "2" do
expect(deprecations).to include \
"bundle console will be replaced by `bin/console` generated by `bundle gem <name>`"
end
+
+ pending "fails with a helpful message", :bundler => "3"
end
context "bundle viz" do
@@ -456,12 +510,10 @@ The :gist git source is deprecated, and will be removed in the future. Add this
bundle "viz"
end
- it "does not print a deprecation warning", :bundler => "< 2" do
- expect(deprecations).to be_empty
- end
-
it "prints a deprecation warning", :bundler => "2" do
expect(deprecations).to include "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
end
+
+ pending "fails with a helpful message", :bundler => "3"
end
end
diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb
index cb47cc024e..9c62904286 100644
--- a/spec/other/platform_spec.rb
+++ b/spec/other/platform_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe "bundle platform" do
context "without flags" do
let(:bundle_platform_platforms_string) do
platforms = [rb]
- platforms.unshift(specific_local_platform) if Bundler.feature_flag.bundler_2_mode?
+ platforms.unshift(specific_local_platform) if Bundler.feature_flag.bundler_3_mode?
platforms.map {|pl| "* #{pl}" }.join("\n")
end
@@ -511,7 +511,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
@@ -528,7 +528,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
end
@@ -545,7 +545,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update, :all => bundle_update_requires_all?
+ bundle :update, :all => true
should_be_ruby_version_incorrect
end
@@ -561,7 +561,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update, :all => bundle_update_requires_all?
+ bundle :update, :all => true
should_be_engine_incorrect
end
@@ -578,7 +578,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update, :all => bundle_update_requires_all?
+ bundle :update, :all => true
should_be_engine_version_incorrect
end
end
@@ -594,7 +594,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update, :all => bundle_update_requires_all?
+ bundle :update, :all => true
should_be_patchlevel_incorrect
end
end
@@ -633,7 +633,7 @@ G
end
end
- it "fails if ruby version doesn't match", :bundler => "< 2" do
+ it "fails if ruby version doesn't match", :bundler => "< 3" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rails"
@@ -645,7 +645,7 @@ G
should_be_ruby_version_incorrect
end
- it "fails if engine doesn't match", :bundler => "< 2" do
+ it "fails if engine doesn't match", :bundler => "< 3" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rails"
@@ -657,7 +657,7 @@ G
should_be_engine_incorrect
end
- it "fails if engine version doesn't match", :bundler => "< 2" do
+ it "fails if engine version doesn't match", :bundler => "< 3" do
simulate_ruby_engine "jruby" do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -671,7 +671,7 @@ G
end
end
- it "fails when patchlevel doesn't match", :bundler => "< 2" do
+ it "fails when patchlevel doesn't match", :bundler => "< 3" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -928,7 +928,7 @@ G
end
end
- context "bundle console", :bundler => "< 2" do
+ context "bundle console", :bundler => "< 3" do
before do
install_gemfile <<-G
source "file://#{gem_repo1}"
diff --git a/spec/other/ssl_cert_spec.rb b/spec/other/ssl_cert_spec.rb
deleted file mode 100644
index 6d957276fc..0000000000
--- a/spec/other/ssl_cert_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/ssl_certs/certificate_manager"
-
-RSpec.describe "SSL Certificates", :rubygems_master do
- hosts = %w[
- rubygems.org
- index.rubygems.org
- rubygems.global.ssl.fastly.net
- staging.rubygems.org
- ]
-
- hosts.each do |host|
- it "can securely connect to #{host}", :realworld do
- Bundler::SSLCerts::CertificateManager.new.connect_to(host)
- end
- end
-end
diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb
index fd30892f63..bc076c06bf 100644
--- a/spec/plugins/source/example_spec.rb
+++ b/spec/plugins/source/example_spec.rb
@@ -67,7 +67,7 @@ RSpec.describe "real source plugins" do
expect(the_bundle).to include_gems("a-path-gem 1.0")
end
- it "writes to lock file", :bundler => "< 2" do
+ it "writes to lock file", :bundler => "< 3" do
bundle "install"
lockfile_should_be <<-G
@@ -92,20 +92,20 @@ RSpec.describe "real source plugins" do
G
end
- it "writes to lock file", :bundler => "2" do
+ it "writes to lock file", :bundler => "3" do
bundle "install"
lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
-
PLUGIN SOURCE
remote: #{lib_path("a-path-gem-1.0")}
type: mpath
specs:
a-path-gem (1.0)
+ GEM
+ remote: file://localhost#{gem_repo2}/
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -359,7 +359,7 @@ RSpec.describe "real source plugins" do
expect(the_bundle).to include_gems("ma-gitp-gem 1.0")
end
- it "writes to lock file", :bundler => "< 2" do
+ it "writes to lock file", :bundler => "< 3" do
revision = revision_for(lib_path("ma-gitp-gem-1.0"))
bundle "install"
@@ -386,15 +386,11 @@ RSpec.describe "real source plugins" do
G
end
- it "writes to lock file", :bundler => "2" do
+ it "writes to lock file", :bundler => "3" do
revision = revision_for(lib_path("ma-gitp-gem-1.0"))
bundle "install"
lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
-
PLUGIN SOURCE
remote: file://#{lib_path("ma-gitp-gem-1.0")}
type: gitp
@@ -402,6 +398,10 @@ RSpec.describe "real source plugins" do
specs:
ma-gitp-gem (1.0)
+ GEM
+ remote: file://localhost#{gem_repo2}/
+ specs:
+
PLATFORMS
#{lockfile_platforms}
diff --git a/spec/quality_es_spec.rb b/spec/quality_es_spec.rb
index 8fc653c45a..46eed8f18a 100644
--- a/spec/quality_es_spec.rb
+++ b/spec/quality_es_spec.rb
@@ -55,7 +55,7 @@ RSpec.describe "La biblioteca si misma" do
expect(error_messages.compact).to be_well_formed
end
- it "mantiene la calidad de lenguaje de oraciones usadas en el código fuente" do
+ it "mantiene la calidad de lenguaje de oraciones usadas en el código fuente", :ruby_repo do
error_messages = []
exempt = /vendor/
Dir.chdir(root) do
diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb
index 3ddc775fae..87279ebb74 100644
--- a/spec/quality_spec.rb
+++ b/spec/quality_spec.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require "set"
+
if defined?(Encoding) && Encoding.default_external.name != "UTF-8"
# An approximation of ruby -E UTF-8, since it works on 1.8.7
Encoding.default_external = Encoding.find("UTF-8")
@@ -97,7 +99,7 @@ RSpec.describe "The library itself" do
end
it "has no malformed whitespace" do
- exempt = /\.gitmodules|\.marshal|fixtures|vendor|ssl_certs|LICENSE|vcr_cassettes/
+ exempt = /\.gitmodules|\.marshal|fixtures|vendor|LICENSE|vcr_cassettes/
error_messages = []
Dir.chdir(root) do
lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib`
@@ -167,16 +169,13 @@ RSpec.describe "The library itself" do
exemptions = %w[
auto_config_jobs
cache_command_is_package
- console_command
deployment_means_frozen
forget_cli_options
gem.coc
gem.mit
github.https
inline
- lockfile_uses_separate_rubygems_sources
use_gem_version_promoter_for_major_updates
- viz_command
]
all_settings = Hash.new {|h, k| h[k] = [] }
@@ -228,9 +227,9 @@ RSpec.describe "The library itself" do
end
# there's no way around this warning
- last_command.stderr.sub!(/^YAML safe loading.*/, "")
+ err.sub!(/^YAML safe loading.*/, "")
- expect(last_command.stderr).to be_empty, "bundler should build as a gem without warnings, but\n#{err}"
+ expect(err).to be_empty, "bundler should build as a gem without warnings, but\n#{err}"
ensure
# clean up the .gem generated
FileUtils.rm("bundler-#{Bundler::VERSION}.gem")
@@ -238,7 +237,7 @@ RSpec.describe "The library itself" do
end
end
- it "ships the correct set of files" do
+ it "ships the correct set of files", :ruby_repo do
Dir.chdir(root) do
git_list = IO.popen("git ls-files -z", &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) }
git_list += %w[CHANGELOG.md LICENSE.md README.md bundler.gemspec]
@@ -276,4 +275,20 @@ RSpec.describe "The library itself" do
expect(warnings).to be_well_formed
end
end
+
+ it "does not use require internally, but require_relative" do
+ Dir.chdir(root) do
+ exempt = %r{templates/|vendor/}
+ all_bad_requires = []
+ lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib`
+ lib_files.split("\x0").each do |filename|
+ next if filename =~ exempt
+ File.readlines(filename).each_with_index do |line, number|
+ line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" }
+ end
+ end
+
+ expect(all_bad_requires).to be_empty, "#{all_bad_requires.size} internal requires that should use `require_relative`: #{all_bad_requires}"
+ end
+ end
end
diff --git a/spec/realworld/dependency_api_spec.rb b/spec/realworld/dependency_api_spec.rb
index 13527ce5d1..e7d11419cd 100644
--- a/spec/realworld/dependency_api_spec.rb
+++ b/spec/realworld/dependency_api_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe "gemcutter's dependency API", :realworld => true do
@server_uri = "http://127.0.0.1:#{port}"
require File.expand_path("../../support/artifice/endpoint_timeout", __FILE__)
- require "thread"
+
@t = Thread.new do
server = Rack::Server.start(:app => EndpointTimeout,
:Host => "0.0.0.0",
@@ -22,7 +22,7 @@ RSpec.describe "gemcutter's dependency API", :realworld => true do
@t.run
wait_for_server("127.0.0.1", port)
- bundle! "config timeout 1"
+ bundle! "config set timeout 1"
end
after do
diff --git a/spec/realworld/edgecases_spec.rb b/spec/realworld/edgecases_spec.rb
index 0189c55020..6468ee7f1e 100644
--- a/spec/realworld/edgecases_spec.rb
+++ b/spec/realworld/edgecases_spec.rb
@@ -23,12 +23,12 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
gemfile <<-G
source "https://rubygems.org"
- gem 'rails', '~> 3.0'
+ gem 'rails', '~> 5.0'
gem 'capybara', '~> 2.2.0'
gem 'rack-cache', '1.2.0' # last version that works on Ruby 1.9
G
bundle! :lock
- expect(lockfile).to include(rubygems_version("rails", "~> 3.0"))
+ expect(lockfile).to include(rubygems_version("rails", "~> 5.0"))
expect(lockfile).to include("capybara (2.2.1)")
end
@@ -37,7 +37,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
source "https://rubygems.org"
gem "sass-rails"
- gem "rails", "~> 3"
+ gem "rails", "~> 5"
gem "gxapi_rails", "< 0.1.0" # 0.1.0 was released way after the test was written
gem 'rack-cache', '1.2.0' # last version that works on Ruby 1.9
G
@@ -150,7 +150,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
activemodel (= 4.2.7.1)
activerecord (= 4.2.7.1)
activesupport (= 4.2.7.1)
- bundler (>= 1.3.0, < 2.0)
+ bundler (>= 1.3.0, < 3.0)
railties (= 4.2.7.1)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
@@ -201,9 +201,10 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
gem 'rack', '1.0.1'
G
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
+ bundle "config set --local path vendor/bundle"
+ bundle! :install
expect(err).not_to include("Could not find rake")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "checks out git repos when the lockfile is corrupted" do
@@ -330,7 +331,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
L
bundle! :lock
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "outputs a helpful error message when gems have invalid gemspecs" do
diff --git a/spec/realworld/gemfile_source_header_spec.rb b/spec/realworld/gemfile_source_header_spec.rb
index ad8897d68c..eaefd0f03e 100644
--- a/spec/realworld/gemfile_source_header_spec.rb
+++ b/spec/realworld/gemfile_source_header_spec.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "thread"
-
RSpec.describe "fetching dependencies with a mirrored source", :realworld => true do
let(:mirror) { "https://server.example.org" }
let(:original) { "http://127.0.0.1:#{@port}" }
diff --git a/spec/realworld/mirror_probe_spec.rb b/spec/realworld/mirror_probe_spec.rb
index 8235032321..13d1afe124 100644
--- a/spec/realworld/mirror_probe_spec.rb
+++ b/spec/realworld/mirror_probe_spec.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "thread"
-
RSpec.describe "fetching dependencies with a not available mirror", :realworld => true do
let(:mirror) { @mirror_uri }
let(:original) { @server_uri }
@@ -88,8 +86,8 @@ RSpec.describe "fetching dependencies with a not available mirror", :realworld =
bundle :install, :artifice => nil
- expect(last_command.stdout).to include "Fetching source index from #{mirror}/"
- expect(last_command.bundler_err).to include <<-EOS.strip
+ expect(out).to include "Fetching source index from #{mirror}/"
+ expect(err).to include <<-EOS.strip
Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}/
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}/
Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}/
diff --git a/spec/realworld/parallel_spec.rb b/spec/realworld/parallel_spec.rb
index ebb7987e0b..7738b46aac 100644
--- a/spec/realworld/parallel_spec.rb
+++ b/spec/realworld/parallel_spec.rb
@@ -34,7 +34,7 @@ RSpec.describe "parallel", :realworld => true, :sometimes => true do
gem 'i18n', '~> 0.6.0' # Because 0.7+ requires Ruby 1.9.3+
G
- bundle :update, :jobs => 4, :env => { "DEBUG" => "1" }, :all => bundle_update_requires_all?
+ bundle :update, :jobs => 4, :env => { "DEBUG" => "1" }, :all => true
expect(out).to match(/[1-3]: /)
diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb
index dcee234e15..b2d5b6c03f 100644
--- a/spec/runtime/executable_spec.rb
+++ b/spec/runtime/executable_spec.rb
@@ -99,7 +99,7 @@ RSpec.describe "Running bin/* commands" do
expect(bundled_app("bin/rackup")).not_to exist
end
- it "allows you to stop installing binstubs", :bundler => "< 2" do
+ it "allows you to stop installing binstubs", :bundler => "< 3" do
bundle! "install --binstubs bin/"
bundled_app("bin/rackup").rmtree
bundle! "install --binstubs \"\""
@@ -110,7 +110,7 @@ RSpec.describe "Running bin/* commands" do
expect(out).to include("You have not configured a value for `bin`")
end
- it "remembers that the option was specified", :bundler => "< 2" do
+ it "remembers that the option was specified", :bundler => "< 3" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "activesupport"
@@ -129,23 +129,6 @@ RSpec.describe "Running bin/* commands" do
expect(bundled_app("bin/rackup")).to exist
end
- it "rewrites bins on --binstubs (to maintain backwards compatibility)", :bundler => "< 2" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
-
- bundle! :install, forgotten_command_line_options([:binstubs, :bin] => "bin")
-
- File.open(bundled_app("bin/rackup"), "wb") do |file|
- file.print "OMG"
- end
-
- bundle "install"
-
- expect(bundled_app("bin/rackup").read).to_not eq("OMG")
- end
-
it "rewrites bins on binstubs (to maintain backwards compatibility)" do
install_gemfile! <<-G
source "file://#{gem_repo1}"
diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb
index 3c69f8a800..f0f48a01ac 100644
--- a/spec/runtime/gem_tasks_spec.rb
+++ b/spec/runtime/gem_tasks_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "require 'bundler/gem_tasks'", :ruby_repo do
+RSpec.describe "require 'bundler/gem_tasks'" do
before :each do
bundled_app("foo.gemspec").open("w") do |f|
f.write <<-GEMSPEC
@@ -22,7 +22,7 @@ RSpec.describe "require 'bundler/gem_tasks'", :ruby_repo do
sys_exec "#{rake} -T"
end
- expect(last_command.stderr).to eq("")
+ expect(err).to eq("")
expected_tasks = [
"rake build",
"rake clean",
@@ -39,6 +39,6 @@ RSpec.describe "require 'bundler/gem_tasks'", :ruby_repo do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect')
end
- expect(last_command.stdout).to eq '["pkg"]'
+ expect(out).to eq '["pkg"]'
end
end
diff --git a/spec/runtime/inline_spec.rb b/spec/runtime/inline_spec.rb
index 96a3fa09ae..d53c3d1c15 100644
--- a/spec/runtime/inline_spec.rb
+++ b/spec/runtime/inline_spec.rb
@@ -67,7 +67,7 @@ RSpec.describe "bundler/inline#gemfile" do
puts "success"
RUBY
- expect(last_command.stderr).to include "Could not find gem 'eleven'"
+ expect(err).to include "Could not find gem 'eleven'"
expect(out).not_to include "success"
script <<-RUBY
@@ -90,7 +90,7 @@ RSpec.describe "bundler/inline#gemfile" do
expect(out).to include("Installing activesupport")
err.gsub! %r{.*lib/sinatra/base\.rb:\d+: warning: constant ::Fixnum is deprecated$}, ""
err.strip!
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -134,7 +134,7 @@ RSpec.describe "bundler/inline#gemfile" do
puts "success"
RUBY
- expect(last_command.stderr).to include "Unknown options: arglebargle"
+ expect(err).to include "Unknown options: arglebargle"
expect(out).not_to include "success"
end
@@ -165,7 +165,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("1.0.0")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -183,7 +183,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("1.0.0\n2.0.0")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -203,7 +203,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("two\nfour")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -240,6 +240,20 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
end
+ expect(err).to be_empty
+ expect(exitstatus).to be_zero if exitstatus
+ end
+
+ it "installs inline gems when frozen is set" do
+ script <<-RUBY, :env => { "BUNDLE_FROZEN" => "true" }
+ gemfile do
+ source "file://#{gem_repo1}"
+ gem "rack"
+ end
+
+ puts RACK
+ RUBY
+
expect(last_command.stderr).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -258,7 +272,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
end
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -274,6 +288,19 @@ RSpec.describe "bundler/inline#gemfile" do
puts RACK
RUBY
expect(last_command).to be_success
- expect(last_command.stdout).to eq "1.0.0"
+ expect(out).to eq "1.0.0"
+ end
+
+ it "skips platform warnings" do
+ simulate_platform "ruby"
+
+ script <<-RUBY
+ gemfile(true) do
+ source "file://#{gem_repo1}"
+ gem "rack", platform: :jruby
+ end
+ RUBY
+
+ expect(err).to be_empty
end
end
diff --git a/spec/runtime/platform_spec.rb b/spec/runtime/platform_spec.rb
index eecf162427..11fe16f499 100644
--- a/spec/runtime/platform_spec.rb
+++ b/spec/runtime/platform_spec.rb
@@ -93,7 +93,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
gem "platform_specific"
G
- bundle! "config force_ruby_platform true"
+ bundle! "config set force_ruby_platform true"
bundle! "install"
@@ -108,7 +108,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
gem "platform_specific"
G
- bundle! "config force_ruby_platform true"
+ bundle! "config set force_ruby_platform true"
bundle! "install"
diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb
index c9cfa199d3..f149c9d489 100644
--- a/spec/runtime/require_spec.rb
+++ b/spec/runtime/require_spec.rb
@@ -136,8 +136,8 @@ RSpec.describe "Bundler.require" do
G
run "Bundler.require"
- expect(last_command.stderr).to match("error while trying to load the gem 'faulty'")
- expect(last_command.stderr).to match("Gem Internal Error Message")
+ expect(err).to match("error while trying to load the gem 'faulty'")
+ expect(err).to match("Gem Internal Error Message")
end
it "doesn't swallow the error when the library has an unrelated error" do
@@ -198,7 +198,7 @@ RSpec.describe "Bundler.require" do
RUBY
ruby(cmd)
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "does not mangle explicitly given requires" do
@@ -432,7 +432,7 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
G
run "Bundler.require"
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "requires gems pinned to multiple platforms, including the current one" do
@@ -447,6 +447,6 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
run "Bundler.require; puts RACK"
expect(out).to eq("1.0.0")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index d0bc44ca98..90c3df8661 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -1,5 +1,8 @@
# frozen_string_literal: true
+require "tmpdir"
+require "tempfile"
+
RSpec.describe "Bundler.setup" do
describe "with no arguments" do
it "makes all groups available" do
@@ -16,7 +19,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("1.0.0")
end
end
@@ -42,7 +45,7 @@ RSpec.describe "Bundler.setup" do
puts "WIN"
end
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("WIN")
end
@@ -55,7 +58,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("1.0.0")
end
@@ -69,7 +72,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("1.0.0")
end
@@ -87,7 +90,7 @@ RSpec.describe "Bundler.setup" do
puts "FAIL"
end
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to match("WIN")
end
@@ -101,8 +104,8 @@ RSpec.describe "Bundler.setup" do
puts "FAIL"
RUBY
- expect(last_command.stderr).to match("rack")
- expect(last_command.stderr).to match("LoadError")
+ expect(err).to match("rack")
+ expect(err).to match("LoadError")
expect(out).not_to match("FAIL")
end
end
@@ -138,7 +141,7 @@ RSpec.describe "Bundler.setup" do
load_path = out.split("\n")
rack_load_order = load_path.index {|path| path.include?("rack") }
- expect(last_command.stderr).to eq("")
+ expect(err).to eq("")
expect(load_path).to include(a_string_ending_with("dash_i_dir"), "rubylib_dir")
expect(rack_load_order).to be > 0
end
@@ -361,7 +364,7 @@ RSpec.describe "Bundler.setup" do
end
R
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "replaces #gem but raises when the version is wrong" do
@@ -387,7 +390,7 @@ RSpec.describe "Bundler.setup" do
end
R
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -446,7 +449,7 @@ RSpec.describe "Bundler.setup" do
it "provides a useful exception when the git repo is not checked out yet" do
run "1"
- expect(last_command.stderr).to match(/the git source #{lib_path('rack-1.0.0')} is not yet checked out. Please run `bundle install`/i)
+ expect(err).to match(/the git source #{lib_path('rack-1.0.0')} is not yet checked out. Please run `bundle install`/i)
end
it "does not hit the git binary if the lockfile is available and up to date" do
@@ -527,12 +530,12 @@ RSpec.describe "Bundler.setup" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle! :install
FileUtils.rm_rf(lib_path("local-rack"))
run "require 'rack'"
- expect(last_command.stderr).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
+ expect(err).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
end
it "explodes if branch is not given on runtime" do
@@ -545,7 +548,7 @@ RSpec.describe "Bundler.setup" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle! :install
gemfile <<-G
@@ -554,7 +557,7 @@ RSpec.describe "Bundler.setup" do
G
run "require 'rack'"
- expect(last_command.stderr).to match(/because :branch is not specified in Gemfile/)
+ expect(err).to match(/because :branch is not specified in Gemfile/)
end
it "explodes on different branches on runtime" do
@@ -567,7 +570,7 @@ RSpec.describe "Bundler.setup" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle! :install
gemfile <<-G
@@ -576,7 +579,7 @@ RSpec.describe "Bundler.setup" do
G
run "require 'rack'"
- expect(last_command.stderr).to match(/is using branch master but Gemfile specifies changed/)
+ expect(err).to match(/is using branch master but Gemfile specifies changed/)
end
it "explodes on refs with different branches on runtime" do
@@ -594,9 +597,9 @@ RSpec.describe "Bundler.setup" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :ref => "master", :branch => "nonexistant"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
run "require 'rack'"
- expect(last_command.stderr).to match(/is using branch master but Gemfile specifies nonexistant/)
+ expect(err).to match(/is using branch master but Gemfile specifies nonexistant/)
end
end
@@ -708,7 +711,7 @@ end
ENV["GEM_HOME"] = ""
bundle %(exec ruby -e "require 'set'")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
describe "$MANPATH" do
@@ -804,7 +807,7 @@ end
let(:gem_home) { Dir.mktmpdir }
let(:symlinked_gem_home) { Tempfile.new("gem_home").path }
let(:bundler_dir) { ruby_core? ? File.expand_path("../../../..", __FILE__) : File.expand_path("../../..", __FILE__) }
- let(:bundler_lib) { File.join(bundler_dir, "lib") }
+ let(:full_name) { "bundler-#{Bundler::VERSION}" }
before do
FileUtils.ln_sf(gem_home, symlinked_gem_home)
@@ -813,32 +816,30 @@ end
Dir.mkdir(gems_dir)
Dir.mkdir(specifications_dir)
- FileUtils.ln_s(bundler_dir, File.join(gems_dir, "bundler-#{Bundler::VERSION}"))
+ FileUtils.ln_s(bundler_dir, File.join(gems_dir, full_name))
gemspec_file = ruby_core? ? "#{bundler_dir}/lib/bundler/bundler.gemspec" : "#{bundler_dir}/bundler.gemspec"
- gemspec = File.read(gemspec_file).
+ gemspec = File.binread(gemspec_file).
sub("Bundler::VERSION", %("#{Bundler::VERSION}"))
gemspec = gemspec.lines.reject {|line| line =~ %r{lib/bundler/version} }.join
- File.open(File.join(specifications_dir, "bundler.gemspec"), "wb") do |f|
+ File.open(File.join(specifications_dir, "#{full_name}.gemspec"), "wb") do |f|
f.write(gemspec)
end
end
- # Can't make this pass on 2.6 since the ruby standard library has the same $LOAD_PATH
- # entry as bundler (since it's a default gem)
- it "should successfully require 'bundler/setup'", :ruby_repo, :ruby => "< 2.6" do
+ it "should not remove itself from the LOAD_PATH and require a different copy of 'bundler/setup'", :ruby_repo do
install_gemfile ""
- ruby <<-'R', :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true
- # Remove any bundler that's not the current bundler from $LOAD_PATH
- $LOAD_PATH.each do |path|
- $LOAD_PATH.delete(path) if File.exist?("#{path}/bundler.rb")
+ ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true
+ TracePoint.trace(:class) do |tp|
+ puts "OMG" if tp.path.include?("bundler") && !tp.path.start_with?("#{File.expand_path("../..", __dir__)}")
end
- puts (require 'bundler/setup')
+ gem 'bundler', '#{Bundler::VERSION}'
+ require 'bundler/setup'
R
- expect(out).to eql("true")
+ expect(out).to be_empty
end
end
@@ -877,7 +878,7 @@ end
require 'foo'
R
end
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "should make sure the Bundler.root is really included in the path relative to the Gemfile" do
@@ -902,7 +903,7 @@ end
R
end
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -980,7 +981,7 @@ end
describe "with system gems in the bundle" do
before :each do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
system_gems "rack-1.0.0"
install_gemfile <<-G
@@ -1052,7 +1053,7 @@ end
Bundler.load
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("")
end
end
@@ -1064,7 +1065,7 @@ end
G
bundle %(exec ruby -e "require 'bundler'; Bundler.setup")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -1213,7 +1214,7 @@ end
describe "default gem activation" do
let(:exemptions) do
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7") || ENV["RGV"] == "master"
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
[]
else
%w[io-console openssl]
@@ -1259,14 +1260,14 @@ end
it "activates no gems with -rbundler/setup" do
install_gemfile! ""
ruby! code, :env => { :RUBYOPT => activation_warning_hack_rubyopt + " -rbundler/setup" }
- expect(last_command.stdout).to eq("{}")
+ expect(out).to eq("{}")
end
it "activates no gems with bundle exec" do
install_gemfile! ""
create_file("script.rb", code)
bundle! "exec ruby ./script.rb", :env => { :RUBYOPT => activation_warning_hack_rubyopt }
- expect(last_command.stdout).to eq("{}")
+ expect(out).to eq("{}")
end
it "activates no gems with bundle exec that is loaded" do
@@ -1274,7 +1275,7 @@ end
create_file("script.rb", "#!/usr/bin/env ruby\n\n#{code}")
FileUtils.chmod(0o777, bundled_app("script.rb"))
bundle! "exec ./script.rb", :artifice => nil, :env => { :RUBYOPT => activation_warning_hack_rubyopt }
- expect(last_command.stdout).to eq("{}")
+ expect(out).to eq("{}")
end
let(:default_gems) do
@@ -1326,7 +1327,7 @@ end
end
describe "after setup" do
- it "allows calling #gem on random objects", :bundler => "< 2" do
+ it "allows calling #gem on random objects", :bundler => "< 3" do
install_gemfile <<-G
source "file:#{gem_repo1}"
gem "rack"
@@ -1341,7 +1342,7 @@ end
expect(out).to eq("rack-1.0.0")
end
- it "keeps Kernel#gem private", :bundler => "2" do
+ it "keeps Kernel#gem private", :bundler => "3" do
install_gemfile! <<-G
source "file:#{gem_repo1}"
gem "rack"
@@ -1354,7 +1355,7 @@ end
RUBY
expect(last_command.stdboth).not_to include "FAIL"
- expect(last_command.stderr).to include "private method `gem'"
+ expect(err).to include "private method `gem'"
end
it "keeps Kernel#require private" do
@@ -1370,7 +1371,7 @@ end
RUBY
expect(last_command.stdboth).not_to include "FAIL"
- expect(last_command.stderr).to include "private method `require'"
+ expect(err).to include "private method `require'"
end
end
end
diff --git a/spec/runtime/with_unbundled_env_spec.rb b/spec/runtime/with_unbundled_env_spec.rb
index c47f2912c5..b901f28c8b 100644
--- a/spec/runtime/with_unbundled_env_spec.rb
+++ b/spec/runtime/with_unbundled_env_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe "Bundler.with_env helpers" do
build_bundler_context
bundle! "exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2"
end
- expect(last_command.stderr).to eq <<-EOS.strip
+ expect(err).to eq <<-EOS.strip
2 false
1 true
0 true
@@ -98,28 +98,10 @@ RSpec.describe "Bundler.with_env helpers" do
it_behaves_like "an unbundling helper"
end
- describe "Bundler.clean_env" do
+ describe "Bundler.clean_env", :bundler => 2 do
let(:modified_env) { "Bundler.clean_env" }
it_behaves_like "an unbundling helper"
-
- it "prints a deprecation", :bundler => 2 do
- code = "Bundler.clean_env"
- bundle_exec_ruby! code.dump
- expect(err).to include(
- "[DEPRECATED] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
- )
- end
-
- it "does not print a deprecation", :bundler => "< 2" do
- code = "Bundler.clean_env"
- bundle_exec_ruby! code.dump
- expect(out).not_to include(
- "[DEPRECATED] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
- )
- end
end
describe "Bundler.with_original_env" do
@@ -138,7 +120,7 @@ RSpec.describe "Bundler.with_env helpers" do
end
end
- describe "Bundler.with_clean_env" do
+ describe "Bundler.with_clean_env", :bundler => 2 do
it "should set ENV to unbundled_env in the block" do
expected = Bundler.unbundled_env
actual = Bundler.with_clean_env { ENV.to_hash }
@@ -152,24 +134,6 @@ RSpec.describe "Bundler.with_env helpers" do
expect(ENV).not_to have_key("FOO")
end
-
- it "prints a deprecation", :bundler => 2 do
- code = "Bundler.with_clean_env {}"
- bundle_exec_ruby! code.dump
- expect(err).to include(
- "[DEPRECATED] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
- )
- end
-
- it "does not print a deprecation", :bundler => "< 2" do
- code = "Bundler.with_clean_env {}"
- bundle_exec_ruby! code.dump
- expect(out).not_to include(
- "[DEPRECATED] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
- )
- end
end
describe "Bundler.with_unbundled_env" do
@@ -188,20 +152,111 @@ RSpec.describe "Bundler.with_env helpers" do
end
end
- describe "Bundler.clean_system", :bundler => "< 2" do
+ describe "Bundler.original_system" do
+ let(:code) do
+ <<~RUBY
+ Bundler.original_system(%([ "\$BUNDLE_FOO" = "bar" ] && exit 42))
+
+ exit $?.exitstatus
+ RUBY
+ end
+
+ it "runs system inside with_original_env" do
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
+ expect($?.exitstatus).to eq(42)
+ end
+ end
+
+ describe "Bundler.clean_system", :bundler => 2 do
+ let(:code) do
+ <<~RUBY
+ Bundler.clean_system(%([ "\$BUNDLE_FOO" = "bar" ] || exit 42))
+
+ exit $?.exitstatus
+ RUBY
+ end
+
it "runs system inside with_clean_env" do
- Bundler.clean_system(%(echo 'if [ "$BUNDLE_PATH" = "" ]; then exit 42; else exit 1; fi' | /bin/sh))
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
expect($?.exitstatus).to eq(42)
end
end
- describe "Bundler.clean_exec", :bundler => "< 2" do
- it "runs exec inside with_clean_env" do
- pid = Kernel.fork do
- Bundler.clean_exec(%(echo 'if [ "$BUNDLE_PATH" = "" ]; then exit 42; else exit 1; fi' | /bin/sh))
- end
- Process.wait(pid)
+ describe "Bundler.unbundled_system" do
+ let(:code) do
+ <<~RUBY
+ Bundler.unbundled_system(%([ "\$BUNDLE_FOO" = "bar" ] || exit 42))
+
+ exit $?.exitstatus
+ RUBY
+ end
+
+ it "runs system inside with_unbundled_env" do
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
expect($?.exitstatus).to eq(42)
end
end
+
+ describe "Bundler.original_exec" do
+ let(:code) do
+ <<~RUBY
+ Process.fork do
+ exit Bundler.original_exec(%(test "\$BUNDLE_FOO" = "bar"))
+ end
+
+ _, status = Process.wait2
+
+ exit(status.exitstatus)
+ RUBY
+ end
+
+ it "runs exec inside with_original_env" do
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
+ expect($?.exitstatus).to eq(0)
+ end
+ end
+
+ describe "Bundler.clean_exec", :bundler => 2 do
+ let(:code) do
+ <<~RUBY
+ Process.fork do
+ exit Bundler.clean_exec(%(test "\$BUNDLE_FOO" = "bar"))
+ end
+
+ _, status = Process.wait2
+
+ exit(status.exitstatus)
+ RUBY
+ end
+
+ it "runs exec inside with_clean_env" do
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
+ expect($?.exitstatus).to eq(1)
+ end
+ end
+
+ describe "Bundler.unbundled_exec" do
+ let(:code) do
+ <<~RUBY
+ Process.fork do
+ exit Bundler.unbundled_exec(%(test "\$BUNDLE_FOO" = "bar"))
+ end
+
+ _, status = Process.wait2
+
+ exit(status.exitstatus)
+ RUBY
+ end
+
+ it "runs exec inside with_clean_env" do
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
+ expect($?.exitstatus).to eq(1)
+ end
+ end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 81c222ea6f..35cf8bfefb 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -13,6 +13,7 @@ if File.expand_path(__FILE__) =~ %r{([^\w/\.:\-])}
end
require "bundler"
+require "rspec"
Dir["#{File.expand_path("../support", __FILE__)}/*.rb"].each do |file|
file = file.gsub(%r{\A#{Regexp.escape File.expand_path("..", __FILE__)}/}, "")
@@ -29,8 +30,6 @@ ENV["BUNDLE_SPEC_RUN"] = "true"
# Don't wrap output in tests
ENV["THOR_COLUMNS"] = "10000"
-Spec::CodeClimate.setup
-
module Gem
def self.ruby=(ruby)
@ruby = ruby
diff --git a/spec/support/artifice/compact_index.rb b/spec/support/artifice/compact_index.rb
index f97c2b3fbc..4f01690ae4 100644
--- a/spec/support/artifice/compact_index.rb
+++ b/spec/support/artifice/compact_index.rb
@@ -57,11 +57,7 @@ class CompactIndexAPI < Endpoint
end
def slice_body(body, range)
- if body.respond_to?(:byteslice)
- body.byteslice(range)
- else # pre-1.9.3
- body.unpack("@#{range.first}a#{range.end + 1}").first
- end
+ body.byteslice(range)
end
def gems(gem_repo = GEM_REPO)
diff --git a/spec/support/code_climate.rb b/spec/support/code_climate.rb
deleted file mode 100644
index a15442cabe..0000000000
--- a/spec/support/code_climate.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-# frozen_string_literal: true
-
-module Spec
- module CodeClimate
- def self.setup
- require "codeclimate-test-reporter"
- ::CodeClimate::TestReporter.start
- configure_exclusions
- rescue LoadError
- # it's fine if CodeClimate isn't set up
- nil
- end
-
- def self.configure_exclusions
- SimpleCov.start do
- add_filter "/bin/"
- add_filter "/lib/bundler/man/"
- add_filter "/lib/bundler/vendor/"
- add_filter "/man/"
- add_filter "/pkg/"
- add_filter "/spec/"
- add_filter "/tmp/"
- end
- end
- end
-end
diff --git a/spec/support/command_execution.rb b/spec/support/command_execution.rb
index 556285ac52..cec531d6c3 100644
--- a/spec/support/command_execution.rb
+++ b/spec/support/command_execution.rb
@@ -27,14 +27,6 @@ module Spec
@stdboth ||= [stderr, stdout].join("\n").strip
end
- def bundler_err
- if Bundler::VERSION.start_with?("1.")
- stdout
- else
- stderr
- end
- end
-
def to_s_verbose
[
to_s,
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 151c99c3ff..478fe60822 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -45,13 +45,13 @@ module Spec
end
def err
- Bundler.feature_flag.error_on_stderr? ? last_command.stderr : last_command.stdout
+ last_command.stderr
end
MAJOR_DEPRECATION = /^\[DEPRECATED\]\s*/.freeze
def err_without_deprecations
- last_command.stderr.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "")
+ err.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "")
end
def deprecations
@@ -62,10 +62,6 @@ module Spec
last_command.exitstatus
end
- def bundle_update_requires_all?
- Bundler::VERSION.start_with?("1.") ? nil : true
- end
-
def in_app_root(&blk)
Dir.chdir(bundled_app, &blk)
end
@@ -81,7 +77,7 @@ module Spec
def run(cmd, *args)
opts = args.last.is_a?(Hash) ? args.pop : {}
groups = args.map(&:inspect).join(", ")
- setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n"
+ setup = "require 'bundler' ; Bundler.setup(#{groups})\n"
ruby(setup + cmd, opts)
end
bang :run
@@ -160,7 +156,7 @@ module Spec
bang :bundle
def forgotten_command_line_options(options)
- remembered = Bundler::VERSION.split(".", 2).first == "1"
+ remembered = Bundler::VERSION.split(".", 2).first == "2"
options = options.map do |k, v|
k = Array(k)[remembered ? 0 : -1]
v = '""' if v && v.to_s.empty?
@@ -268,18 +264,22 @@ module Spec
end
def gemfile(*args)
- if args.empty?
+ contents = args.shift
+
+ if contents.nil?
File.open("Gemfile", "r", &:read)
else
- create_file("Gemfile", *args)
+ create_file("Gemfile", contents, *args)
end
end
def lockfile(*args)
- if args.empty?
+ contents = args.shift
+
+ if contents.nil?
File.open("Gemfile.lock", "r", &:read)
else
- create_file("Gemfile.lock", *args)
+ create_file("Gemfile.lock", normalize_uri_file(contents), *args)
end
end
@@ -439,7 +439,7 @@ module Spec
ENV["GEM_PATH"] = system_gem_path.to_s
gems.each do |gem|
- gem_command :install, "--no-document #{gem}"
+ gem_command! :install, "--no-document #{gem}"
end
return unless block_given?
begin
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index 0a9285837a..5d1a6a7919 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -133,7 +133,7 @@ module Spec
rescue StandardError => e
next "#{name} is not installed:\n#{indent(e)}"
end
- actual_version, actual_platform = last_command.stdout.strip.split(/\s+/, 2)
+ actual_version, actual_platform = out.strip.split(/\s+/, 2)
unless Gem::Version.new(actual_version) == Gem::Version.new(version)
next "#{name} was expected to be at version #{version} but was #{actual_version}"
end
@@ -147,7 +147,7 @@ module Spec
rescue StandardError
next "#{name} does not have a source defined:\n#{indent(e)}"
end
- unless last_command.stdout.strip == source
+ unless out.strip == source
next "Expected #{name} (#{version}) to be installed from `#{source}`, was actually from `#{out}`"
end
end.compact
@@ -172,9 +172,9 @@ module Spec
rescue StandardError => e
next "checking for #{name} failed:\n#{e}"
end
- next if last_command.stdout == "WIN"
+ next if out == "WIN"
next "expected #{name} to not be installed, but it was" if version.nil?
- if Gem::Version.new(last_command.stdout) == Gem::Version.new(version)
+ if Gem::Version.new(out) == Gem::Version.new(version)
next "expected #{name} (#{version}) not to be installed, but it was"
end
end.compact
@@ -194,7 +194,7 @@ module Spec
RSpec::Matchers.alias_matcher :include_gem, :include_gems
def have_lockfile(expected)
- read_as(strip_whitespace(expected))
+ read_as(normalize_uri_file(strip_whitespace(expected)))
end
def plugin_should_be_installed(*names)
@@ -212,7 +212,7 @@ module Spec
end
def lockfile_should_be(expected)
- expect(bundled_app("Gemfile.lock")).to read_as(normalize_uri_file(strip_whitespace(expected)))
+ expect(bundled_app("Gemfile.lock")).to have_lockfile(expected)
end
def gemfile_should_be(expected)
diff --git a/spec/support/path.rb b/spec/support/path.rb
index ae7a8c5bbe..dc4b3bb6eb 100644
--- a/spec/support/path.rb
+++ b/spec/support/path.rb
@@ -29,7 +29,7 @@ module Spec
end
def default_bundle_path(*path)
- if Bundler::VERSION.split(".").first.to_i < 2
+ if Bundler::VERSION.split(".").first.to_i < 3
system_gem_path(*path)
else
bundled_app(*[".bundle", ENV.fetch("BUNDLER_SPEC_RUBY_ENGINE", Gem.ruby_engine), Gem::ConfigMap[:ruby_version], *path].compact)
diff --git a/spec/support/platforms.rb b/spec/support/platforms.rb
index 39040a61bd..caac7734bf 100644
--- a/spec/support/platforms.rb
+++ b/spec/support/platforms.rb
@@ -100,13 +100,12 @@ module Spec
9999
end
- def lockfile_platforms(*platforms)
- platforms = local_platforms if platforms.empty?
- platforms.map(&:to_s).sort.join("\n ")
+ def lockfile_platforms
+ local_platforms.map(&:to_s).sort.join("\n ")
end
def local_platforms
- if Bundler::VERSION.split(".").first.to_i > 1
+ if Bundler.feature_flag.specific_platform?
[local, specific_local_platform]
else
[local]
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index edd66278ad..2f3d252865 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -2,6 +2,7 @@
require "rubygems/user_interaction"
require "support/path"
+require "fileutils"
module Spec
module Rubygems
diff --git a/spec/update/gemfile_spec.rb b/spec/update/gemfile_spec.rb
index 6bab457a76..6c47c254cd 100644
--- a/spec/update/gemfile_spec.rb
+++ b/spec/update/gemfile_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe "bundle update" do
G
bundle! :install, :gemfile => bundled_app("NotGemfile")
- bundle! :update, :gemfile => bundled_app("NotGemfile"), :all => bundle_update_requires_all?
+ bundle! :update, :gemfile => bundled_app("NotGemfile"), :all => true
# Specify BUNDLE_GEMFILE for `the_bundle`
# to retrieve the proper Gemfile
@@ -30,7 +30,7 @@ RSpec.describe "bundle update" do
end
it "uses the gemfile to update" do
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
bundle "list"
expect(out).to include("rack (1.0.0)")
@@ -39,28 +39,11 @@ RSpec.describe "bundle update" do
it "uses the gemfile while in a subdirectory" do
bundled_app("subdir").mkpath
Dir.chdir(bundled_app("subdir")) do
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
bundle "list"
expect(out).to include("rack (1.0.0)")
end
end
end
-
- context "with prefer_gems_rb set" do
- before { bundle! "config prefer_gems_rb true" }
-
- it "prefers gems.rb to Gemfile" do
- create_file("gems.rb", "gem 'bundler'")
- create_file("Gemfile", "raise 'wrong Gemfile!'")
-
- bundle! :install
- bundle! :update, :all => bundle_update_requires_all?
-
- expect(bundled_app("gems.rb")).to be_file
- expect(bundled_app("Gemfile.lock")).not_to be_file
-
- expect(the_bundle).to include_gem "bundler #{Bundler::VERSION}"
- end
- end
end
diff --git a/spec/update/gems/post_install_spec.rb b/spec/update/gems/post_install_spec.rb
index 2fb3547806..f6b7f39d0b 100644
--- a/spec/update/gems/post_install_spec.rb
+++ b/spec/update/gems/post_install_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe "bundle update" do
gem 'thin'
G
- bundle! "config #{config}" if config
+ bundle! "config set #{config}" if config
bundle! :install
end
@@ -52,7 +52,7 @@ RSpec.describe "bundle update" do
gem 'thin'
G
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
end
it_behaves_like "a post-install message outputter"
@@ -67,7 +67,7 @@ RSpec.describe "bundle update" do
gem 'thin'
G
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
end
it_behaves_like "a post-install message outputter"
diff --git a/spec/update/git_spec.rb b/spec/update/git_spec.rb
index a09805bef0..bc230a3575 100644
--- a/spec/update/git_spec.rb
+++ b/spec/update/git_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe "bundle update" do
s.write "lib/foo.rb", "FOO = '1.1'"
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "foo 1.1"
end
@@ -88,7 +88,7 @@ RSpec.describe "bundle update" do
gem "foo", "1.0", :git => "#{lib_path("foo_two")}"
G
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to include("Fetching #{lib_path}/foo_two")
expect(out).to include("Bundle complete!")
end
@@ -111,7 +111,7 @@ RSpec.describe "bundle update" do
gem 'foo', :git => "#{@remote.path}", :tag => "fubar"
G
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(exitstatus).to eq(0) if exitstatus
end
@@ -191,8 +191,8 @@ RSpec.describe "bundle update" do
lib_path("foo-1.0").join(".git").rmtree
- bundle :update, :all => bundle_update_requires_all?
- expect(last_command.bundler_err).to include(lib_path("foo-1.0").to_s).
+ bundle :update, :all => true
+ expect(err).to include(lib_path("foo-1.0").to_s).
and match(/Git error: command `git fetch.+has failed/)
end
@@ -208,7 +208,7 @@ RSpec.describe "bundle update" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle "update rack"
expect(out).to include("Bundle updated!")
end
@@ -233,7 +233,7 @@ RSpec.describe "bundle update" do
rails!
G
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(out).to include("Using rails 3.0 (was 2.3.2) from #{lib_path("rails")} (at master@#{revision_for(lib_path("rails"))[0..6]})")
end
end
@@ -299,7 +299,7 @@ RSpec.describe "bundle update" do
G
end
- it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "< 2" do
+ it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "< 3" do
spec_lines = lib_path("bar/foo.gemspec").read.split("\n")
spec_lines[5] = "s.version = '2.0'"
@@ -335,7 +335,7 @@ RSpec.describe "bundle update" do
G
end
- it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "2" do
+ it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "3" do
spec_lines = lib_path("bar/foo.gemspec").read.split("\n")
spec_lines[5] = "s.version = '2.0'"
@@ -348,17 +348,17 @@ RSpec.describe "bundle update" do
bundle "update --source bar"
lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
- rack (1.0.0)
-
GIT
remote: #{@git.path}
revision: #{ref}
specs:
foo (2.0)
+ GEM
+ remote: file://localhost#{gem_repo2}/
+ specs:
+ rack (1.0.0)
+
PLATFORMS
#{lockfile_platforms}
diff --git a/spec/update/redownload_spec.rb b/spec/update/redownload_spec.rb
index b70c009248..39edac0902 100644
--- a/spec/update/redownload_spec.rb
+++ b/spec/update/redownload_spec.rb
@@ -18,16 +18,6 @@ RSpec.describe "bundle update" do
bundle! "update rack --no-color --force"
expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
-
- it "does not show a deprecation when single flag passed", :bundler => "< 2" do
- bundle! "update rack --force"
- expect(out).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
-
- it "does not show a deprecation when multiple flags passed", :bundler => "< 2" do
- bundle! "update rack --no-color --force"
- expect(out).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
- end
end
describe "with --redownload" do