diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | test/fileutils/fileasserts.rb | 33 |
2 files changed, 20 insertions, 17 deletions
@@ -1,4 +1,6 @@ -Sat Feb 5 03:34:02 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> +Sat Feb 5 03:34:59 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * test/fileutils/fileasserts.rb: add message arguments. * test/fileutils/fileasserts.rb (Test::Unit::Assertions#assert_block): show the given message. 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) } } |