archive-zip 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/LICENSE +22 -57
- data/{NEWS → NEWS.md} +29 -16
- data/README.md +250 -0
- data/Rakefile +119 -76
- data/lib/archive/support/binary_stringio.rb +9 -2
- data/lib/archive/support/time.rb +2 -2
- data/lib/archive/zip.rb +1 -1
- data/lib/archive/zip/entry.rb +2 -2
- data/lib/archive/zip/version.rb +1 -1
- data/spec/archive/zip/archive_spec.rb +54 -0
- data/spec/archive/zip/codec/deflate/compress/checksum_spec.rb +8 -6
- data/spec/archive/zip/codec/deflate/compress/close_spec.rb +13 -12
- data/spec/archive/zip/codec/deflate/compress/crc32_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/compress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/deflate/compress/new_spec.rb +7 -5
- data/spec/archive/zip/codec/deflate/compress/open_spec.rb +9 -7
- data/spec/archive/zip/codec/deflate/compress/write_spec.rb +15 -15
- data/spec/archive/zip/codec/deflate/decompress/checksum_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/decompress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/deflate/decompress/crc32_spec.rb +6 -4
- data/spec/archive/zip/codec/deflate/decompress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/deflate/decompress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/deflate/decompress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/null_encryption/decrypt/close_spec.rb +10 -9
- data/spec/archive/zip/codec/null_encryption/decrypt/new_spec.rb +6 -4
- data/spec/archive/zip/codec/null_encryption/decrypt/open_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/decrypt/read_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/decrypt/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/null_encryption/decrypt/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/null_encryption/decrypt/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/null_encryption/encrypt/close_spec.rb +10 -9
- data/spec/archive/zip/codec/null_encryption/encrypt/new_spec.rb +5 -3
- data/spec/archive/zip/codec/null_encryption/encrypt/open_spec.rb +9 -5
- data/spec/archive/zip/codec/null_encryption/encrypt/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/null_encryption/encrypt/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/null_encryption/encrypt/tell_spec.rb +11 -9
- data/spec/archive/zip/codec/null_encryption/encrypt/write_spec.rb +12 -10
- data/spec/archive/zip/codec/store/compress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/store/compress/data_descriptor_spec.rb +19 -10
- data/spec/archive/zip/codec/store/compress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/store/compress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/store/compress/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/store/compress/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/store/compress/tell_spec.rb +11 -9
- data/spec/archive/zip/codec/store/compress/write_spec.rb +10 -10
- data/spec/archive/zip/codec/store/decompress/close_spec.rb +10 -9
- data/spec/archive/zip/codec/store/decompress/data_descriptor_spec.rb +17 -10
- data/spec/archive/zip/codec/store/decompress/new_spec.rb +5 -3
- data/spec/archive/zip/codec/store/decompress/open_spec.rb +7 -5
- data/spec/archive/zip/codec/store/decompress/read_spec.rb +8 -6
- data/spec/archive/zip/codec/store/decompress/rewind_spec.rb +9 -7
- data/spec/archive/zip/codec/store/decompress/seek_spec.rb +15 -13
- data/spec/archive/zip/codec/store/decompress/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/traditional_encryption/decrypt/close_spec.rb +13 -24
- data/spec/archive/zip/codec/traditional_encryption/decrypt/new_spec.rb +6 -4
- data/spec/archive/zip/codec/traditional_encryption/decrypt/open_spec.rb +10 -6
- data/spec/archive/zip/codec/traditional_encryption/decrypt/read_spec.rb +12 -13
- data/spec/archive/zip/codec/traditional_encryption/decrypt/rewind_spec.rb +10 -12
- data/spec/archive/zip/codec/traditional_encryption/decrypt/seek_spec.rb +16 -18
- data/spec/archive/zip/codec/traditional_encryption/decrypt/tell_spec.rb +8 -6
- data/spec/archive/zip/codec/traditional_encryption/encrypt/close_spec.rb +13 -24
- data/spec/archive/zip/codec/traditional_encryption/encrypt/new_spec.rb +5 -3
- data/spec/archive/zip/codec/traditional_encryption/encrypt/open_spec.rb +7 -5
- data/spec/archive/zip/codec/traditional_encryption/encrypt/rewind_spec.rb +10 -12
- data/spec/archive/zip/codec/traditional_encryption/encrypt/seek_spec.rb +16 -18
- data/spec/archive/zip/codec/traditional_encryption/encrypt/tell_spec.rb +12 -14
- data/spec/archive/zip/codec/traditional_encryption/encrypt/write_spec.rb +8 -23
- data/spec/binary_stringio/new_spec.rb +18 -12
- data/spec/binary_stringio/set_encoding_spec.rb +10 -7
- data/spec/ioextensions/read_exactly_spec.rb +14 -12
- data/spec/zlib/zreader/checksum_spec.rb +10 -8
- data/spec/zlib/zreader/close_spec.rb +5 -3
- data/spec/zlib/zreader/compressed_size_spec.rb +6 -4
- data/spec/zlib/zreader/new_spec.rb +7 -5
- data/spec/zlib/zreader/open_spec.rb +9 -7
- data/spec/zlib/zreader/read_spec.rb +10 -8
- data/spec/zlib/zreader/rewind_spec.rb +7 -5
- data/spec/zlib/zreader/seek_spec.rb +13 -11
- data/spec/zlib/zreader/tell_spec.rb +8 -6
- data/spec/zlib/zreader/uncompressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/checksum_spec.rb +10 -8
- data/spec/zlib/zwriter/close_spec.rb +5 -3
- data/spec/zlib/zwriter/compressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/new_spec.rb +10 -8
- data/spec/zlib/zwriter/open_spec.rb +12 -10
- data/spec/zlib/zwriter/rewind_spec.rb +9 -7
- data/spec/zlib/zwriter/seek_spec.rb +15 -17
- data/spec/zlib/zwriter/tell_spec.rb +11 -9
- data/spec/zlib/zwriter/uncompressed_size_spec.rb +6 -4
- data/spec/zlib/zwriter/write_spec.rb +9 -9
- metadata +268 -217
- data/CONTRIBUTORS +0 -13
- data/GPL +0 -676
- data/HACKING +0 -105
- data/LEGAL +0 -8
- data/README +0 -151
- data/TODO +0 -5
- data/default.mspec +0 -8
- data/spec_helper.rb +0 -49
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/support/zlib'
|
6
8
|
require 'archive/zip/codec/store'
|
7
9
|
|
@@ -12,12 +14,14 @@ describe "Archive::Zip::Codec::Store::Decompress#data_descriptor" do
|
|
12
14
|
cd
|
13
15
|
) do |decompressor|
|
14
16
|
decompressor.read
|
15
|
-
decompressor.data_descriptor.
|
17
|
+
decompressor.data_descriptor.must_be_instance_of(
|
16
18
|
Archive::Zip::DataDescriptor
|
19
|
+
)
|
17
20
|
decompressor
|
18
21
|
end
|
19
|
-
closed_decompressor.data_descriptor.
|
22
|
+
closed_decompressor.data_descriptor.must_be_instance_of(
|
20
23
|
Archive::Zip::DataDescriptor
|
24
|
+
)
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
@@ -28,10 +32,10 @@ describe "Archive::Zip::Codec::Store::Decompress#data_descriptor" do
|
|
28
32
|
cd
|
29
33
|
) do |decompressor|
|
30
34
|
decompressor.read
|
31
|
-
decompressor.data_descriptor.crc32.
|
35
|
+
decompressor.data_descriptor.crc32.must_equal(crc32)
|
32
36
|
decompressor
|
33
37
|
end
|
34
|
-
closed_decompressor.data_descriptor.crc32.
|
38
|
+
closed_decompressor.data_descriptor.crc32.must_equal(crc32)
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
@@ -42,11 +46,12 @@ describe "Archive::Zip::Codec::Store::Decompress#data_descriptor" do
|
|
42
46
|
cd
|
43
47
|
) do |decompressor|
|
44
48
|
decompressor.read
|
45
|
-
decompressor.data_descriptor.compressed_size.
|
49
|
+
decompressor.data_descriptor.compressed_size.must_equal(compressed_size)
|
46
50
|
decompressor
|
47
51
|
end
|
48
|
-
closed_decompressor.data_descriptor.compressed_size.
|
52
|
+
closed_decompressor.data_descriptor.compressed_size.must_equal(
|
49
53
|
compressed_size
|
54
|
+
)
|
50
55
|
end
|
51
56
|
end
|
52
57
|
|
@@ -57,12 +62,14 @@ describe "Archive::Zip::Codec::Store::Decompress#data_descriptor" do
|
|
57
62
|
cd
|
58
63
|
) do |decompressor|
|
59
64
|
decompressor.read
|
60
|
-
decompressor.data_descriptor.uncompressed_size.
|
65
|
+
decompressor.data_descriptor.uncompressed_size.must_equal(
|
61
66
|
uncompressed_size
|
67
|
+
)
|
62
68
|
decompressor
|
63
69
|
end
|
64
|
-
closed_decompressor.data_descriptor.uncompressed_size.
|
70
|
+
closed_decompressor.data_descriptor.uncompressed_size.must_equal(
|
65
71
|
uncompressed_size
|
72
|
+
)
|
66
73
|
end
|
67
74
|
end
|
68
75
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/store'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
8
10
|
describe "Archive::Zip::Codec::Store::Decompress.new" do
|
9
11
|
it "returns a new instance" do
|
10
12
|
d = Archive::Zip::Codec::Store::Decompress.new(BinaryStringIO.new)
|
11
|
-
d.
|
13
|
+
d.must_be_instance_of(Archive::Zip::Codec::Store::Decompress)
|
12
14
|
d.close
|
13
15
|
end
|
14
16
|
end
|
@@ -1,20 +1,22 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/store'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
8
10
|
describe "Archive::Zip::Codec::Store::Decompress.open" do
|
9
11
|
it "returns a new instance when run without a block" do
|
10
12
|
d = Archive::Zip::Codec::Store::Decompress.open(BinaryStringIO.new)
|
11
|
-
d.
|
13
|
+
d.must_be_instance_of(Archive::Zip::Codec::Store::Decompress)
|
12
14
|
d.close
|
13
15
|
end
|
14
16
|
|
15
17
|
it "executes a block with a new instance as an argument" do
|
16
18
|
Archive::Zip::Codec::Store::Decompress.open(BinaryStringIO.new) do |decompressor|
|
17
|
-
decompressor.
|
19
|
+
decompressor.must_be_instance_of(Archive::Zip::Codec::Store::Decompress)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -22,6 +24,6 @@ describe "Archive::Zip::Codec::Store::Decompress.open" do
|
|
22
24
|
d = Archive::Zip::Codec::Store::Decompress.open(BinaryStringIO.new) do |decompressor|
|
23
25
|
decompressor
|
24
26
|
end
|
25
|
-
d.closed?.
|
27
|
+
d.closed?.must_equal(true)
|
26
28
|
end
|
27
29
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/store'
|
6
8
|
|
7
9
|
describe "Archive::Zip::Codec::Store::Decompress#read" do
|
8
10
|
it "calls the read method of the delegate" do
|
9
|
-
delegate =
|
10
|
-
delegate.
|
11
|
-
delegate.
|
11
|
+
delegate = MiniTest::Mock.new
|
12
|
+
delegate.expect(:read, nil, [Integer])
|
13
|
+
delegate.expect(:close, nil)
|
12
14
|
Archive::Zip::Codec::Store::Decompress.open(delegate) do |d|
|
13
15
|
d.read
|
14
16
|
end
|
@@ -17,7 +19,7 @@ describe "Archive::Zip::Codec::Store::Decompress#read" do
|
|
17
19
|
it "passes data through unmodified" do
|
18
20
|
StoreSpecs.compressed_data do |cd|
|
19
21
|
Archive::Zip::Codec::Store::Decompress.open(cd) do |d|
|
20
|
-
d.read.
|
22
|
+
d.read.must_equal(StoreSpecs.test_data)
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/store'
|
6
8
|
|
7
9
|
describe "Archive::Zip::Codec::Store::Decompress#rewind" do
|
@@ -9,17 +11,17 @@ describe "Archive::Zip::Codec::Store::Decompress#rewind" do
|
|
9
11
|
StoreSpecs.compressed_data do |cd|
|
10
12
|
Archive::Zip::Codec::Store::Decompress.open(cd) do |d|
|
11
13
|
d.read(4)
|
12
|
-
|
13
|
-
d.read.
|
14
|
+
d.rewind
|
15
|
+
d.read.must_equal(StoreSpecs.test_data)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
20
|
it "raises Errno::EINVAL when attempting to rewind the stream when the delegate does not respond to rewind" do
|
19
|
-
delegate =
|
20
|
-
delegate.
|
21
|
+
delegate = MiniTest::Mock.new
|
22
|
+
delegate.expect(:close, nil)
|
21
23
|
Archive::Zip::Codec::Store::Decompress.open(delegate) do |d|
|
22
|
-
lambda { d.rewind }.
|
24
|
+
lambda { d.rewind }.must_raise(Errno::EINVAL)
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/store'
|
6
8
|
|
7
9
|
describe "Archive::Zip::Codec::Store::Decompress#seek" do
|
@@ -9,16 +11,16 @@ describe "Archive::Zip::Codec::Store::Decompress#seek" do
|
|
9
11
|
StoreSpecs.compressed_data do |cd|
|
10
12
|
Archive::Zip::Codec::Store::Decompress.open(cd) do |d|
|
11
13
|
d.read(4)
|
12
|
-
|
14
|
+
d.seek(0).must_equal(0)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
19
|
it "raises Errno::EINVAL when attempting to seek to the beginning of the stream when the delegate does not respond to rewind" do
|
18
|
-
delegate =
|
19
|
-
delegate.
|
20
|
+
delegate = MiniTest::Mock.new
|
21
|
+
delegate.expect(:close, nil)
|
20
22
|
Archive::Zip::Codec::Store::Decompress.open(delegate) do |d|
|
21
|
-
lambda { d.seek(0) }.
|
23
|
+
lambda { d.seek(0) }.must_raise(Errno::EINVAL)
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
@@ -30,8 +32,8 @@ describe "Archive::Zip::Codec::Store::Decompress#seek" do
|
|
30
32
|
d.fill_size = 0
|
31
33
|
|
32
34
|
d.read(4)
|
33
|
-
lambda { d.seek(1, IO::SEEK_CUR) }.
|
34
|
-
lambda { d.seek(-1, IO::SEEK_CUR) }.
|
35
|
+
lambda { d.seek(1, IO::SEEK_CUR) }.must_raise(Errno::EINVAL)
|
36
|
+
lambda { d.seek(-1, IO::SEEK_CUR) }.must_raise(Errno::EINVAL)
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
@@ -39,8 +41,8 @@ describe "Archive::Zip::Codec::Store::Decompress#seek" do
|
|
39
41
|
it "raises Errno::EINVAL when seeking a non-zero offset relative to the beginning of the stream" do
|
40
42
|
StoreSpecs.compressed_data do |cd|
|
41
43
|
Archive::Zip::Codec::Store::Decompress.open(cd) do |d|
|
42
|
-
lambda { d.seek(-1, IO::SEEK_SET) }.
|
43
|
-
lambda { d.seek(1, IO::SEEK_SET) }.
|
44
|
+
lambda { d.seek(-1, IO::SEEK_SET) }.must_raise(Errno::EINVAL)
|
45
|
+
lambda { d.seek(1, IO::SEEK_SET) }.must_raise(Errno::EINVAL)
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
@@ -48,9 +50,9 @@ describe "Archive::Zip::Codec::Store::Decompress#seek" do
|
|
48
50
|
it "raises Errno::EINVAL when seeking relative to the end of the stream" do
|
49
51
|
StoreSpecs.compressed_data do |cd|
|
50
52
|
Archive::Zip::Codec::Store::Decompress.open(cd) do |d|
|
51
|
-
lambda { d.seek(0, IO::SEEK_END) }.
|
52
|
-
lambda { d.seek(-1, IO::SEEK_END) }.
|
53
|
-
lambda { d.seek(1, IO::SEEK_END) }.
|
53
|
+
lambda { d.seek(0, IO::SEEK_END) }.must_raise(Errno::EINVAL)
|
54
|
+
lambda { d.seek(-1, IO::SEEK_END) }.must_raise(Errno::EINVAL)
|
55
|
+
lambda { d.seek(1, IO::SEEK_END) }.must_raise(Errno::EINVAL)
|
54
56
|
end
|
55
57
|
end
|
56
58
|
end
|
@@ -1,20 +1,22 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/store'
|
6
8
|
|
7
9
|
describe "Archive::Zip::Codec::Store::Decompress#tell" do
|
8
10
|
it "returns the current position of the stream" do
|
9
11
|
StoreSpecs.compressed_data do |cd|
|
10
12
|
Archive::Zip::Codec::Store::Decompress.open(cd) do |d|
|
11
|
-
d.tell.
|
13
|
+
d.tell.must_equal(0)
|
12
14
|
d.read(4)
|
13
|
-
d.tell.
|
15
|
+
d.tell.must_equal(4)
|
14
16
|
d.read
|
15
|
-
d.tell.
|
17
|
+
d.tell.must_equal(235)
|
16
18
|
d.rewind
|
17
|
-
d.tell.
|
19
|
+
d.tell.must_equal(0)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/traditional_encryption'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
@@ -13,17 +15,13 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#close" do
|
|
13
15
|
TraditionalEncryptionSpecs.mtime
|
14
16
|
)
|
15
17
|
d.close
|
16
|
-
d.closed?.
|
18
|
+
d.closed?.must_equal(true)
|
17
19
|
end
|
18
20
|
|
19
21
|
it "closes the delegate stream by default" do
|
20
|
-
delegate =
|
21
|
-
|
22
|
-
|
23
|
-
#delegate.should_receive(:read).with(an_instance_of(Fixnum)).at_least(:once).and_return { |n| "\000" * n }
|
24
|
-
# Use the following instead for now.
|
25
|
-
delegate.should_receive(:read).once.and_return("\000" * 12)
|
26
|
-
delegate.should_receive(:close).and_return(nil)
|
22
|
+
delegate = MiniTest::Mock.new
|
23
|
+
delegate.expect(:read, "\000" * 12, [Integer])
|
24
|
+
delegate.expect(:close, nil)
|
27
25
|
d = Archive::Zip::Codec::TraditionalEncryption::Decrypt.new(
|
28
26
|
delegate,
|
29
27
|
TraditionalEncryptionSpecs.password,
|
@@ -33,13 +31,9 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#close" do
|
|
33
31
|
end
|
34
32
|
|
35
33
|
it "optionally leaves the delegate stream open" do
|
36
|
-
delegate =
|
37
|
-
|
38
|
-
|
39
|
-
#delegate.should_receive(:read).with(an_instance_of(Fixnum)).at_least(:once).and_return { |n| "\000" * n }
|
40
|
-
# Use the following instead for now.
|
41
|
-
delegate.should_receive(:read).once.and_return("\000" * 12)
|
42
|
-
delegate.should_receive(:close).and_return(nil)
|
34
|
+
delegate = MiniTest::Mock.new
|
35
|
+
delegate.expect(:read, "\000" * 12, [Integer])
|
36
|
+
delegate.expect(:close, nil)
|
43
37
|
d = Archive::Zip::Codec::TraditionalEncryption::Decrypt.new(
|
44
38
|
delegate,
|
45
39
|
TraditionalEncryptionSpecs.password,
|
@@ -47,13 +41,8 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#close" do
|
|
47
41
|
)
|
48
42
|
d.close(true)
|
49
43
|
|
50
|
-
delegate =
|
51
|
-
|
52
|
-
# of version 1.5.10.
|
53
|
-
#delegate.should_receive(:read).with(an_instance_of(Fixnum)).at_least(:once).and_return { |n| "\000" * n }
|
54
|
-
# Use the following instead for now.
|
55
|
-
delegate.should_receive(:read).once.and_return("\000" * 12)
|
56
|
-
delegate.should_not_receive(:close)
|
44
|
+
delegate = MiniTest::Mock.new
|
45
|
+
delegate.expect(:read, "\000" * 12, [Integer])
|
57
46
|
d = Archive::Zip::Codec::TraditionalEncryption::Decrypt.new(
|
58
47
|
delegate,
|
59
48
|
TraditionalEncryptionSpecs.password,
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
5
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
7
|
+
require 'archive/zip/codec/traditional_encryption'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
8
10
|
describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt.new" do
|
@@ -12,7 +14,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt.new" do
|
|
12
14
|
TraditionalEncryptionSpecs.password,
|
13
15
|
TraditionalEncryptionSpecs.mtime
|
14
16
|
)
|
15
|
-
d.
|
17
|
+
d.must_be_instance_of(Archive::Zip::Codec::TraditionalEncryption::Decrypt)
|
16
18
|
d.close
|
17
19
|
end
|
18
20
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
5
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
7
|
+
require 'archive/zip/codec/traditional_encryption'
|
6
8
|
require 'archive/support/binary_stringio'
|
7
9
|
|
8
10
|
describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt.open" do
|
@@ -12,7 +14,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt.open" do
|
|
12
14
|
TraditionalEncryptionSpecs.password,
|
13
15
|
TraditionalEncryptionSpecs.mtime
|
14
16
|
)
|
15
|
-
d.
|
17
|
+
d.must_be_instance_of(Archive::Zip::Codec::TraditionalEncryption::Decrypt)
|
16
18
|
d.close
|
17
19
|
end
|
18
20
|
|
@@ -22,7 +24,9 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt.open" do
|
|
22
24
|
TraditionalEncryptionSpecs.password,
|
23
25
|
TraditionalEncryptionSpecs.mtime
|
24
26
|
) do |decryptor|
|
25
|
-
decryptor.
|
27
|
+
decryptor.must_be_instance_of(
|
28
|
+
Archive::Zip::Codec::TraditionalEncryption::Decrypt
|
29
|
+
)
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
@@ -34,6 +38,6 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt.open" do
|
|
34
38
|
) do |decryptor|
|
35
39
|
decryptor
|
36
40
|
end
|
37
|
-
d.closed?.
|
41
|
+
d.closed?.must_equal(true)
|
38
42
|
end
|
39
43
|
end
|
@@ -1,18 +1,17 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'minitest/autorun'
|
4
|
+
|
5
|
+
require File.expand_path('../../fixtures/classes', __FILE__)
|
6
|
+
|
5
7
|
require 'archive/zip/codec/traditional_encryption'
|
6
8
|
|
7
9
|
describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#read" do
|
8
10
|
it "calls the read method of the delegate" do
|
9
|
-
delegate =
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# Use the following instead for now.
|
14
|
-
delegate.should_receive(:read).twice.and_return("\000" * 12, nil)
|
15
|
-
delegate.should_receive(:close).and_return(nil)
|
11
|
+
delegate = MiniTest::Mock.new
|
12
|
+
delegate.expect(:read, "\000" * 12, [Integer])
|
13
|
+
delegate.expect(:read, nil, [Integer])
|
14
|
+
delegate.expect(:close, nil)
|
16
15
|
Archive::Zip::Codec::TraditionalEncryption::Decrypt.open(
|
17
16
|
delegate,
|
18
17
|
TraditionalEncryptionSpecs.password,
|
@@ -29,7 +28,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#read" do
|
|
29
28
|
TraditionalEncryptionSpecs.password,
|
30
29
|
TraditionalEncryptionSpecs.mtime
|
31
30
|
) do |d|
|
32
|
-
d.read.
|
31
|
+
d.read.must_equal(TraditionalEncryptionSpecs.test_data)
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
@@ -55,7 +54,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#read" do
|
|
55
54
|
rescue Errno::EAGAIN
|
56
55
|
retry
|
57
56
|
end
|
58
|
-
buffer.
|
57
|
+
buffer.must_equal(TraditionalEncryptionSpecs.test_data)
|
59
58
|
end
|
60
59
|
end
|
61
60
|
end
|
@@ -87,7 +86,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#read" do
|
|
87
86
|
rescue Errno::EAGAIN
|
88
87
|
retry
|
89
88
|
end
|
90
|
-
buffer.
|
89
|
+
buffer.must_equal(TraditionalEncryptionSpecs.test_data)
|
91
90
|
end
|
92
91
|
end
|
93
92
|
end
|
@@ -119,7 +118,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#read" do
|
|
119
118
|
rescue Errno::EINTR
|
120
119
|
retry
|
121
120
|
end
|
122
|
-
buffer.
|
121
|
+
buffer.must_equal(TraditionalEncryptionSpecs.test_data)
|
123
122
|
end
|
124
123
|
end
|
125
124
|
end
|