Add additional specs for PATH.

This commit is contained in:
Markus Reiter 2018-04-14 06:46:01 +02:00
parent 0432feabd3
commit 9f1b64a9d4
2 changed files with 14 additions and 1 deletions

View File

@ -32,7 +32,7 @@ class PATH
end
def to_ary
@paths
@paths.dup.to_ary
end
alias to_a to_ary

View File

@ -23,6 +23,13 @@ describe PATH do
it "returns a PATH array" do
expect(described_class.new("/path1", "/path2").to_ary).to eq(["/path1", "/path2"])
end
it "does not allow mutating the original" do
path = described_class.new("/path1", "/path2")
path.to_ary << "/path3"
expect(path).not_to include("/path3")
end
end
describe "#to_str" do
@ -61,6 +68,12 @@ describe PATH do
end
end
describe "#==" do
it "always returns false when comparing against something which does not respons to `#to_ary` or `#to_str`" do
expect(described_class.new).not_to eq Object.new
end
end
describe "#include?" do
it "returns true if a path is included" do
path = described_class.new("/path1", "/path2")