Add additional specs for PATH.
This commit is contained in:
parent
0432feabd3
commit
9f1b64a9d4
@ -32,7 +32,7 @@ class PATH
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_ary
|
def to_ary
|
||||||
@paths
|
@paths.dup.to_ary
|
||||||
end
|
end
|
||||||
alias to_a to_ary
|
alias to_a to_ary
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,13 @@ describe PATH do
|
|||||||
it "returns a PATH array" do
|
it "returns a PATH array" do
|
||||||
expect(described_class.new("/path1", "/path2").to_ary).to eq(["/path1", "/path2"])
|
expect(described_class.new("/path1", "/path2").to_ary).to eq(["/path1", "/path2"])
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "#to_str" do
|
describe "#to_str" do
|
||||||
@ -61,6 +68,12 @@ describe PATH do
|
|||||||
end
|
end
|
||||||
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
|
describe "#include?" do
|
||||||
it "returns true if a path is included" do
|
it "returns true if a path is included" do
|
||||||
path = described_class.new("/path1", "/path2")
|
path = described_class.new("/path1", "/path2")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user