diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-09 14:18:05 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-09 14:18:05 +0000 |
commit | 428ec4ec05c0f5a0c24dacee406854fff623dca4 (patch) | |
tree | 302eabe363f9211c5ba809c9132700b6eba8ceef /test/ruby/test_file_exhaustive.rb | |
parent | e3efce6df1aa691e17c59f442b35b4fd129d3a13 (diff) | |
download | ruby-428ec4ec05c0f5a0c24dacee406854fff623dca4.tar.gz |
envutil.rb: assert_file and assert_file_not
* test/ruby/envutil.rb (assert_file, assert_file_not): more
descriptive assertions for File predicates.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_file_exhaustive.rb')
-rw-r--r-- | test/ruby/test_file_exhaustive.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 14e7f5a1b6..76cf615d5b 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -1,6 +1,7 @@ require "test/unit" require "fileutils" require "tmpdir" +require_relative "envutil" class TestFileExhaustive < Test::Unit::TestCase DRIVE = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i] @@ -119,7 +120,7 @@ class TestFileExhaustive < Test::Unit::TestCase Dir.mktmpdir do |dir| prefix = File.join(dir, "...a") Dir.mkdir(prefix) - assert File.exist?(prefix) + assert_file(:exist?, prefix) assert_nothing_raised { File.stat(prefix) } @@ -169,9 +170,9 @@ class TestFileExhaustive < Test::Unit::TestCase end def test_exist_p - assert(File.exist?(@dir)) - assert(File.exist?(@file)) - assert(!(File.exist?(@nofile))) + assert_file(:exist?, @dir) + assert_file(:exist?, @file) + assert_file_not(:exist?, @nofile) end def test_readable_p @@ -398,8 +399,8 @@ class TestFileExhaustive < Test::Unit::TestCase def test_rename assert_equal(0, File.rename(@file, @nofile)) - assert(!(File.exist?(@file))) - assert(File.exist?(@nofile)) + assert_file_not(:exist?, @file) + assert_file(:exist?, @nofile) assert_equal(0, File.rename(@nofile, @file)) assert_raise(Errno::ENOENT) { File.rename(@nofile, @file) } end @@ -786,21 +787,21 @@ class TestFileExhaustive < Test::Unit::TestCase def test_truncate assert_equal(0, File.truncate(@file, 1)) - assert(File.exist?(@file)) + assert_file(:exist?, @file) assert_equal(1, File.size(@file)) assert_equal(0, File.truncate(@file, 0)) - assert(File.exist?(@file)) - assert(File.zero?(@file)) + assert_file(:exist?, @file) + assert_file(:zero?, @file) make_file("foo", @file) assert_raise(Errno::ENOENT) { File.truncate(@nofile, 0) } f = File.new(@file, "w") assert_equal(0, f.truncate(2)) - assert(File.exist?(@file)) + assert_file(:exist?, @file) assert_equal(2, File.size(@file)) assert_equal(0, f.truncate(0)) - assert(File.exist?(@file)) - assert(File.zero?(@file)) + assert_file(:exist?, @file) + assert_file(:zero?, @file) f.close make_file("foo", @file) |