implement Pathname#join() interface for Filepath.

This commit is contained in:
Charles Lowell 2011-10-01 16:58:29 -05:00
parent a8b638daf2
commit 40b754190e
2 changed files with 10 additions and 0 deletions

View File

@ -16,6 +16,10 @@ module Jenkins
FilePath.new(@native.child(name))
end
def join(*names)
FilePath.new names.inject(@native) {|native, name| native.child(name) }
end
def to_s
@native.getRemote()
end

View File

@ -17,6 +17,12 @@ describe Jenkins::FilePath do
(create(".") + "foo" + "bar").to_s.should == "foo/bar"
end
it "returns child for join" do
create('.').join('foo').to_s.should == "foo"
create('.').join('foo', 'bar').to_s.should == "foo/bar"
create('.').join('foo', 'bar', 'baz').to_s.should == "foo/bar/baz"
end
it "returns path for to_s" do
create(".").to_s.should == "."
end