diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-15 13:14:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-15 13:14:48 +0000 |
commit | 32569104e121e6dc7363acf37b5aef766bd04d4d (patch) | |
tree | 19750e8770748ef40b914b199f66e2397deb8d81 /test/ruby/envutil.rb | |
parent | a17cb167ea5e0f0690a94d8f39b821a43aebd456 (diff) | |
download | ruby-32569104e121e6dc7363acf37b5aef766bd04d4d.tar.gz |
envutil.rb: file_assertion
* test/ruby/envutil.rb (Test::Unit::Assertions#file_assertion):
rewrite file assertions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/envutil.rb')
-rw-r--r-- | test/ruby/envutil.rb | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index b170c46c83..d6f46f4401 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -225,12 +225,25 @@ module Test assert(1.0/f == -Float::INFINITY, "#{f} is not -0.0") end - def assert_file(predicate, path) - assert(File.__send__(predicate, path), "Expected file #{path.inspect} to be #{predicate}") + def file_assertion + FileAssertion end - def assert_file_not(predicate, path) - assert(!File.__send__(predicate, path), "Expected file #{path.inspect} not to be #{predicate}") + class << (FileAssertion = Object.new) + include Assertions + def assert_file_predicate(predicate, *args) + if /\Anot_/ =~ predicate + predicate = $' + neg = " not" + end + result = File.__send__(predicate, *args) + result = !result if neg + mesg = "Expected file " << args.shift.inspect + mesg << mu_pp(args) unless args.empty? + mesg << "#{neg} to be #{predicate}" + assert(result, mesg) + end + alias method_missing assert_file_predicate end end end |