aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/dir
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2022-12-18 21:05:22 +0100
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-12-24 22:54:23 +0900
commitd6ce4180a5b4dacbac895c9911031a6df6c61136 (patch)
tree5fcea95c22a419d1e9286d83daccecb87cb043e6 /spec/ruby/core/dir
parent18c1ca8f4c0748905d5cedb6c044df507ea8ad6a (diff)
downloadruby-d6ce4180a5b4dacbac895c9911031a6df6c61136.tar.gz
Windows: Fix encoding of Dir.home
Dir.home returns an UTF-8 string since ruby-3.0, but the actual encoding of the bytes was CP_ACP or CP_OEMCP. That led to invalid bytes when calling Dir.home with an unicode username.
Diffstat (limited to 'spec/ruby/core/dir')
-rw-r--r--spec/ruby/core/dir/home_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/ruby/core/dir/home_spec.rb b/spec/ruby/core/dir/home_spec.rb
index 8377f1dc97..c49a18041b 100644
--- a/spec/ruby/core/dir/home_spec.rb
+++ b/spec/ruby/core/dir/home_spec.rb
@@ -19,6 +19,17 @@ describe "Dir.home" do
it "returns a non-frozen string" do
Dir.home.should_not.frozen?
end
+
+ platform_is :windows do
+ ruby_version_is "3.0" 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
+ end
+ end
end
describe "when called with the current user name" do