Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/tmpdir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def next

# 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()
Expand Down
10 changes: 10 additions & 0 deletions test/test_tmpdir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ def test_mktmpdir_not_empty_parent
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
Expand Down
Loading