[ruby/tmpdir] Fix for path-like objects
Fix https://github.com/ruby/tmpdir/pull/37 https://github.com/ruby/tmpdir/commit/a8ceafae7d
This commit is contained in:
parent
eef4e8a2c8
commit
bf0f323907
@ -149,8 +149,8 @@ class Dir
|
||||
|
||||
# Generates and yields random names to create a temporary name
|
||||
def create(basename, tmpdir=nil, max_try: nil, **opts)
|
||||
origdir = tmpdir
|
||||
if tmpdir
|
||||
origdir = tmpdir = File.path(tmpdir)
|
||||
raise ArgumentError, "empty parent path" if tmpdir.empty?
|
||||
else
|
||||
tmpdir = tmpdir()
|
||||
|
@ -108,6 +108,16 @@ class TestTmpdir < Test::Unit::TestCase
|
||||
assert_raise(ArgumentError) do
|
||||
Dir.mktmpdir("foo", "")
|
||||
end
|
||||
|
||||
path = Struct.new(:to_path).new("")
|
||||
assert_raise(ArgumentError) do
|
||||
Dir.mktmpdir("foo", path)
|
||||
end
|
||||
|
||||
Dir.mktmpdir do |d|
|
||||
path = Struct.new(:to_path).new(d)
|
||||
assert_operator(Dir.mktmpdir("prefix-", path), :start_with?, d + "/prefix-")
|
||||
end
|
||||
end
|
||||
|
||||
def assert_mktmpdir_traversal
|
||||
|
Loading…
x
Reference in New Issue
Block a user