diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-04 00:18:38 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-04 00:18:38 +0000 |
commit | 05c108cdba62545bb50616726f0b7261cb89ad4e (patch) | |
tree | fe832bc92dc43fa5422937f165d9632f5a977a9a | |
parent | b85a4eea558368f68070c69b6ee482a77266ad96 (diff) |
* lib/tempfile.rb: provide default basename parameter.
[fix GH-523] Patch by @dissolved
* test/test_tempfile.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/tempfile.rb | 2 | ||||
-rw-r--r-- | test/test_tempfile.rb | 5 |
3 files changed, 12 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Sun Jan 4 09:18:31 2015 SHIBATA Hiroshi <[email protected]> + + * lib/tempfile.rb: provide default basename parameter. + [fix GH-523] Patch by @dissolved + * test/test_tempfile.rb: ditto. + Sun Jan 4 00:43:41 2015 Ayumu AIZAWA <[email protected]> * README.ja.md: add guidance of mailing list and bugs.r-l.o. diff --git a/lib/tempfile.rb b/lib/tempfile.rb index 64441511fe..47151732c3 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -122,7 +122,7 @@ class Tempfile < DelegateClass(File) # # If Tempfile.new cannot find a unique filename within a limited # number of tries, then it will raise an exception. - def initialize(basename, tmpdir=nil, mode: 0, **options) + def initialize(basename="", tmpdir=nil, mode: 0, **options) if block_given? warn "Tempfile.new doesn't call the given block." end diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index 2fe62d37c5..6bba13473c 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -57,6 +57,11 @@ class TestTempfile < Test::Unit::TestCase assert_match(/^foo/, File.basename(t.path)) end + def test_default_basename + t = tempfile + assert File.exist?(t.path) + end + def test_basename_with_suffix t = tempfile(["foo", ".txt"]) assert_match(/^foo/, File.basename(t.path)) |