Add test and comment for PATH#existing.

This commit is contained in:
Markus Reiter 2017-04-30 21:23:12 +02:00
parent 1c7238e59b
commit 1be5eeec26
2 changed files with 5 additions and 0 deletions

View File

@ -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

View File

@ -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