summaryrefslogtreecommitdiff
path: root/test/fileutils/fileasserts.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-07 01:23:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-07 01:23:07 +0000
commit298258891d2f8a80f8d1eac193c6609a256a3cf0 (patch)
tree0c7bac8b88d9d2b57e3aa9635f6839a8e97b1b35 /test/fileutils/fileasserts.rb
parentb5ba059a0b21ba6a198d8dca864045c37ce3babb (diff)
use assert_equal, assert_match, and so on.
* test/fileutils/fileasserts.rb: use assert_equal, assert_match, and so on. * test/ruby/enc/test_utf16.rb, test/ruby/enc/test_utf32.rb, test/ruby/test_io_m17n.rb (assert_str_equal): ditto. * test/rubygems/test_gem_remote_fetcher.rb (assert_data_from_{server,proxy}): ditto. * test/test_pstore.rb (test_thread_safe): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/fileutils/fileasserts.rb')
-rw-r--r--test/fileutils/fileasserts.rb79
1 files changed, 23 insertions, 56 deletions
diff --git a/test/fileutils/fileasserts.rb b/test/fileutils/fileasserts.rb
index e8c5fa4369..0aa139fe16 100644
--- a/test/fileutils/fileasserts.rb
+++ b/test/fileutils/fileasserts.rb
@@ -3,17 +3,8 @@
module Test
module Unit
module FileAssertions
-
- def _wrap_assertion
- yield
- end
-
def assert_same_file(from, to, message=nil)
- _wrap_assertion {
- assert_block("file #{from} != #{to}#{message&&': '}#{message||''}") {
- File.read(from) == File.read(to)
- }
- }
+ assert_equal(File.read(from), File.read(to), "file #{from} != #{to}#{message&&': '}#{message||''}")
end
def assert_same_entry(from, to, message=nil)
@@ -28,76 +19,52 @@ module Test
end
def assert_file_exist(path, message=nil)
- _wrap_assertion {
- assert_block("file not exist: #{path}#{message&&': '}#{message||''}") {
- File.exist?(path)
- }
- }
+ assert(File.exist?(path), "file not exist: #{path}#{message&&': '}#{message||''}")
end
def assert_file_not_exist(path, message=nil)
- _wrap_assertion {
- assert_block("file not exist: #{path}#{message&&': '}#{message||''}") {
- not File.exist?(path)
- }
- }
+ assert(!File.exist?(path), "file exist: #{path}#{message&&': '}#{message||''}")
end
def assert_directory(path, message=nil)
- _wrap_assertion {
- assert_block("is not directory: #{path}#{message&&': '}#{message||''}") {
- File.directory?(path)
- }
- }
+ assert(File.directory?(path), "is not directory: #{path}#{message&&': '}#{message||''}")
end
def assert_symlink(path, message=nil)
- _wrap_assertion {
- assert_block("is not a symlink: #{path}#{message&&': '}#{message||''}") {
- File.symlink?(path)
- }
- }
+ assert(File.symlink?(path), "is not a symlink: #{path}#{message&&': '}#{message||''}")
end
def assert_not_symlink(path)
- _wrap_assertion {
- assert_block("is a symlink: #{path}#{message&&': '}#{message||''}") {
- not File.symlink?(path)
- }
- }
+ assert(!File.symlink?(path), "is a symlink: #{path}#{message&&': '}#{message||''}")
end
def assert_equal_time(expected, actual, message=nil)
- _wrap_assertion {
- expected_str = expected.to_s
- actual_str = actual.to_s
- if expected_str == actual_str
- expected_str << " (nsec=#{expected.nsec})"
- actual_str << " (nsec=#{actual.nsec})"
- end
- full_message = build_message(message, <<EOT)
+ expected_str = expected.to_s
+ actual_str = actual.to_s
+ if expected_str == actual_str
+ expected_str << " (nsec=#{expected.nsec})"
+ actual_str << " (nsec=#{actual.nsec})"
+ end
+ full_message = build_message(message, <<EOT)
<#{expected_str}> expected but was
<#{actual_str}>.
EOT
- assert_block(full_message) { expected == actual }
- }
+ assert_equal(expected, actual, full_message)
end
def assert_equal_timestamp(expected, actual, message=nil)
- _wrap_assertion {
- expected_str = expected.to_s
- actual_str = actual.to_s
- if expected_str == actual_str
- expected_str << " (nsec=#{expected.nsec})"
- actual_str << " (nsec=#{actual.nsec})"
- end
- full_message = build_message(message, <<EOT)
+ expected_str = expected.to_s
+ actual_str = actual.to_s
+ if expected_str == actual_str
+ expected_str << " (nsec=#{expected.nsec})"
+ actual_str << " (nsec=#{actual.nsec})"
+ end
+ full_message = build_message(message, <<EOT)
<#{expected_str}> expected but was
<#{actual_str}>.
EOT
- # subsecond timestamp is not portable.
- assert_block(full_message) { expected.tv_sec == actual.tv_sec }
- }
+ # subsecond timestamp is not portable.
+ assert_equal(expected.tv_sec, actual.tv_sec, full_message)
end
end