Skip to content

Commit

Permalink
Adapt File class methods to use Path implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Mar 3, 2019
1 parent b0157fd commit 66c2ab3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 162 deletions.
18 changes: 9 additions & 9 deletions spec/std/file_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -564,17 +564,17 @@ describe "File" do
File.expand_path("../bin", "x/../tmp").should eq(File.join([base, "bin"]))
end

pending_win32 "expand_path for commoms unix path give a full path" do
File.expand_path("/tmp/").should eq("/tmp")
it "expand_path for commoms unix path give a full path" do
File.expand_path("/tmp/").should eq("/tmp/")
File.expand_path("/tmp/../../../tmp").should eq("/tmp")
File.expand_path("").should eq(base)
File.expand_path("./////").should eq(base)
File.expand_path("./////").should eq(File.join(base, ""))
File.expand_path(".").should eq(base)
File.expand_path(base).should eq(base)
end

pending_win32 "converts a pathname to an absolute pathname, using ~ (home) as base" do
File.expand_path("~/").should eq(home)
it "converts a pathname to an absolute pathname, using ~ (home) as base" do
File.expand_path("~/").should eq(File.join(home, ""))
File.expand_path("~/..badfilename").should eq(File.join(home, "..badfilename"))
File.expand_path("..").should eq("/#{base.split('/')[0...-1].join('/')}".gsub(%r{\A//}, "/"))
File.expand_path("~/a", "~/b").should eq(File.join(home, "a"))
Expand All @@ -583,11 +583,11 @@ describe "File" do
File.expand_path("~/a", "/tmp/gumby/ddd").should eq(File.join([home, "a"]))
end

pending_win32 "converts a pathname to an absolute pathname, using ~ (home) as base (trailing /)" do
it "converts a pathname to an absolute pathname, using ~ (home) as base (trailing /)" do
prev_home = home
begin
ENV["HOME"] = File.expand_path(datapath)
File.expand_path("~/").should eq(home)
File.expand_path("~/").should eq(File.join(home, ""))
File.expand_path("~/..badfilename").should eq(File.join(home, "..badfilename"))
File.expand_path("..").should eq("/#{base.split('/')[0...-1].join('/')}".gsub(%r{\A//}, "/"))
File.expand_path("~/a", "~/b").should eq(File.join(home, "a"))
Expand All @@ -599,13 +599,13 @@ describe "File" do
end
end

pending_win32 "converts a pathname to an absolute pathname, using ~ (home) as base (HOME=/)" do
it "converts a pathname to an absolute pathname, using ~ (home) as base (HOME=/)" do
prev_home = home
begin
ENV["HOME"] = "/"
File.expand_path("~/").should eq(home)
File.expand_path("~/..badfilename").should eq(File.join(home, "..badfilename"))
File.expand_path("..").should eq("/#{base.split('/')[0...-1].join('/')}".gsub(%r{\A//}, "/"))
File.expand_path("..").should eq("/#{base.split('/')[0...-1].join('/')}".gsub(/\A\/\//, "/"))
File.expand_path("~/a", "~/b").should eq(File.join(home, "a"))
File.expand_path("~").should eq(home)
File.expand_path("~", "/tmp/gumby/ddd").should eq(home)
Expand Down
Loading

0 comments on commit 66c2ab3

Please sign in to comment.