aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/envutil.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/envutil.rb')
-rw-r--r--test/ruby/envutil.rb21
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