From ab53367bc7aec0ba935a62dc745f1f2e001f8a08 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 4 Feb 2011 18:35:07 +0000 Subject: * test/fileutils/fileasserts.rb: add message arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/fileutils/fileasserts.rb | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'test/fileutils') diff --git a/test/fileutils/fileasserts.rb b/test/fileutils/fileasserts.rb index 579fefd15e..3ecd6a5259 100644 --- a/test/fileutils/fileasserts.rb +++ b/test/fileutils/fileasserts.rb @@ -12,51 +12,52 @@ module Test assert yield, msg end - def assert_same_file(from, to) + def assert_same_file(from, to, message=nil) _wrap_assertion { - assert_block("file #{from} != #{to}") { + assert_block("file #{from} != #{to}#{message&&': '}#{message||''}") { File.read(from) == File.read(to) } } end - def assert_same_entry(from, to) + def assert_same_entry(from, to, message=nil) a = File.stat(from) b = File.stat(to) - assert_equal a.mode, b.mode, "mode #{a.mode} != #{b.mode}" + msg = "#{message&&': '}#{message||''}" + assert_equal a.mode, b.mode, "mode #{a.mode} != #{b.mode}#{msg}" #assert_equal a.atime, b.atime - assert_equal_timestamp a.mtime, b.mtime, "mtime #{a.mtime} != #{b.mtime}" - assert_equal a.uid, b.uid, "uid #{a.uid} != #{b.uid}" - assert_equal a.gid, b.gid, "gid #{a.gid} != #{b.gid}" + assert_equal_timestamp a.mtime, b.mtime, "mtime #{a.mtime} != #{b.mtime}#{msg}" + assert_equal a.uid, b.uid, "uid #{a.uid} != #{b.uid}#{msg}" + assert_equal a.gid, b.gid, "gid #{a.gid} != #{b.gid}#{msg}" end - def assert_file_exist(path) + def assert_file_exist(path, message=nil) _wrap_assertion { - assert_block("file not exist: #{path}") { + assert_block("file not exist: #{path}#{message&&': '}#{message||''}") { File.exist?(path) } } end - def assert_file_not_exist(path) + def assert_file_not_exist(path, message=nil) _wrap_assertion { - assert_block("file not exist: #{path}") { + assert_block("file not exist: #{path}#{message&&': '}#{message||''}") { not File.exist?(path) } } end - def assert_directory(path) + def assert_directory(path, message=nil) _wrap_assertion { - assert_block("is not directory: #{path}") { + assert_block("is not directory: #{path}#{message&&': '}#{message||''}") { File.directory?(path) } } end - def assert_symlink(path) + def assert_symlink(path, message=nil) _wrap_assertion { - assert_block("is not a symlink: #{path}") { + assert_block("is not a symlink: #{path}#{message&&': '}#{message||''}") { File.symlink?(path) } } @@ -64,7 +65,7 @@ module Test def assert_not_symlink(path) _wrap_assertion { - assert_block("is a symlink: #{path}") { + assert_block("is a symlink: #{path}#{message&&': '}#{message||''}") { not File.symlink?(path) } } -- cgit v1.2.3