mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/fileutils/fileasserts.rb: add message arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f38aad8d87
commit
ab53367bc7
2 changed files with 20 additions and 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.
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue