From 1be5eeec26000b881c2ec8ff53333266eedd9fff Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 30 Apr 2017 21:23:12 +0200 Subject: Add test and comment for `PATH#existing`. --- Library/Homebrew/PATH.rb | 1 + Library/Homebrew/test/PATH_spec.rb | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/PATH.rb b/Library/Homebrew/PATH.rb index f1c0ebb5d..de7167eb4 100644 --- a/Library/Homebrew/PATH.rb +++ b/Library/Homebrew/PATH.rb @@ -59,6 +59,7 @@ class PATH def existing existing_path = select(&File.method(:directory?)) + # return nil instead of empty PATH, to unset environment variables existing_path unless existing_path.empty? end diff --git a/Library/Homebrew/test/PATH_spec.rb b/Library/Homebrew/test/PATH_spec.rb index b20a3d3ac..68233c23c 100644 --- a/Library/Homebrew/test/PATH_spec.rb +++ b/Library/Homebrew/test/PATH_spec.rb @@ -107,5 +107,9 @@ describe PATH do expect(path.existing.to_ary).to eq(["/path1"]) expect(path.to_ary).to eq(["/path1", "/path2"]) end + + it "returns nil instead of an empty #{described_class}" do + expect(described_class.new.existing).to be nil + end end end -- cgit v1.2.3