test/zipfilesystemtest.rb in rubyzip-0.9.1 vs test/zipfilesystemtest.rb in rubyzip-0.9.4

- old
+ new

@@ -4,10 +4,11 @@ $: << "../lib" require 'zip/zipfilesystem' require 'test/unit' +require 'fileutils' module ExtraAssertions def assert_forwarded(anObject, method, retVal, *expectedArgs) callArgs = nil @@ -21,11 +22,11 @@ end_eval assert_equal(retVal, yield) # Invoke test assert_equal(expectedArgs, callArgs) ensure - anObject.instance_eval "alias #{method} #{method}_org" + anObject.instance_eval "undef #{method}; alias #{method} #{method}_org" end end include Zip @@ -66,10 +67,19 @@ f.readline.chomp) } assert(blockCalled) blockCalled = false + @zipFile.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 @zipFile.dir.chdir "dir2" @zipFile.file.open("file21", "r") { |f| blockCalled = true assert_equal("this is the entry 'dir2/file21' in my test archive!", @@ -550,11 +560,11 @@ end class ZipFsFileMutatingTest < Test::Unit::TestCase TEST_ZIP = "zipWithDirs_copy.zip" def setup - File.copy("data/zipWithDirs.zip", TEST_ZIP) + FileUtils.cp("data/zipWithDirs.zip", TEST_ZIP) end def teardown end @@ -577,11 +587,11 @@ } assert_equal("This is what I'm writing", zf.file.read("test_open_write_entry")) # Test with existing entry - zf.file.open("file1", "w") { + zf.file.open("file1", "wb") { #also check that 'b' option is ignored |f| blockCalled = true f.write "This is what I'm writing too" } assert_equal("This is what I'm writing too", @@ -638,10 +648,10 @@ class ZipFsDirectoryTest < Test::Unit::TestCase TEST_ZIP = "zipWithDirs_copy.zip" def setup - File.copy("data/zipWithDirs.zip", TEST_ZIP) + FileUtils.cp("data/zipWithDirs.zip", TEST_ZIP) end def test_delete ZipFile.open(TEST_ZIP) { |zf|