diff options
Diffstat (limited to 'test/test_tempfile.rb')
-rw-r--r-- | test/test_tempfile.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index 21edf39776..eba139fe25 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -352,5 +352,31 @@ puts Tempfile.new('foo').path f.close if f && !f.closed? File.unlink path if 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 |