summaryrefslogtreecommitdiff
path: root/test/fileutils
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-09 07:02:04 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-09 07:02:04 +0000
commita6e3d4bea0c6625c76669d7246868f7683dd23a6 (patch)
tree00b53f19b8d92785357f697f0a7d534d00324149 /test/fileutils
parentf5a6a2a7e05b314ae9c6425c6dafd893e50005d9 (diff)
* lib/fileutils.rb (FileUtils#mode_to_s): Define mode_to_s() also
as singleton method, or FileUtils.chmod fails in verbose mode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/fileutils')
-rw-r--r--test/fileutils/test_fileutils.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb
index abcecb9..1c24a92 100644
--- a/test/fileutils/test_fileutils.rb
+++ b/test/fileutils/test_fileutils.rb
@@ -1024,7 +1024,6 @@ class TestFileUtils
def test_chmod_verbose
check_singleton :chmod
- r, w = IO.pipe
stderr_back = $stderr
read, $stderr = IO.pipe
th = Thread.new { read.read }
@@ -1042,6 +1041,23 @@ class TestFileUtils
$stderr = stderr_back if stderr_back
end if have_file_perm?
+ def test_s_chmod_verbose
+ output_back = FileUtils.instance_variable_get(:@fileutils_output)
+ read, write = IO.pipe
+ FileUtils.instance_variable_set(:@fileutils_output, write)
+ th = Thread.new { read.read }
+
+ touch 'tmp/a'
+ FileUtils.chmod 0700, 'tmp/a', verbose: true
+ assert_equal 0700, File.stat('tmp/a').mode & 0777
+
+ write.close
+ lines = th.value.lines.map {|l| l.chomp }
+ assert_equal(["chmod 700 tmp/a"], lines)
+ ensure
+ FileUtils.instance_variable_set(:@fileutils_output, output_back) if output_back
+ end if have_file_perm?
+
# FIXME: How can I test this method?
def test_chown
check_singleton :chown