aboutsummaryrefslogtreecommitdiffstats
path: root/spec/bundler/other
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-01 23:29:38 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-01 23:29:38 +0000
commitbe7b5929126cb3e696ef222339237faba9b8fe5a (patch)
tree51eae376f93c09bc82dde5a657a91df2c89062e4 /spec/bundler/other
parentae49dbd392083f69026f2a0fff4a1d5f42d172a7 (diff)
downloadruby-be7b5929126cb3e696ef222339237faba9b8fe5a.tar.gz
Update bundled bundler to 1.16.0.
* lib/bundler, spec/bundler: Merge bundler-1.16.0. * common.mk: rspec examples of bundler-1.16.0 needs require option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/bundler/other')
-rw-r--r--spec/bundler/other/bundle_ruby_spec.rb3
-rw-r--r--spec/bundler/other/cli_dispatch_spec.rb21
-rw-r--r--spec/bundler/other/compatibility_guard_spec.rb25
-rw-r--r--spec/bundler/other/ext_spec.rb1
-rw-r--r--spec/bundler/other/major_deprecation_spec.rb106
-rw-r--r--spec/bundler/other/platform_spec.rb69
-rw-r--r--spec/bundler/other/ssl_cert_spec.rb6
7 files changed, 151 insertions, 80 deletions
diff --git a/spec/bundler/other/bundle_ruby_spec.rb b/spec/bundler/other/bundle_ruby_spec.rb
index 0ef6f407bf..6cc33f60ac 100644
--- a/spec/bundler/other/bundle_ruby_spec.rb
+++ b/spec/bundler/other/bundle_ruby_spec.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
-require "spec_helper"
-RSpec.describe "bundle_ruby", :ruby_repo do
+RSpec.describe "bundle_ruby", :bundler => "< 2" do
context "without patchlevel" do
it "returns the ruby version" do
gemfile <<-G
diff --git a/spec/bundler/other/cli_dispatch_spec.rb b/spec/bundler/other/cli_dispatch_spec.rb
index 8b34a457ef..a9d0bf7462 100644
--- a/spec/bundler/other/cli_dispatch_spec.rb
+++ b/spec/bundler/other/cli_dispatch_spec.rb
@@ -1,22 +1,29 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "bundle command names" do
it "work when given fully" do
bundle "install"
- expect(err).to lack_errors
- expect(out).not_to match(/Ambiguous command/)
+ expect(last_command.bundler_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(err).to lack_errors
- expect(out).not_to match(/Ambiguous command/)
+ expect(last_command.bundler_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(err).to lack_errors
- expect(out).to match(/Ambiguous command/)
+ expect(last_command.bundler_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" }
+
+ it "dispatches `bundle cache` to the package command" do
+ bundle "cache --verbose"
+ expect(last_command.stdout).to start_with "Running `bundle package --no-color --verbose`"
+ end
end
end
diff --git a/spec/bundler/other/compatibility_guard_spec.rb b/spec/bundler/other/compatibility_guard_spec.rb
new file mode 100644
index 0000000000..ac05ebd918
--- /dev/null
+++ b/spec/bundler/other/compatibility_guard_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+RSpec.describe "bundler compatibility guard" do
+ context "when the bundler version is 2+" do
+ before { simulate_bundler_version "2.0.a" }
+
+ context "when running on Ruby < 2.3", :ruby => "< 2.3" do
+ before { simulate_rubygems_version "2.6.11" }
+
+ it "raises a friendly error" do
+ bundle :version
+ expect(err).to eq("Bundler 2 requires Ruby 2.3 or later. Either install bundler 1 or update to a supported Ruby version.")
+ end
+ end
+
+ context "when running on RubyGems < 2.5", :ruby => ">= 2.5" do
+ before { simulate_rubygems_version "1.3.6" }
+
+ it "raises a friendly error" do
+ bundle :version
+ expect(err).to eq("Bundler 2 requires RubyGems 2.5 or later. Either install bundler 1 or update to a supported RubyGems version.")
+ end
+ end
+ end
+end
diff --git a/spec/bundler/other/ext_spec.rb b/spec/bundler/other/ext_spec.rb
index 2d6ab941b8..3f6f8b4928 100644
--- a/spec/bundler/other/ext_spec.rb
+++ b/spec/bundler/other/ext_spec.rb
@@ -1,5 +1,4 @@
# frozen_string_literal: true
-require "spec_helper"
RSpec.describe "Gem::Specification#match_platform" do
it "does not match platforms other than the gem platform" do
diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb
index 196fbe0c31..fba177b497 100644
--- a/spec/bundler/other/major_deprecation_spec.rb
+++ b/spec/bundler/other/major_deprecation_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require "spec_helper"
-RSpec.describe "major deprecations" do
- let(:warnings) { out } # change to err in 2.0
+RSpec.describe "major deprecations", :bundler => "< 2" do
+ let(:warnings) { last_command.bundler_err } # change to err in 2.0
+ let(:warnings_without_version_messages) { warnings.gsub(/#{Spec::Matchers::MAJOR_DEPRECATION}Bundler will only support ruby(gems)? >= .*/, "") }
context "in a .99 version" do
before do
@@ -23,17 +23,18 @@ RSpec.describe "major deprecations" do
before do
bundle "config major_deprecations true"
- install_gemfile <<-G
+ create_file "gems.rb", <<-G
source "file:#{gem_repo1}"
ruby #{RUBY_VERSION.dump}
gem "rack"
G
+ bundle! "install"
end
- describe "bundle_ruby", :ruby_repo do
+ describe "bundle_ruby" do
it "prints a deprecation" do
bundle_ruby
- out.gsub! "\nruby #{RUBY_VERSION}", ""
+ warnings.gsub! "\nruby #{RUBY_VERSION}", ""
expect(warnings).to have_major_deprecation "the bundle_ruby executable has been removed in favor of `bundle platform --ruby`"
end
end
@@ -86,7 +87,24 @@ RSpec.describe "major deprecations" do
describe "bundle update --quiet" do
it "does not print any deprecations" do
bundle :update, :quiet => true
- expect(warnings).not_to have_major_deprecation
+ expect(warnings_without_version_messages).not_to have_major_deprecation
+ end
+ end
+
+ describe "bundle update" do
+ before do
+ create_file("gems.rb", "")
+ bundle! "install"
+ end
+
+ it "warns when no options are given" do
+ bundle! "update"
+ expect(warnings).to have_major_deprecation a_string_including("Pass --all to `bundle update` to update everything")
+ end
+
+ it "does not warn when --all is passed" do
+ bundle! "update --all"
+ expect(warnings_without_version_messages).not_to have_major_deprecation
end
end
@@ -110,17 +128,18 @@ RSpec.describe "major deprecations" do
G
bundle :install
- expect(err).not_to have_major_deprecation
- expect(out).not_to have_major_deprecation
+ expect(warnings_without_version_messages).not_to have_major_deprecation
end
it "should print a Gemfile deprecation warning" do
- install_gemfile <<-G
+ create_file "gems.rb"
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
G
+ expect(the_bundle).to include_gem "rack 1.0"
- expect(warnings).to have_major_deprecation("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.")
+ expect(warnings).to have_major_deprecation a_string_including("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.")
end
context "with flags" do
@@ -139,7 +158,8 @@ RSpec.describe "major deprecations" do
context "when Bundler.setup is run in a ruby script" do
it "should print a single deprecation warning" do
- install_gemfile <<-G
+ create_file "gems.rb"
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack", :group => :test
G
@@ -154,7 +174,7 @@ RSpec.describe "major deprecations" do
Bundler.setup
RUBY
- expect(warnings).to have_major_deprecation("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.")
+ expect(warnings_without_version_messages).to have_major_deprecation("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.")
end
end
@@ -179,17 +199,27 @@ RSpec.describe "major deprecations" do
context "with github gems" do
it "warns about the https change" do
- msg = "The :github option uses the git: protocol, which is not secure. " \
- "Bundler 2.0 will use the https: protocol, which is secure. Enable this change now by " \
- "running `bundle config github.https true`."
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(msg)
+ msg = <<-EOS
+The :github git source is deprecated, and will be removed in Bundler 2.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work:
+
+ git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
+
+ EOS
+ expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg)
subject.gem("sparks", :github => "indirect/sparks")
end
it "upgrades to https on request" do
- Bundler.settings["github.https"] = true
+ Bundler.settings.temporary "github.https" => true
+ msg = <<-EOS
+The :github git source is deprecated, and will be removed in Bundler 2.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work:
+
+ git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
+
+ EOS
+ expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg)
+ expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, "The `github.https` setting will be removed")
subject.gem("sparks", :github => "indirect/sparks")
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).never
github_uri = "https://github.com/indirect/sparks.git"
expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
@@ -198,12 +228,17 @@ RSpec.describe "major deprecations" do
context "with bitbucket gems" do
it "warns about removal" do
allow(Bundler.ui).to receive(:deprecate)
- msg = "The :bitbucket git source is deprecated, and will be removed " \
- "in Bundler 2.0. Add this code to your Gemfile to ensure it " \
- "continues to work:\n git_source(:bitbucket) do |repo_name|\n " \
- " \"https://\#{user_name}@bitbucket.org/\#{user_name}/\#{repo_name}" \
- ".git\"\n end\n"
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(msg)
+ msg = <<-EOS
+The :bitbucket git source is deprecated, and will be removed in Bundler 2.0. Add this code to the top of your Gemfile to ensure it continues to work:
+
+ git_source(:bitbucket) do |repo_name|
+ user_name, repo_name = repo_name.split("/")
+ repo_name ||= user_name
+ "https://\#{user_name}@bitbucket.org/\#{user_name}/\#{repo_name}.git"
+ end
+
+ EOS
+ expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg)
subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails")
end
end
@@ -212,28 +247,27 @@ RSpec.describe "major deprecations" do
it "warns about removal" do
allow(Bundler.ui).to receive(:deprecate)
msg = "The :gist git source is deprecated, and will be removed " \
- "in Bundler 2.0. Add this code to your Gemfile to ensure it " \
- "continues to work:\n git_source(:gist) do |repo_name|\n " \
- " \"https://gist.github.com/\#{repo_name}.git\"\n" \
- " end\n"
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(msg)
+ "in Bundler 2.0. Add this code to the top of your Gemfile to ensure it " \
+ "continues to work:\n\n git_source(:gist) {|repo_name| " \
+ "\"https://gist.github.com/\#{repo_name}.git\" }\n\n"
+ expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg)
subject.gem("not-really-a-gem", :gist => "1234")
end
end
end
- context "bundle list" do
+ context "bundle show" do
it "prints a deprecation warning" do
- install_gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
G
- bundle :list
+ bundle! :show
- out.gsub!(/gems included.*?\[DEPRECATED/im, "[DEPRECATED")
+ warnings.gsub!(/gems included.*?\[DEPRECATED/im, "[DEPRECATED")
- expect(warnings).to have_major_deprecation("use `bundle show` instead of `bundle list`")
+ expect(warnings).to have_major_deprecation a_string_including("use `bundle list` instead of `bundle show`")
end
end
@@ -242,7 +276,7 @@ RSpec.describe "major deprecations" do
bundle "console"
expect(warnings).to have_major_deprecation \
- "bundle console will be replaced by `bin/console` generated by `bundle gem <name>`"
+ a_string_including("bundle console will be replaced by `bin/console` generated by `bundle gem <name>`")
end
end
end
diff --git a/spec/bundler/other/platform_spec.rb b/spec/bundler/other/platform_spec.rb
index 6adbcef111..fea5daf5ac 100644
--- a/spec/bundler/other/platform_spec.rb
+++ b/spec/bundler/other/platform_spec.rb
@@ -1,8 +1,13 @@
# frozen_string_literal: true
-require "spec_helper"
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.map {|pl| "* #{pl}" }.join("\n")
+ end
+
it "returns all the output" do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -17,7 +22,7 @@ RSpec.describe "bundle platform" do
Your platform is: #{RUBY_PLATFORM}
Your app has gems that work on these platforms:
-* ruby
+#{bundle_platform_platforms_string}
Your Gemfile specifies a Ruby version requirement:
* ruby #{RUBY_VERSION}
@@ -40,7 +45,7 @@ G
Your platform is: #{RUBY_PLATFORM}
Your app has gems that work on these platforms:
-* ruby
+#{bundle_platform_platforms_string}
Your Gemfile specifies a Ruby version requirement:
* ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}
@@ -61,7 +66,7 @@ G
Your platform is: #{RUBY_PLATFORM}
Your app has gems that work on these platforms:
-* ruby
+#{bundle_platform_platforms_string}
Your Gemfile does not specify a Ruby version requirement.
G
@@ -81,7 +86,7 @@ G
Your platform is: #{RUBY_PLATFORM}
Your app has gems that work on these platforms:
-* ruby
+#{bundle_platform_platforms_string}
Your Gemfile specifies a Ruby version requirement:
* ruby #{not_local_ruby_version}
@@ -493,7 +498,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle "update"
+ bundle "update", :all => bundle_update_requires_all?
expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
@@ -510,7 +515,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle "update"
+ bundle "update", :all => bundle_update_requires_all?
expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
end
@@ -527,7 +532,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update
+ bundle :update, :all => bundle_update_requires_all?
should_be_ruby_version_incorrect
end
@@ -543,7 +548,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update
+ bundle :update, :all => bundle_update_requires_all?
should_be_engine_incorrect
end
@@ -560,7 +565,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update
+ bundle :update, :all => bundle_update_requires_all?
should_be_engine_version_incorrect
end
end
@@ -576,12 +581,12 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update
+ bundle :update, :all => bundle_update_requires_all?
should_be_patchlevel_incorrect
end
end
- context "bundle show" do
+ context "bundle info" do
before do
install_gemfile <<-G
source "file://#{gem_repo1}"
@@ -590,32 +595,32 @@ G
end
it "prints path if ruby version is correct" do
- gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rails"
#{ruby_version_correct}
G
- bundle "show rails"
+ bundle "info rails --path"
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
it "prints path if ruby version is correct for any engine" do
simulate_ruby_engine "jruby" do
- gemfile <<-G
+ install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rails"
#{ruby_version_correct_engineless}
G
- bundle "show rails"
+ bundle "info rails --path"
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
end
- it "fails if ruby version doesn't match" do
+ it "fails if ruby version doesn't match", :bundler => "< 2" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rails"
@@ -627,7 +632,7 @@ G
should_be_ruby_version_incorrect
end
- it "fails if engine doesn't match" do
+ it "fails if engine doesn't match", :bundler => "< 2" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rails"
@@ -639,7 +644,7 @@ G
should_be_engine_incorrect
end
- it "fails if engine version doesn't match" do
+ it "fails if engine version doesn't match", :bundler => "< 2" do
simulate_ruby_engine "jruby" do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -653,7 +658,7 @@ G
end
end
- it "fails when patchlevel doesn't match" do
+ it "fails when patchlevel doesn't match", :bundler => "< 2" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -671,11 +676,10 @@ G
context "bundle cache" do
before do
- gemfile <<-G
+ install_gemfile <<-G
+ source "file:#{gem_repo1}"
gem 'rack'
G
-
- system_gems "rack-1.0.0"
end
it "copies the .gem file to vendor/cache when ruby version matches" do
@@ -691,13 +695,14 @@ G
it "copies the .gem file to vendor/cache when ruby version matches for any engine" do
simulate_ruby_engine "jruby" do
- gemfile <<-G
+ install_gemfile! <<-G
+ source "file:#{gem_repo1}"
gem 'rack'
#{ruby_version_correct_engineless}
G
- bundle :cache
+ bundle! :cache
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
end
end
@@ -752,11 +757,10 @@ G
context "bundle pack" do
before do
- gemfile <<-G
+ install_gemfile! <<-G
+ source "file:#{gem_repo1}"
gem 'rack'
G
-
- system_gems "rack-1.0.0"
end
it "copies the .gem file to vendor/cache when ruby version matches" do
@@ -772,7 +776,8 @@ G
it "copies the .gem file to vendor/cache when ruby version matches any engine" do
simulate_ruby_engine "jruby" do
- gemfile <<-G
+ install_gemfile! <<-G
+ source "file:#{gem_repo1}"
gem 'rack'
#{ruby_version_correct_engineless}
@@ -834,7 +839,7 @@ G
context "bundle exec" do
before do
ENV["BUNDLER_FORCE_TTY"] = "true"
- system_gems "rack-1.0.0", "rack-0.9.1"
+ system_gems "rack-1.0.0", "rack-0.9.1", :path => :bundle_path
end
it "activates the correct gem when ruby version matches" do
@@ -850,6 +855,7 @@ G
it "activates the correct gem when ruby version matches any engine" do
simulate_ruby_engine "jruby" do
+ system_gems "rack-1.0.0", "rack-0.9.1", :path => :bundle_path
gemfile <<-G
gem "rack", "0.9.1"
@@ -909,7 +915,7 @@ G
end
end
- context "bundle console" do
+ context "bundle console", :bundler => "< 2" do
before do
install_gemfile <<-G
source "file://#{gem_repo1}"
@@ -1174,6 +1180,7 @@ G
it "returns list of outdated gems when the ruby version matches for any engine" do
simulate_ruby_engine "jruby" do
+ bundle! :install
update_repo2 do
build_gem "activesupport", "3.0"
update_git "foo", :path => lib_path("foo")
diff --git a/spec/bundler/other/ssl_cert_spec.rb b/spec/bundler/other/ssl_cert_spec.rb
index 2de4dfdd0c..6d957276fc 100644
--- a/spec/bundler/other/ssl_cert_spec.rb
+++ b/spec/bundler/other/ssl_cert_spec.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-require "spec_helper"
+
require "bundler/ssl_certs/certificate_manager"
RSpec.describe "SSL Certificates", :rubygems_master do
- hosts = %w(
+ 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