From 7812732e2c271732b96e285584ba84eb236c647a Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 23 Aug 2024 14:58:47 +0900 Subject: [PATCH] [ruby/tempfile] File.new(fileno, mode: mode, path: path) is provided from Ruby 3.2 https://github.com/ruby/tempfile/commit/67ce897727 --- lib/tempfile.rb | 2 +- test/test_tempfile.rb | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/tempfile.rb b/lib/tempfile.rb index 40221d4f7c..bb05080cec 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -556,7 +556,7 @@ end # Related: Tempfile.new. # def Tempfile.create(basename="", tmpdir=nil, mode: 0, anonymous: false, **options, &block) - if anonymous + if anonymous && RUBY_VERSION >= '3.2' create_anonymous(basename, tmpdir, mode: mode, **options, &block) else create_with_filename(basename, tmpdir, mode: mode, **options, &block) diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index 8077cc3603..931b512ee0 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -488,7 +488,11 @@ puts Tempfile.new('foo').path Dir.mktmpdir {|d| t = Tempfile.create("", d, anonymous: true) t.close - assert_equal([], Dir.children(d)) + if RUBY_VERSION >= '3.2' + assert_equal([], Dir.children(d)) + else + refute_equal([], Dir.children(d)) + end } end @@ -496,7 +500,11 @@ puts Tempfile.new('foo').path Dir.mktmpdir {|d| begin t = Tempfile.create("", d, anonymous: true) - assert_equal(File.join(d, ""), t.path) + if RUBY_VERSION >= '3.2' + assert_equal(File.join(d, ""), t.path) + else + refute_equal(File.join(d, ""), t.path) + end ensure t.close if t end