summaryrefslogtreecommitdiff
path: root/spec/ruby/core/dir/home_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/dir/home_spec.rb')
-rw-r--r--spec/ruby/core/dir/home_spec.rb31
1 files changed, 14 insertions, 17 deletions
diff --git a/spec/ruby/core/dir/home_spec.rb b/spec/ruby/core/dir/home_spec.rb
index bbe347ba9e..f0b20e0687 100644
--- a/spec/ruby/core/dir/home_spec.rb
+++ b/spec/ruby/core/dir/home_spec.rb
@@ -33,13 +33,11 @@ describe "Dir.home" do
end
platform_is :windows do
- ruby_version_is "3.2" do
- it "returns the home directory with forward slashs and as UTF-8" do
- ENV['HOME'] = "C:\\rubyspäc\\home"
- home = Dir.home
- home.should == "C:/rubyspäc/home"
- home.encoding.should == Encoding::UTF_8
- end
+ it "returns the home directory with forward slashs and as UTF-8" do
+ ENV['HOME'] = "C:\\rubyspäc\\home"
+ home = Dir.home
+ home.should == "C:/rubyspäc/home"
+ home.encoding.should == Encoding::UTF_8
end
it "retrieves the directory from HOME, USERPROFILE, HOMEDRIVE/HOMEPATH and the WinAPI in that order" do
@@ -50,8 +48,7 @@ describe "Dir.home" do
ENV['HOMEPATH'] = "\\rubyspec\\home1"
Dir.home.should == "C:/rubyspec/home1"
ENV['USERPROFILE'] = "C:\\rubyspec\\home2"
- # https://bugs.ruby-lang.org/issues/19244
- # Dir.home.should == "C:/rubyspec/home2"
+ Dir.home.should == "C:/rubyspec/home2"
ENV['HOME'] = "C:\\rubyspec\\home3"
Dir.home.should == "C:/rubyspec/home3"
ensure
@@ -61,13 +58,7 @@ describe "Dir.home" do
end
describe "when called with the current user name" do
- platform_is :solaris do
- it "returns the named user's home directory from the user database" do
- Dir.home(ENV['USER']).should == `getent passwd #{ENV['USER']}|cut -d: -f6`.chomp
- end
- end
-
- platform_is_not :windows, :solaris, :android, :wasi do
+ platform_is_not :windows, :android, :wasi do
it "returns the named user's home directory, from the user database" do
Dir.home(ENV['USER']).should == `echo ~#{ENV['USER']}`.chomp
end
@@ -83,6 +74,12 @@ describe "Dir.home" do
end
it "raises an ArgumentError if the named user doesn't exist" do
- -> { Dir.home('geuw2n288dh2k') }.should raise_error(ArgumentError)
+ -> { Dir.home('geuw2n288dh2k') }.should.raise(ArgumentError)
+ end
+
+ describe "when called with a nil user name" do
+ it "returns the current user's home directory, reading $HOME first" do
+ Dir.home(nil).should == "/rubyspec_home"
+ end
end
end