From 5388fb64d991db9c094d1972176c4f5794e3555f Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 20 Apr 2013 13:50:47 +0000 Subject: * lib/tempfile.rb (Tempfile.create): New method. The method name is proposed by Shugo Maeda. [ruby-dev:47220] [ruby-core:41478] [Feature #5707] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/test_tempfile.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/test_tempfile.rb') diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index 1462a981f7..4f7e26f606 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -304,5 +304,26 @@ puts Tempfile.new('foo').path assert_equal(0600, t.stat.mode & 0777) end end + + def test_create_with_block + path = nil + Tempfile.create("tempfile-create") {|f| + path = f.path + assert(File.exist?(path)) + } + assert(!File.exist?(path)) + end + + def test_create_without_block + path = nil + f = Tempfile.create("tempfile-create") + path = f.path + assert(File.exist?(path)) + f.close + assert(File.exist?(path)) + ensure + f.close if f && !f.closed? + File.unlink path if path + end end -- cgit v1.2.3