Try to more accurately reflect MRI's logic in specs for finding the home if $HOME is unset

This commit is contained in:
Benoit Daloze 2019-04-27 19:42:54 +02:00
Родитель 5b93321064
Коммит 0d227d1ce6
1 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -223,7 +223,16 @@ platform_is_not :windows do
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