Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Merged
4 changes: 2 additions & 2 deletions lib/bundler/feature_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def self.settings_method(name, key, &default)
settings_flag(:auto_config_jobs) { bundler_2_mode? }
settings_flag(:cache_all) { bundler_2_mode? }
settings_flag(:cache_command_is_package) { bundler_2_mode? }
settings_flag(:console_command) { !bundler_2_mode? }
settings_flag(:console_command) { !bundler_3_mode? }
settings_flag(:default_install_uses_path) { bundler_2_mode? }
settings_flag(:deployment_means_frozen) { bundler_2_mode? }
settings_flag(:disable_multisource) { bundler_2_mode? }
Expand All @@ -54,7 +54,7 @@ def self.settings_method(name, key, &default)
settings_flag(:specific_platform) { bundler_2_mode? }
settings_flag(:suppress_install_using_messages) { bundler_2_mode? }
settings_flag(:unlock_source_unlocks_spec) { !bundler_2_mode? }
settings_flag(:update_requires_all_flag) { bundler_2_mode? }
settings_flag(:update_requires_all_flag) { bundler_3_mode? }
settings_flag(:use_gem_version_promoter_for_major_updates) { bundler_2_mode? }
settings_flag(:viz_command) { !bundler_2_mode? }

Expand Down
62 changes: 37 additions & 25 deletions spec/install/gemfile/sources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end
end

context "with multiple toplevel sources" do
context "with multiple toplevel sources", :bundler => "< 2" do
let(:repo3_rack_version) { "1.0.0" }

before do
Expand All @@ -27,12 +27,17 @@
G
end

it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first", :bundler => "< 2" do
xit "shows a deprecation" do
bundle :install

expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(out).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo1}"))
expect(err).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
end

it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first" do
bundle :install

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

Expand All @@ -44,7 +49,7 @@
end
end

context "when different versions of the same gem are in multiple sources" do
context "when different versions of the same gem are in multiple sources", :bundler => "< 2" do
let(:repo3_rack_version) { "1.2" }

before do
Expand All @@ -54,14 +59,17 @@
gem "rack-obama"
gem "rack", "1.0.0" # force it to install the working version in repo1
G
end

it "warns about ambiguous gems, but installs anyway", :bundler => "< 2" do
bundle :install
end

xit "shows a deprecation" do
expect(err).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
end

expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(out).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo1}"))
it "warns about ambiguous gems, but installs anyway" 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
end
Expand Down Expand Up @@ -235,7 +243,7 @@
end
end

context "and in yet another source" do
context "and in yet another source", :bundler => "< 2" do
before do
gemfile <<-G
source "file://localhost#{gem_repo1}"
Expand All @@ -244,18 +252,22 @@
gem "depends_on_rack"
end
G
end

it "installs from the other source and warns about ambiguous gems", :bundler => "< 2" do
bundle :install
expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(out).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo2}"))
end

xit "shows a deprecation" do
expect(err).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
end

it "installs from the other source and warns about ambiguous gems" 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
end

context "and only the dependency is pinned" do
context "and only the dependency is pinned", :bundler => "< 2" do
before do
# need this to be broken to check for correct source ordering
build_repo gem_repo2 do
Expand All @@ -273,18 +285,18 @@
G
end

it "installs the dependency from the pinned source without warning", :bundler => "< 2" do
it "installs the dependency from the pinned source without warning" do
bundle :install

expect(out).not_to include("Warning: the gem 'rack' was found in multiple sources.")
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")

# In https://github.com/bundler/bundler/issues/3585 this failed
# when there is already a lock file, and the gems are missing, so try again
system_gems []
bundle :install

expect(out).not_to include("Warning: the gem 'rack' was found in multiple sources.")
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
end
Expand Down Expand Up @@ -329,7 +341,7 @@

it "installs all gems without warning" do
bundle :install
expect(out).not_to include("Warning")
expect(err).not_to include("Warning")
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0")
end
end
Expand Down Expand Up @@ -364,7 +376,7 @@

it "installs the dependency from the top-level source without warning" do
bundle :install
expect(out).not_to include("Warning")
expect(err).not_to include("Warning")
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0")
end
end
Expand Down Expand Up @@ -453,7 +465,7 @@

