ruby-changes:55567
From: Benoit <ko1@a...>
Date: Sun, 28 Apr 2019 02:44:05 +0900 (JST)
Subject: [ruby-changes:55567] Benoit Daloze:0d227d1ce6 (trunk): Try to more accurately reflect MRI's logic in specs for finding the home if $HOME is unset
https://git.ruby-lang.org/ruby.git/commit/?id=0d227d1ce6 From 0d227d1ce6aa01b0f6db06bbbf828acb962d4734 Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Sat, 27 Apr 2019 19:42:54 +0200 Subject: Try to more accurately reflect MRI's logic in specs for finding the home if $HOME is unset diff --git a/spec/ruby/core/file/expand_path_spec.rb b/spec/ruby/core/file/expand_path_spec.rb index c2899fe..5bb60d2 100644 --- a/spec/ruby/core/file/expand_path_spec.rb +++ b/spec/ruby/core/file/expand_path_spec.rb @@ -223,7 +223,16 @@ platform_is_not :windows do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/file/expand_path_spec.rb#L223 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/