diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 7990acc5d8..84953726ff 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -486,6 +486,8 @@ class Tap def self.each return unless TAP_DIRECTORY.directory? + return to_enum unless block_given? + TAP_DIRECTORY.subdirs.each do |user| user.subdirs.each do |repo| yield fetch(user.basename.to_s, repo.basename.to_s) diff --git a/Library/Homebrew/test/tap_spec.rb b/Library/Homebrew/test/tap_spec.rb index 0eb4ca1bee..957f9bdd26 100644 --- a/Library/Homebrew/test/tap_spec.rb +++ b/Library/Homebrew/test/tap_spec.rb @@ -297,6 +297,12 @@ describe Tap do subject.config["foo"] = nil expect(subject.config["foo"]).to be nil end + + describe "#each" do + it "returns an enumerator if no block is passed" do + expect(described_class.each).to be_an_instance_of(Enumerator) + end + end end describe CoreTap do