summaryrefslogtreecommitdiff
path: root/test/test_tempfile.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-28 09:26:00 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-28 09:26:00 +0000
commitad7392754b256400cfde1d9026816444b78d5e27 (patch)
tree4d9aefcfa4844cabec5db1c3dd85934469719160 /test/test_tempfile.rb
parent2d414cb1acb6166643aa7b756ad8e525ef25ddd1 (diff)
Remove directory separators
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@62971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_tempfile.rb')
-rw-r--r--test/test_tempfile.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb
index 465ce42e36..6b7860fe20 100644
--- a/test/test_tempfile.rb
+++ b/test/test_tempfile.rb
@@ -371,5 +371,31 @@ puts Tempfile.new('foo').path
}
assert_file.not_exist?(path)
end
-end
+ TRAVERSAL_PATH = Array.new(Dir.pwd.split('/').count, '..').join('/') + Dir.pwd + '/'
+
+ def test_open_traversal_dir
+ expect = Dir.glob(TRAVERSAL_PATH + '*').count
+ t = Tempfile.open([TRAVERSAL_PATH, 'foo'])
+ actual = Dir.glob(TRAVERSAL_PATH + '*').count
+ assert_equal expect, actual
+ ensure
+ t.close!
+ end
+
+ def test_new_traversal_dir
+ expect = Dir.glob(TRAVERSAL_PATH + '*').count
+ t = Tempfile.new(TRAVERSAL_PATH + 'foo')
+ actual = Dir.glob(TRAVERSAL_PATH + '*').count
+ assert_equal expect, actual
+ ensure
+ t.close!
+ end
+
+ def test_create_traversal_dir
+ expect = Dir.glob(TRAVERSAL_PATH + '*').count
+ Tempfile.create(TRAVERSAL_PATH + 'foo')
+ actual = Dir.glob(TRAVERSAL_PATH + '*').count
+ assert_equal expect, actual
+ end
+end