ruby-changes:18759
From: nobu <ko1@a...>
Date: Sat, 5 Feb 2011 03:35:14 +0900 (JST)
Subject: [ruby-changes:18759] Ruby:r30786 (trunk): * test/fileutils/fileasserts.rb: add message arguments.
nobu 2011-02-05 03:35:07 +0900 (Sat, 05 Feb 2011) New Revision: 30786 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30786 Log: * test/fileutils/fileasserts.rb: add message arguments. Modified files: trunk/ChangeLog trunk/test/fileutils/fileasserts.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 30785) +++ ChangeLog (revision 30786) @@ -1,5 +1,7 @@ -Sat Feb 5 03:34:02 2011 Nobuyoshi Nakada <nobu@r...> +Sat Feb 5 03:34:59 2011 Nobuyoshi Nakada <nobu@r...> + * test/fileutils/fileasserts.rb: add message arguments. + * test/fileutils/fileasserts.rb (Test::Unit::Assertions#assert_block): show the given message. Index: test/fileutils/fileasserts.rb =================================================================== --- test/fileutils/fileasserts.rb (revision 30785) +++ test/fileutils/fileasserts.rb (revision 30786) @@ -12,51 +12,52 @@ 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 @@ 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) } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/