Class: ZipFsFileNonmutatingTest
- Inherits:
-
MiniTest::Test
- Object
- MiniTest::Test
- ZipFsFileNonmutatingTest
- Includes:
- ExtraAssertions
- Defined in:
- lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb
Instance Method Summary collapse
- #assert_always_false(operation) ⇒ Object
- #assert_e_n_o_e_n_t(operation, args = ["NoSuchFile"]) ⇒ Object
- #assert_true_if_entry_exists(operation) ⇒ Object
- #setup ⇒ Object
- #teardown ⇒ Object
- #test_atime ⇒ Object
- #test_basename ⇒ Object
- #test_blockdev? ⇒ Boolean
- #test_chardev? ⇒ Boolean
- #test_chown ⇒ Object
- #test_ctime ⇒ Object
- #test_directory? ⇒ Boolean
- #test_dirname ⇒ Object
- #test_executable? ⇒ Boolean
- #test_executable_real? ⇒ Boolean
- #test_exists? ⇒ Boolean
- #test_expand_path ⇒ Object
- #test_file? ⇒ Boolean
- #test_foreach ⇒ Object
- #test_ftype ⇒ Object
- #test_glob ⇒ Object
- #test_grpowned? ⇒ Boolean
- #test_join ⇒ Object
- #test_link ⇒ Object
- #test_lstat ⇒ Object
- #test_mtime ⇒ Object
- #test_new ⇒ Object
- #test_ntfs_time ⇒ Object
- #test_open_read ⇒ Object
- #test_owned? ⇒ Boolean
- #test_pipe ⇒ Object
- #test_pipe? ⇒ Boolean
- #test_popen ⇒ Object
- #test_read ⇒ Object
- #test_readable? ⇒ Boolean
- #test_readable_real? ⇒ Boolean
-
#test_readlines ⇒ Object
Can be added later def test_select fail “implement test” end.
- #test_readlink ⇒ Object
- #test_setgid? ⇒ Boolean
- #test_setuid? ⇒ Boolean
- #test_size ⇒ Object
- #test_size? ⇒ Boolean
- #test_socket? ⇒ Boolean
- #test_split ⇒ Object
- #test_stat ⇒ Object
- #test_sticky? ⇒ Boolean
- #test_symlink ⇒ Object
- #test_symlink? ⇒ Boolean
- #test_truncate ⇒ Object
- #test_umask ⇒ Object
- #test_utime ⇒ Object
- #test_writable? ⇒ Boolean
- #test_writable_real? ⇒ Boolean
- #test_zero? ⇒ Boolean
Methods included from ExtraAssertions
Instance Method Details
#assert_always_false(operation) ⇒ Object
167 168 169 170 171 172 173 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 167 def assert_always_false(operation) assert(! @zip_file.file.send(operation, "noSuchFile")) assert(! @zip_file.file.send(operation, "file1")) assert(! @zip_file.file.send(operation, "dir1")) assert(! @zip_file.file.stat("file1").send(operation)) assert(! @zip_file.file.stat("dir1").send(operation)) end |
#assert_e_n_o_e_n_t(operation, args = ["NoSuchFile"]) ⇒ Object
209 210 211 212 213 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 209 def assert_e_n_o_e_n_t(operation, args = ["NoSuchFile"]) assert_raises(Errno::ENOENT) { @zip_file.file.send(operation, *args) } end |
#assert_true_if_entry_exists(operation) ⇒ Object
175 176 177 178 179 180 181 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 175 def assert_true_if_entry_exists(operation) assert(! @zip_file.file.send(operation, "noSuchFile")) assert(@zip_file.file.send(operation, "file1")) assert(@zip_file.file.send(operation, "dir1")) assert(@zip_file.file.stat("file1").send(operation)) assert(@zip_file.file.stat("dir1").send(operation)) end |
#setup ⇒ Object
5 6 7 8 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 5 def setup @zipsha = Digest::SHA1.file("test/data/zipWithDirs.zip") @zip_file = ::Zip::File.new("test/data/zipWithDirs.zip") end |
#teardown ⇒ Object
10 11 12 13 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 10 def teardown @zip_file.close if @zip_file assert_equal(@zipsha, Digest::SHA1.file("test/data/zipWithDirs.zip")) end |
#test_atime ⇒ Object
305 306 307 308 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 305 def test_atime assert_nil(@zip_file.file.atime("file1")) assert_nil(@zip_file.file.stat("file1").atime) end |
#test_basename ⇒ Object
138 139 140 141 142 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 138 def test_basename assert_forwarded(File, :basename, "retVal", "a/b/c/d") { @zip_file.file.basename("a/b/c/d") } end |
#test_blockdev? ⇒ Boolean
187 188 189 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 187 def test_blockdev? assert_always_false(:blockdev?) end |
#test_chardev? ⇒ Boolean
199 200 201 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 199 def test_chardev? assert_always_false(:chardev?) end |
#test_chown ⇒ Object
243 244 245 246 247 248 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 243 def test_chown assert_equal(2, @zip_file.file.chown(1,2, "dir1", "file1")) assert_equal(1, @zip_file.file.stat("dir1").uid) assert_equal(2, @zip_file.file.stat("dir1").gid) assert_equal(2, @zip_file.file.chown(nil, nil, "dir1", "file1")) end |
#test_ctime ⇒ Object
300 301 302 303 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 300 def test_ctime assert_nil(@zip_file.file.ctime("file1")) assert_nil(@zip_file.file.stat("file1").ctime) end |
#test_directory? ⇒ Boolean
228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 228 def test_directory? assert(! @zip_file.file.directory?("notAFile")) assert(! @zip_file.file.directory?("file1")) assert(! @zip_file.file.directory?("dir1/file11")) assert(@zip_file.file.directory?("dir1")) assert(@zip_file.file.directory?("dir1/")) assert(@zip_file.file.directory?("dir2/dir21")) assert(! @zip_file.file.stat("file1").directory?) assert(! @zip_file.file.stat("dir1/file11").directory?) assert(@zip_file.file.stat("dir1").directory?) assert(@zip_file.file.stat("dir1/").directory?) assert(@zip_file.file.stat("dir2/dir21").directory?) end |
#test_dirname ⇒ Object
132 133 134 135 136 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 132 def test_dirname assert_forwarded(File, :dirname, "retVal", "a/b/c/d") { @zip_file.file.dirname("a/b/c/d") } end |
#test_executable? ⇒ Boolean
351 352 353 354 355 356 357 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 351 def test_executable? assert(! @zip_file.file.executable?("noSuchFile")) assert(! @zip_file.file.executable?("file1")) assert(@zip_file.file.executable?("dir1")) assert(! @zip_file.file.stat("file1").executable?) assert(@zip_file.file.stat("dir1").executable?) end |
#test_executable_real? ⇒ Boolean
359 360 361 362 363 364 365 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 359 def test_executable_real? assert(! @zip_file.file.executable_real?("noSuchFile")) assert(! @zip_file.file.executable_real?("file1")) assert(@zip_file.file.executable_real?("dir1")) assert(! @zip_file.file.stat("file1").executable_real?) assert(@zip_file.file.stat("dir1").executable_real?) end |
#test_exists? ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 20 def test_exists? assert(! @zip_file.file.exists?("notAFile")) assert(@zip_file.file.exists?("file1")) assert(@zip_file.file.exists?("dir1")) assert(@zip_file.file.exists?("dir1/")) assert(@zip_file.file.exists?("dir1/file12")) assert(@zip_file.file.exist?("dir1/file12")) # notice, tests exist? alias of exists? ! @zip_file.dir.chdir "dir1/" assert(!@zip_file.file.exists?("file1")) assert(@zip_file.file.exists?("file12")) end |
#test_expand_path ⇒ Object
273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 273 def ::Zip::File.open("test/data/zipWithDirs.zip") { |zf| assert_equal("/", zf.file.(".")) zf.dir.chdir "dir1" assert_equal("/dir1", zf.file.(".")) assert_equal("/dir1/file12", zf.file.("file12")) assert_equal("/", zf.file.("..")) assert_equal("/dir2/dir21", zf.file.("../dir2/dir21")) } end |
#test_file? ⇒ Boolean
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 118 def test_file? assert(@zip_file.file.file?("file1")) assert(@zip_file.file.file?("dir2/file21")) assert(! @zip_file.file.file?("dir1")) assert(! @zip_file.file.file?("dir1/dir11")) assert(@zip_file.file.stat("file1").file?) assert(@zip_file.file.stat("dir2/file21").file?) assert(! @zip_file.file.stat("dir1").file?) assert(! @zip_file.file.stat("dir1/dir11").file?) end |
#test_foreach ⇒ Object
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 411 def test_foreach ::Zip::File.open("test/data/generated/zipWithDir.zip") do |zf| ref = [] File.foreach("test/data/file1.txt") { |e| ref << e } index = 0 zf.file.foreach("test/data/file1.txt") do |l| #Ruby replaces \n with \r\n automatically on windows newline = Zip::RUNNING_ON_WINDOWS ? l.gsub(/\r\n/, "\n") : l assert_equal(ref[index], newline) index = index.next end assert_equal(ref.size, index) end ::Zip::File.open("test/data/generated/zipWithDir.zip") do |zf| ref = [] File.foreach("test/data/file1.txt", " ") { |e| ref << e } index = 0 zf.file.foreach("test/data/file1.txt", " ") do |l| #Ruby replaces \n with \r\n automatically on windows newline = Zip::RUNNING_ON_WINDOWS ? l.gsub(/\r\n/, "\n") : l assert_equal(ref[index], newline) index = index.next end assert_equal(ref.size, index) end end |
#test_ftype ⇒ Object
215 216 217 218 219 220 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 215 def test_ftype assert_e_n_o_e_n_t(:ftype) assert_equal("file", @zip_file.file.ftype("file1")) assert_equal("directory", @zip_file.file.ftype("dir1/dir11")) assert_equal("directory", @zip_file.file.ftype("dir1/dir11/")) end |
#test_glob ⇒ Object
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 441 def test_glob ::Zip::File.open('test/data/globTest.zip') do |zf| { 'globTest/foo.txt' => ['globTest/foo.txt'], '*/foo.txt' => ['globTest/foo.txt'], '**/foo.txt' => ['globTest/foo.txt','globTest/foo/bar/baz/foo.txt'], '*/foo/**/*.txt' => ['globTest/foo/bar/baz/foo.txt'] }.each do |spec,expected_results| results = zf.glob(spec) assert results.all?{|entry| entry.is_a? ::Zip::Entry } result_strings = results.map(&:to_s) missing_matches = expected_results - result_strings extra_matches = result_strings - expected_results assert extra_matches.empty?, %Q{spec #{spec.inspect} has extra results #{extra_matches.inspect}} assert missing_matches.empty?, %Q{spec #{spec.inspect} missing results #{missing_matches.inspect}} end end ::Zip::File.open('test/data/globTest.zip') do |zf| results = [] zf.glob('**/foo.txt') do |match| results << "<#{match.class.name}: #{match.to_s}>" end assert((not results.empty?), 'block not run, or run out of context') assert_equal 2, results.size assert_operator results, :include?, '<Zip::Entry: globTest/foo.txt>' assert_operator results, :include?, '<Zip::Entry: globTest/foo/bar/baz/foo.txt>' end end |
#test_grpowned? ⇒ Boolean
371 372 373 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 371 def test_grpowned? assert_true_if_entry_exists(:grpowned?) end |
#test_join ⇒ Object
150 151 152 153 154 155 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 150 def test_join assert_equal("a/b/c", @zip_file.file.join("a/b", "c")) assert_equal("a/b/c/d", @zip_file.file.join("a/b", "c/d")) assert_equal("/c/d", @zip_file.file.join("", "c/d")) assert_equal("a/b/c/d", @zip_file.file.join("a", "b", "c", "d")) end |
#test_link ⇒ Object
222 223 224 225 226 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 222 def test_link assert_raises(NotImplementedError) { @zip_file.file.link("file1", "someOtherString") } end |
#test_lstat ⇒ Object
401 402 403 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 401 def test_lstat assert(@zip_file.file.lstat("file1").file?) end |
#test_mtime ⇒ Object
285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 285 def test_mtime assert_equal(::Zip::DOSTime.at(1027694306), @zip_file.file.mtime("dir2/file21")) assert_equal(::Zip::DOSTime.at(1027690863), @zip_file.file.mtime("dir2/dir21")) assert_raises(Errno::ENOENT) { @zip_file.file.mtime("noSuchEntry") } assert_equal(::Zip::DOSTime.at(1027694306), @zip_file.file.stat("dir2/file21").mtime) assert_equal(::Zip::DOSTime.at(1027690863), @zip_file.file.stat("dir2/dir21").mtime) end |
#test_new ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 76 def test_new begin is = @zip_file.file.new("file1") assert_equal("this is the entry 'file1' in my test archive!", is.readline.chomp) ensure is.close if is end begin is = @zip_file.file.new("file1") { fail "should not call block" } ensure is.close if is end end |
#test_ntfs_time ⇒ Object
310 311 312 313 314 315 316 317 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 310 def test_ntfs_time ::Zip::File.open("test/data/ntfs.zip") do |zf| t = ::Zip::DOSTime.at(1410496497.405178) assert_equal(zf.file.mtime("data.txt"), t) assert_equal(zf.file.atime("data.txt"), t) assert_equal(zf.file.ctime("data.txt"), t) end end |
#test_open_read ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 33 def test_open_read blockCalled = false @zip_file.file.open("file1", "r") { |f| blockCalled = true assert_equal("this is the entry 'file1' in my test archive!", f.readline.chomp) } assert(blockCalled) blockCalled = false @zip_file.file.open("file1", "rb") { # test binary flag is ignored |f| blockCalled = true assert_equal("this is the entry 'file1' in my test archive!", f.readline.chomp) } assert(blockCalled) blockCalled = false @zip_file.dir.chdir "dir2" @zip_file.file.open("file21", "r") { |f| blockCalled = true assert_equal("this is the entry 'dir2/file21' in my test archive!", f.readline.chomp) } assert(blockCalled) @zip_file.dir.chdir "/" assert_raises(Errno::ENOENT) { @zip_file.file.open("noSuchEntry") } begin is = @zip_file.file.open("file1") assert_equal("this is the entry 'file1' in my test archive!", is.readline.chomp) ensure is.close if is end end |
#test_owned? ⇒ Boolean
367 368 369 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 367 def test_owned? assert_true_if_entry_exists(:owned?) end |
#test_pipe ⇒ Object
405 406 407 408 409 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 405 def test_pipe assert_raises(NotImplementedError) { @zip_file.file.pipe } end |
#test_pipe? ⇒ Boolean
183 184 185 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 183 def test_pipe? assert_always_false(:pipe?) end |
#test_popen ⇒ Object
473 474 475 476 477 478 479 480 481 482 483 484 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 473 def test_popen if Zip::RUNNING_ON_WINDOWS #This is pretty much projectile vomit but it allows the test to be #run on windows also system_dir = ::File.popen('dir') { |f| f.read }.gsub(/Dir\(s\).*$/, '') zipfile_dir = @zip_file.file.popen('dir') { |f| f.read }.gsub(/Dir\(s\).*$/, '') assert_equal(system_dir, zipfile_dir) else assert_equal(::File.popen('ls') { |f| f.read }, @zip_file.file.popen('ls') { |f| f.read }) end end |
#test_read ⇒ Object
503 504 505 506 507 508 509 510 511 512 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 503 def test_read ::Zip::File.open("test/data/generated/zipWithDir.zip") do |zf| orig_file = ::File.read("test/data/file1.txt") #Ruby replaces \n with \r\n automatically on windows zip_file = Zip::RUNNING_ON_WINDOWS ? \ zf.file.read("test/data/file1.txt").gsub(/\r\n/, "\n") : zf.file.read("test/data/file1.txt") assert_equal(orig_file, zip_file) end end |
#test_readable? ⇒ Boolean
319 320 321 322 323 324 325 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 319 def test_readable? assert(! @zip_file.file.readable?("noSuchFile")) assert(@zip_file.file.readable?("file1")) assert(@zip_file.file.readable?("dir1")) assert(@zip_file.file.stat("file1").readable?) assert(@zip_file.file.stat("dir1").readable?) end |
#test_readable_real? ⇒ Boolean
327 328 329 330 331 332 333 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 327 def test_readable_real? assert(! @zip_file.file.readable_real?("noSuchFile")) assert(@zip_file.file.readable_real?("file1")) assert(@zip_file.file.readable_real?("dir1")) assert(@zip_file.file.stat("file1").readable_real?) assert(@zip_file.file.stat("dir1").readable_real?) end |
#test_readlines ⇒ Object
Can be added later
def test_select
fail "implement test"
end
491 492 493 494 495 496 497 498 499 500 501 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 491 def test_readlines ::Zip::File.open("test/data/generated/zipWithDir.zip") do |zf| orig_file = ::File.readlines("test/data/file1.txt") zip_file = zf.file.readlines("test/data/file1.txt") #Ruby replaces \n with \r\n automatically on windows zip_file.each { |l| l.gsub!(/\r\n/, "\n") } if Zip::RUNNING_ON_WINDOWS assert_equal(orig_file, zip_file) end end |
#test_readlink ⇒ Object
387 388 389 390 391 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 387 def test_readlink assert_raises(NotImplementedError) { @zip_file.file.readlink("someString") } end |
#test_setgid? ⇒ Boolean
375 376 377 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 375 def test_setgid? assert_always_false(:setgid?) end |
#test_setuid? ⇒ Boolean
379 380 381 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 379 def test_setuid? assert_always_false(:setgid?) end |
#test_size ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 99 def test_size assert_raises(Errno::ENOENT) { @zip_file.file.size("notAFile") } assert_equal(72, @zip_file.file.size("file1")) assert_equal(0, @zip_file.file.size("dir2/dir21")) assert_equal(72, @zip_file.file.stat("file1").size) assert_equal(0, @zip_file.file.stat("dir2/dir21").size) end |
#test_size? ⇒ Boolean
108 109 110 111 112 113 114 115 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 108 def test_size? assert_equal(nil, @zip_file.file.size?("notAFile")) assert_equal(72, @zip_file.file.size?("file1")) assert_equal(nil, @zip_file.file.size?("dir2/dir21")) assert_equal(72, @zip_file.file.stat("file1").size?) assert_equal(nil, @zip_file.file.stat("dir2/dir21").size?) end |
#test_socket? ⇒ Boolean
195 196 197 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 195 def test_socket? assert_always_false(:socket?) end |
#test_split ⇒ Object
144 145 146 147 148 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 144 def test_split assert_forwarded(File, :split, "retVal", "a/b/c/d") { @zip_file.file.split("a/b/c/d") } end |
#test_stat ⇒ Object
393 394 395 396 397 398 399 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 393 def test_stat s = @zip_file.file.stat("file1") assert(s.kind_of?(File::Stat)) # It pretends assert_raises(Errno::ENOENT, "No such file or directory - noSuchFile") { @zip_file.file.stat("noSuchFile") } end |
#test_sticky? ⇒ Boolean
383 384 385 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 383 def test_sticky? assert_always_false(:sticky?) end |
#test_symlink ⇒ Object
93 94 95 96 97 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 93 def test_symlink assert_raises(NotImplementedError) { @zip_file.file.symlink("file1", "aSymlink") } end |
#test_symlink? ⇒ Boolean
191 192 193 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 191 def test_symlink? assert_always_false(:symlink?) end |
#test_truncate ⇒ Object
203 204 205 206 207 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 203 def test_truncate assert_raises(StandardError, "truncate not supported") { @zip_file.file.truncate("file1", 100) } end |
#test_umask ⇒ Object
15 16 17 18 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 15 def test_umask assert_equal(::File.umask, @zip_file.file.umask) @zip_file.file.umask(0006) end |
#test_utime ⇒ Object
157 158 159 160 161 162 163 164 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 157 def test_utime t_now = ::Zip::DOSTime.now t_bak = @zip_file.file.mtime("file1") @zip_file.file.utime(t_now, "file1") assert_equal(t_now, @zip_file.file.mtime("file1")) @zip_file.file.utime(t_bak, "file1") assert_equal(t_bak, @zip_file.file.mtime("file1")) end |
#test_writable? ⇒ Boolean
335 336 337 338 339 340 341 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 335 def test_writable? assert(! @zip_file.file.writable?("noSuchFile")) assert(@zip_file.file.writable?("file1")) assert(@zip_file.file.writable?("dir1")) assert(@zip_file.file.stat("file1").writable?) assert(@zip_file.file.stat("dir1").writable?) end |
#test_writable_real? ⇒ Boolean
343 344 345 346 347 348 349 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 343 def test_writable_real? assert(! @zip_file.file.writable_real?("noSuchFile")) assert(@zip_file.file.writable_real?("file1")) assert(@zip_file.file.writable_real?("dir1")) assert(@zip_file.file.stat("file1").writable_real?) assert(@zip_file.file.stat("dir1").writable_real?) end |
#test_zero? ⇒ Boolean
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb', line 250 def test_zero? assert(! @zip_file.file.zero?("notAFile")) assert(! @zip_file.file.zero?("file1")) assert(@zip_file.file.zero?("dir1")) blockCalled = false ::Zip::File.open("test/data/generated/5entry.zip") { |zf| blockCalled = true assert(zf.file.zero?("test/data/generated/empty.txt")) } assert(blockCalled) assert(! @zip_file.file.stat("file1").zero?) assert(@zip_file.file.stat("dir1").zero?) blockCalled = false ::Zip::File.open("test/data/generated/5entry.zip") { |zf| blockCalled = true assert(zf.file.stat("test/data/generated/empty.txt").zero?) } assert(blockCalled) end |