Feature #11965 ยป tempfile-create-basename.patch
lib/tempfile.rb | ||
---|---|---|
# ... 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
|
test/test_tempfile.rb | ||
---|---|---|
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|
|