aboutsummaryrefslogtreecommitdiffstats
path: root/spec/bundler/other/major_deprecation_spec.rb
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
commitdfe59a99f40c2f133ab0d3744d090de842c52f57 (patch)
tree51eae376f93c09bc82dde5a657a91df2c89062e4 /spec/bundler/other/major_deprecation_spec.rb
parent757c38a189bf3bc0255072876693ee309eaa319f (diff)
downloadruby-dfe59a99f40c2f133ab0d3744d090de842c52f57.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/major_deprecation_spec.rb')
-rw-r--r--spec/bundler/other/major_deprecation_spec.rb106
1 files changed, 70 insertions, 36 deletions
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