diff options
-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)) |