summaryrefslogtreecommitdiff
path: root/spec/ruby/core/file/expand_path_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/file/expand_path_spec.rb')
-rw-r--r--spec/ruby/core/file/expand_path_spec.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/spec/ruby/core/file/expand_path_spec.rb b/spec/ruby/core/file/expand_path_spec.rb
index c2899fe1ac..5bb60d2c23 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
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