diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-04 18:35:07 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-04 18:35:07 +0000 |
commit | ab53367bc7aec0ba935a62dc745f1f2e001f8a08 (patch) | |
tree | 4ee28b6d6d912902df5cc242fd4a28dd06d35635 /test | |
parent | f38aad8d878e5fbf760bf6ec71825a41d24e082e (diff) | |
download | ruby-ab53367bc7aec0ba935a62dc745f1f2e001f8a08.tar.gz |
* test/fileutils/fileasserts.rb: add message arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/fileutils/fileasserts.rb | 33 |
1 files changed, 17 insertions, 16 deletions
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) } } |