From 4c54fc8719cb66db3a1314c7f6620e01dfd3462f Mon Sep 17 00:00:00 2001 From: John Keiser Date: Fri, 29 Aug 2014 12:30:29 -0700 Subject: Make join work properly with leading slashes --- spec/unit/util/path_helper_spec.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'spec/unit/util') diff --git a/spec/unit/util/path_helper_spec.rb b/spec/unit/util/path_helper_spec.rb index eb89aa083a..57774c5b53 100644 --- a/spec/unit/util/path_helper_spec.rb +++ b/spec/unit/util/path_helper_spec.rb @@ -35,6 +35,12 @@ describe Chef::Util::PathHelper do PathHelper.join(is_windows ? 'C:\\foo\\' : "/foo/", "bar", "baz").should == expected end + it "joins components when some end and start with separators" do + expected = PathHelper.cleanpath("/foo/bar/baz") + expected = "C:#{expected}" if is_windows + PathHelper.join(is_windows ? 'C:\\foo\\' : "/foo/", "bar/", "/baz").should == expected + end + it "joins components that don't end in separators" do expected = PathHelper.cleanpath("/foo/bar/baz") expected = "C:#{expected}" if is_windows @@ -51,8 +57,7 @@ describe Chef::Util::PathHelper do if is_windows it "joins components on Windows when some end with unix separators" do - expected = 'C:\\foo/bar\\baz' - PathHelper.join('C:\\foo/', "bar", "baz").should == expected + PathHelper.join('C:\\foo/', "bar", "baz").should == 'C:\\foo\\bar\\baz' end end end -- cgit v1.2.1