diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-20 13:50:47 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-20 13:50:47 +0000 |
commit | 5388fb64d991db9c094d1972176c4f5794e3555f (patch) | |
tree | 0726bc8b3386a51d3043d5f75d7a9ce33566f5d7 /test/test_tempfile.rb | |
parent | 8c77e58b97465ebfef0d94497a5eecd78f5bef3c (diff) | |
download | ruby-5388fb64d991db9c094d1972176c4f5794e3555f.tar.gz |
* 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
Diffstat (limited to 'test/test_tempfile.rb')
-rw-r--r-- | test/test_tempfile.rb | 21 |
1 files changed, 21 insertions, 0 deletions
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 |