diff --git a/lib/tempfile.rb b/lib/tempfile.rb index 13d9585..6280a53 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -323,7 +323,7 @@ def open(*args) # ... do something with f ... # end # -def Tempfile.create(basename, tmpdir=nil, mode: 0, **options) +def Tempfile.create(basename="", tmpdir=nil, mode: 0, **options) tmpfile = nil Dir::Tmpname.create(basename, tmpdir, options) do |tmpname, n, opts| mode |= File::RDWR|File::CREAT|File::EXCL diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index c8af2f5..42d8331 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -325,6 +325,15 @@ def test_binmode end end + def test_create_default_basename + path = nil + Tempfile.create {|f| + path = f.path + assert(File.exist?(path)) + } + assert(!File.exist?(path)) + end + def test_create_with_block path = nil Tempfile.create("tempfile-create") {|f|