summaryrefslogtreecommitdiff
path: root/test/pathname
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-21 11:33:09 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-08-31 11:53:41 +0900
commit2dd26bed86f721ed1982d00c3a0bd5ed37568e96 (patch)
tree643dc7e2689fba87ce97536d0d0f85606c3f82ea /test/pathname
parent181207e830cc8fb0fac78e9bcd4163c25831c600 (diff)
[Feature #16972] Add mode: option to Pathname#mkpath
Diffstat (limited to 'test/pathname')
-rw-r--r--test/pathname/test_pathname.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index 8a0f3cbb66..a83eb1ffcf 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -1429,10 +1429,22 @@ class TestPathname < Test::Unit::TestCase
}
end
+ def assert_mode(val, mask, path, mesg = nil)
+ st = File.stat(path)
+ assert_equal(val.to_s(8), (st.mode & mask).to_s(8), st.inspect)
+ end
+
def test_mkpath
with_tmpchdir('rubytest-pathname') {|dir|
Pathname("a/b/c/d").mkpath
assert_file.directory?("a/b/c/d")
+ unless File.stat(dir).world_readable?
+ # mktmpdir should make unreadable
+ Pathname("x/y/z").mkpath(mode: 0775)
+ assert_mode(0775, 0777, "x")
+ assert_mode(0775, 0777, "x/y")
+ assert_mode(0775, 0777, "x/y/z")
+ end
}
end