it "installs the gems without any warning" do
bundle :install
expect(out).not_to include("Warning")
expect(err).not_to include("Warning")
expect(the_bundle).to include_gems("rack 1.0.0")
end
end
Expand Down Expand Up @@ -631,7 +643,7 @@
gem "depends_on_rack"
G
expect(last_command).to be_failure
expect(last_command.stderr).to eq normalize_uri_file(strip_whitespace(<<-EOS).strip)
expect(err).to eq normalize_uri_file(strip_whitespace(<<-EOS).strip)
The gem 'rack' was found in multiple relevant sources.
* rubygems repository file://localhost#{gem_repo1}/ or installed locally
* rubygems repository file://localhost#{gem_repo4}/ or installed locally
Expand Down
45 changes: 29 additions & 16 deletions spec/other/major_deprecation_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# frozen_string_literal: true

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 >= .*/, "") }
RSpec.describe "major deprecations" do
let(:warnings) { err }

before do
create_file "gems.rb", <<-G
Expand Down Expand Up @@ -35,29 +34,33 @@
describe "bundle update --quiet" do
it "does not print any deprecations" do
bundle :update, :quiet => true
expect(warnings_without_version_messages).not_to have_major_deprecation
expect(warnings).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
it "does not warn when no options are given", :bundler => "< 2" do
bundle! "update"
expect(warnings).not_to have_major_deprecation
end

it "warns when no options are given", :bundler => "2" 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
expect(warnings).not_to have_major_deprecation
end
end

describe "bundle install --binstubs" do
it "should output a deprecation warning" do
xit "should output a deprecation warning" do
gemfile <<-G
gem 'rack'
G
Expand All @@ -76,10 +79,10 @@
G

bundle :install
expect(warnings_without_version_messages).not_to have_major_deprecation
expect(warnings).not_to have_major_deprecation
end

it "should print a Gemfile deprecation warning" do
xit "should print a Gemfile deprecation warning" do
create_file "gems.rb"
install_gemfile! <<-G
source "file://#{gem_repo1}"
Expand All @@ -91,7 +94,7 @@
end

context "with flags" do
it "should print a deprecation warning about autoremembering flags" do
xit "should print a deprecation warning about autoremembering flags" do
install_gemfile <<-G, :path => "vendor/bundle"
source "file://#{gem_repo1}"
gem "rack"
Expand Down Expand Up @@ -122,7 +125,7 @@
Bundler.setup
RUBY

expect(warnings_without_version_messages).to have_major_deprecation("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.")
expect(warnings).to have_major_deprecation("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.")
end
end

Expand All @@ -139,7 +142,7 @@
end
end

describe Bundler::Dsl do
xdescribe Bundler::Dsl do
before do
@rubygems = double("rubygems")
allow(Bundler::Source::Rubygems).to receive(:new) { @rubygems }
Expand Down Expand Up @@ -205,24 +208,34 @@
end

context "bundle show" do
it "prints a deprecation warning" do
before do
install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
G

bundle! :show
end

warnings.gsub!(/gems included.*?\[DEPRECATED/im, "[DEPRECATED")
it "does not print a deprecation warning", :bundler => "< 2" do
expect(warnings).not_to have_major_deprecation
end

it "prints a deprecation warning", :bundler => "2" do
expect(warnings).to have_major_deprecation a_string_including("use `bundle list` instead of `bundle show`")
end
end

context "bundle console" do
it "prints a deprecation warning" do
before do
bundle "console"
end

it "does not print a deprecation warning", :bundler => "< 2" do
expect(warnings).not_to have_major_deprecation
end

it "prints a deprecation warning", :bundler => "2" do
expect(warnings).to have_major_deprecation \
a_string_including("bundle console will be replaced by `bin/console` generated by `bundle gem <name>`")
end
Expand Down
3 changes: 1 addition & 2 deletions spec/support/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ def self.define_compound_matcher(matcher, preconditions, &declarations)
match do |actual|
deprecations = actual.split(MAJOR_DEPRECATION)

return !expected.nil? if deprecations.size <= 1
return true if expected.nil?
return !expected.nil? if deprecations.empty?

deprecations.any? do |d|
!d.empty? && values_match?(expected, d.strip)
Expand Down