summaryrefslogtreecommitdiff
path: root/test/test_tempfile.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_tempfile.rb')
-rw-r--r--test/test_tempfile.rb27
1 files changed, 25 insertions, 2 deletions
diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb
index 6b087f9207..eddbac5d75 100644
--- a/test/test_tempfile.rb
+++ b/test/test_tempfile.rb
@@ -63,6 +63,22 @@ class TestTempfile < Test::Unit::TestCase
assert_match(/\.txt$/, File.basename(t.path))
end
+ def test_dup
+ t = tempfile
+ t2 = t.dup
+ t2.close
+ assert_equal true, t2.closed?
+ assert_equal false, t.closed?
+ end
+
+ def test_clone
+ t = tempfile
+ t2 = t.clone
+ t2.close
+ assert_equal true, t2.closed?
+ assert_equal false, t.closed?
+ end
+
def test_unlink
t = tempfile("foo")
path = t.path
@@ -209,8 +225,7 @@ puts Tempfile.new('foo').path
def test_tempfile_finalizer_does_not_run_if_unlinked
bug8768 = '[ruby-core:56521] [Bug #8768]'
- args = %w(--disable-gems -rtempfile)
- assert_in_out_err(args, <<-'EOS') do |(filename), (error)|
+ assert_in_out_err(%w(-rtempfile), <<-'EOS') do |(filename), (error)|
tmp = Tempfile.new('foo')
puts tmp.path
tmp.close
@@ -363,6 +378,14 @@ puts Tempfile.new('foo').path
assert_file.not_exist?(path)
end
+ def test_open
+ Tempfile.open {|f|
+ file = f.open
+ assert_kind_of File, file
+ assert_equal f.to_i, file.to_i
+ }
+ end
+
def test_open_traversal_dir
assert_mktmpdir_traversal do |traversal_path|
t = Tempfile.open([traversal_path, 'foo'])