summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-04 00:18:38 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-04 00:18:38 +0000
commit05c108cdba62545bb50616726f0b7261cb89ad4e (patch)
treefe832bc92dc43fa5422937f165d9632f5a977a9a
parentb85a4eea558368f68070c69b6ee482a77266ad96 (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--ChangeLog6
-rw-r--r--lib/tempfile.rb2
-rw-r--r--test/test_tempfile.rb5
3 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b895dc..a02b4f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Jan 4 09:18:31 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
+
+ * 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 <ayumu.aizawa@gmail.com>
* README.ja.md: add guidance of mailing list and bugs.r-l.o.
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 6444151..4715173 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 2fe62d3..6bba134 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))