From b500e8fab445d5a4ad91fd71e622aff88d0c7dd6 Mon Sep 17 00:00:00 2001 From: Daniel Niknam Date: Sat, 24 Jul 2021 17:25:08 +1000 Subject: [PATCH] [rubygems/rubygems] Implement Bundler::SourceList#implicit_global_source? This method is created to tell whether any global source exist in the object or not and it will be used by `Bundler:Dsl` to print a warning if no global source has been defined in the Gemfile. https://github.com/rubygems/rubygems/commit/422fec4438 --- lib/bundler/source_list.rb | 4 ++++ spec/bundler/bundler/source_list_spec.rb | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb index 113d49ba72..c7dfa3d797 100644 --- a/lib/bundler/source_list.rb +++ b/lib/bundler/source_list.rb @@ -37,6 +37,10 @@ module Bundler global_rubygems_source.multiple_remotes? end + def implicit_global_source? + global_rubygems_source.no_remotes? + end + def add_path_source(options = {}) if options["gemspec"] add_source_to_list Source::Gemspec.new(options), path_sources diff --git a/spec/bundler/bundler/source_list_spec.rb b/spec/bundler/bundler/source_list_spec.rb index c2d1978b29..f860e9ff58 100644 --- a/spec/bundler/bundler/source_list_spec.rb +++ b/spec/bundler/bundler/source_list_spec.rb @@ -441,4 +441,19 @@ RSpec.describe Bundler::SourceList do source_list.remote! end end + + describe "implicit_global_source?" do + context "when a global rubygem source provided" do + it "returns a falsy value" do + source_list.add_global_rubygems_remote("https://rubygems.org") + + expect(source_list.implicit_global_source?).to be_falsey + end + end + context "when no global rubygem source provided" do + it "returns a truthy value" do + expect(source_list.implicit_global_source?).to be_truthy + end + end + end end