From 91a3f06e98682078493a9501bdbd1302673ad96b Mon Sep 17 00:00:00 2001 From: Daniel Niknam Date: Sat, 24 Jul 2021 17:21:42 +1000 Subject: [PATCH] [rubygems/rubygems] Implement Bundler::Source::Rubygems#no_remotes? This method is created to tell whether any remote exist in the object or not and it will be used by `Bundler:SourceList` to tell if a global source has been defined implicitly or not. https://github.com/rubygems/rubygems/commit/47e3ff0e47 --- lib/bundler/source/rubygems.rb | 4 ++++ spec/bundler/bundler/source/rubygems_spec.rb | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 43b193cf1c..858a69a48b 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -71,6 +71,10 @@ module Bundler @remotes.size > 1 end + def no_remotes? + @remotes.size == 0 + end + def can_lock?(spec) return super unless multiple_remotes? include?(spec.source) diff --git a/spec/bundler/bundler/source/rubygems_spec.rb b/spec/bundler/bundler/source/rubygems_spec.rb index 7c457a7265..884fa81046 100644 --- a/spec/bundler/bundler/source/rubygems_spec.rb +++ b/spec/bundler/bundler/source/rubygems_spec.rb @@ -30,4 +30,18 @@ RSpec.describe Bundler::Source::Rubygems do end end end + + describe "#no_remotes?" do + context "when no remote provided" do + it "returns a truthy value" do + expect(described_class.new("remotes" => []).no_remotes?).to be_truthy + end + end + + context "when a remote provided" do + it "returns a falsey value" do + expect(described_class.new("remotes" => ["https://rubygems.org"]).no_remotes?).to be_falsey + end + end + end end