aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/PATH_spec.rb
diff options
context:
space:
mode:
authorMarkus Reiter2017-04-28 12:39:00 +0200
committerMarkus Reiter2017-04-30 21:11:28 +0200
commit22f624b373d77ede5c15db6f62672bdd81e6c9da (patch)
tree2e74f0456b0d8e9707b19c545735208f939c00fe /Library/Homebrew/test/PATH_spec.rb
parente70f2ec33233422b70db047338aa85d9e2088042 (diff)
downloadbrew-22f624b373d77ede5c15db6f62672bdd81e6c9da.tar.bz2
Make `PATH` enumerable.
Diffstat (limited to 'Library/Homebrew/test/PATH_spec.rb')
-rw-r--r--Library/Homebrew/test/PATH_spec.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/Library/Homebrew/test/PATH_spec.rb b/Library/Homebrew/test/PATH_spec.rb
index 7e42670f2..07caae617 100644
--- a/Library/Homebrew/test/PATH_spec.rb
+++ b/Library/Homebrew/test/PATH_spec.rb
@@ -51,6 +51,41 @@ describe PATH do
end
end
+ describe "#insert" do
+ it "inserts a path at a given index" do
+ expect(described_class.new("/path1").insert(0, "/path2").to_str).to eq("/path2:/path1")
+ end
+
+ it "can insert multiple paths" do
+ expect(described_class.new("/path1").insert(0, "/path2", "/path3")).to eq("/path2:/path3:/path1")
+ end
+ end
+
+ describe "#include?" do
+ it "returns true if a path is included" do
+ path = described_class.new("/path1", "/path2")
+ expect(path).to include("/path1")
+ expect(path).to include("/path2")
+ end
+
+ it "returns false if a path is not included" do
+ expect(described_class.new("/path1")).not_to include("/path2")
+ end
+
+ it "returns false if the given string contains a separator" do
+ expect(described_class.new("/path1", "/path2")).not_to include("/path1:")
+ end
+ end
+
+ describe "#each" do
+ it "loops through each path" do
+ enum = described_class.new("/path1", "/path2").each
+
+ expect(enum.next).to eq("/path1")
+ expect(enum.next).to eq("/path2")
+ end
+ end
+
describe "#validate" do
it "returns a new PATH without non-existent paths" do
allow(File).to receive(:directory?).with("/path1").and_return(true)