Skip to content

Commit

Permalink
Implement Bundler::SourceList#implicit_global_source?
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
daniel-niknam authored and deivid-rodriguez committed Jul 26, 2021
1 parent 47e3ff0 commit 422fec4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bundler/lib/bundler/source_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def aggregate_global_source?
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
Expand Down
15 changes: 15 additions & 0 deletions bundler/spec/bundler/source_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,4 +441,19 @@
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

0 comments on commit 422fec4

Please sign in to comment.