Skip to content

Commit

Permalink
Try to more accurately reflect MRI's logic in specs for finding the h…
Browse files Browse the repository at this point in the history
…ome if $HOME is unset
  • Loading branch information
eregon committed Apr 27, 2019
1 parent 5b93321 commit 0d227d1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion spec/ruby/core/file/expand_path_spec.rb
Expand Up @@ -223,7 +223,16 @@
ENV["HOME"] = @home
end

guard -> { Etc.getlogin } do
guard -> {
# We need to check if getlogin(3) returns non-NULL,
# as MRI only checks getlogin(3) for expanding '~' if $HOME is not set.
user = ENV.delete("USER")
begin
Etc.getlogin != nil
ensure
ENV["USER"] = user
end
} do
it "uses the user database when passed '~' if HOME is nil" do
ENV.delete "HOME"
File.directory?(File.expand_path("~")).should == true
Expand Down

0 comments on commit 0d227d1

Please sign in to comment.