Project

General

Profile

tempfile-create-basename.patch

ksss (Yuki Kurihara), 01/07/2016 04:57 AM

Download (942 Bytes)

View differences:

lib/tempfile.rb
323 323
#      ... do something with f ...
324 324
#   end
325 325
#
326
def Tempfile.create(basename, tmpdir=nil, mode: 0, **options)
326
def Tempfile.create(basename="", tmpdir=nil, mode: 0, **options)
327 327
  tmpfile = nil
328 328
  Dir::Tmpname.create(basename, tmpdir, options) do |tmpname, n, opts|
329 329
    mode |= File::RDWR|File::CREAT|File::EXCL
test/test_tempfile.rb
325 325
    end
326 326
  end
327 327

  
328
  def test_create_default_basename
329
    path = nil
330
    Tempfile.create {|f|
331
      path = f.path
332
      assert(File.exist?(path))
333
    }
334
    assert(!File.exist?(path))
335
  end
336

  
328 337
  def test_create_with_block
329 338
    path = nil
330 339
    Tempfile.create("tempfile-create") {|f|