archive-zip 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/LICENSE +22 -57
  4. data/{NEWS → NEWS.md} +29 -16
  5. data/README.md +250 -0
  6. data/Rakefile +119 -76
  7. data/lib/archive/support/binary_stringio.rb +9 -2
  8. data/lib/archive/support/time.rb +2 -2
  9. data/lib/archive/zip.rb +1 -1
  10. data/lib/archive/zip/entry.rb +2 -2
  11. data/lib/archive/zip/version.rb +1 -1
  12. data/spec/archive/zip/archive_spec.rb +54 -0
  13. data/spec/archive/zip/codec/deflate/compress/checksum_spec.rb +8 -6
  14. data/spec/archive/zip/codec/deflate/compress/close_spec.rb +13 -12
  15. data/spec/archive/zip/codec/deflate/compress/crc32_spec.rb +6 -4
  16. data/spec/archive/zip/codec/deflate/compress/data_descriptor_spec.rb +17 -10
  17. data/spec/archive/zip/codec/deflate/compress/new_spec.rb +7 -5
  18. data/spec/archive/zip/codec/deflate/compress/open_spec.rb +9 -7
  19. data/spec/archive/zip/codec/deflate/compress/write_spec.rb +15 -15
  20. data/spec/archive/zip/codec/deflate/decompress/checksum_spec.rb +6 -4
  21. data/spec/archive/zip/codec/deflate/decompress/close_spec.rb +10 -9
  22. data/spec/archive/zip/codec/deflate/decompress/crc32_spec.rb +6 -4
  23. data/spec/archive/zip/codec/deflate/decompress/data_descriptor_spec.rb +17 -10
  24. data/spec/archive/zip/codec/deflate/decompress/new_spec.rb +5 -3
  25. data/spec/archive/zip/codec/deflate/decompress/open_spec.rb +7 -5
  26. data/spec/archive/zip/codec/null_encryption/decrypt/close_spec.rb +10 -9
  27. data/spec/archive/zip/codec/null_encryption/decrypt/new_spec.rb +6 -4
  28. data/spec/archive/zip/codec/null_encryption/decrypt/open_spec.rb +8 -6
  29. data/spec/archive/zip/codec/null_encryption/decrypt/read_spec.rb +8 -6
  30. data/spec/archive/zip/codec/null_encryption/decrypt/rewind_spec.rb +9 -7
  31. data/spec/archive/zip/codec/null_encryption/decrypt/seek_spec.rb +15 -13
  32. data/spec/archive/zip/codec/null_encryption/decrypt/tell_spec.rb +8 -6
  33. data/spec/archive/zip/codec/null_encryption/encrypt/close_spec.rb +10 -9
  34. data/spec/archive/zip/codec/null_encryption/encrypt/new_spec.rb +5 -3
  35. data/spec/archive/zip/codec/null_encryption/encrypt/open_spec.rb +9 -5
  36. data/spec/archive/zip/codec/null_encryption/encrypt/rewind_spec.rb +9 -7
  37. data/spec/archive/zip/codec/null_encryption/encrypt/seek_spec.rb +15 -13
  38. data/spec/archive/zip/codec/null_encryption/encrypt/tell_spec.rb +11 -9
  39. data/spec/archive/zip/codec/null_encryption/encrypt/write_spec.rb +12 -10
  40. data/spec/archive/zip/codec/store/compress/close_spec.rb +10 -9
  41. data/spec/archive/zip/codec/store/compress/data_descriptor_spec.rb +19 -10
  42. data/spec/archive/zip/codec/store/compress/new_spec.rb +5 -3
  43. data/spec/archive/zip/codec/store/compress/open_spec.rb +7 -5
  44. data/spec/archive/zip/codec/store/compress/rewind_spec.rb +9 -7
  45. data/spec/archive/zip/codec/store/compress/seek_spec.rb +15 -13
  46. data/spec/archive/zip/codec/store/compress/tell_spec.rb +11 -9
  47. data/spec/archive/zip/codec/store/compress/write_spec.rb +10 -10
  48. data/spec/archive/zip/codec/store/decompress/close_spec.rb +10 -9
  49. data/spec/archive/zip/codec/store/decompress/data_descriptor_spec.rb +17 -10
  50. data/spec/archive/zip/codec/store/decompress/new_spec.rb +5 -3
  51. data/spec/archive/zip/codec/store/decompress/open_spec.rb +7 -5
  52. data/spec/archive/zip/codec/store/decompress/read_spec.rb +8 -6
  53. data/spec/archive/zip/codec/store/decompress/rewind_spec.rb +9 -7
  54. data/spec/archive/zip/codec/store/decompress/seek_spec.rb +15 -13
  55. data/spec/archive/zip/codec/store/decompress/tell_spec.rb +8 -6
  56. data/spec/archive/zip/codec/traditional_encryption/decrypt/close_spec.rb +13 -24
  57. data/spec/archive/zip/codec/traditional_encryption/decrypt/new_spec.rb +6 -4
  58. data/spec/archive/zip/codec/traditional_encryption/decrypt/open_spec.rb +10 -6
  59. data/spec/archive/zip/codec/traditional_encryption/decrypt/read_spec.rb +12 -13
  60. data/spec/archive/zip/codec/traditional_encryption/decrypt/rewind_spec.rb +10 -12
  61. data/spec/archive/zip/codec/traditional_encryption/decrypt/seek_spec.rb +16 -18
  62. data/spec/archive/zip/codec/traditional_encryption/decrypt/tell_spec.rb +8 -6
  63. data/spec/archive/zip/codec/traditional_encryption/encrypt/close_spec.rb +13 -24
  64. data/spec/archive/zip/codec/traditional_encryption/encrypt/new_spec.rb +5 -3
  65. data/spec/archive/zip/codec/traditional_encryption/encrypt/open_spec.rb +7 -5
  66. data/spec/archive/zip/codec/traditional_encryption/encrypt/rewind_spec.rb +10 -12
  67. data/spec/archive/zip/codec/traditional_encryption/encrypt/seek_spec.rb +16 -18
  68. data/spec/archive/zip/codec/traditional_encryption/encrypt/tell_spec.rb +12 -14
  69. data/spec/archive/zip/codec/traditional_encryption/encrypt/write_spec.rb +8 -23
  70. data/spec/binary_stringio/new_spec.rb +18 -12
  71. data/spec/binary_stringio/set_encoding_spec.rb +10 -7
  72. data/spec/ioextensions/read_exactly_spec.rb +14 -12
  73. data/spec/zlib/zreader/checksum_spec.rb +10 -8
  74. data/spec/zlib/zreader/close_spec.rb +5 -3
  75. data/spec/zlib/zreader/compressed_size_spec.rb +6 -4
  76. data/spec/zlib/zreader/new_spec.rb +7 -5
  77. data/spec/zlib/zreader/open_spec.rb +9 -7
  78. data/spec/zlib/zreader/read_spec.rb +10 -8
  79. data/spec/zlib/zreader/rewind_spec.rb +7 -5
  80. data/spec/zlib/zreader/seek_spec.rb +13 -11
  81. data/spec/zlib/zreader/tell_spec.rb +8 -6
  82. data/spec/zlib/zreader/uncompressed_size_spec.rb +6 -4
  83. data/spec/zlib/zwriter/checksum_spec.rb +10 -8
  84. data/spec/zlib/zwriter/close_spec.rb +5 -3
  85. data/spec/zlib/zwriter/compressed_size_spec.rb +6 -4
  86. data/spec/zlib/zwriter/new_spec.rb +10 -8
  87. data/spec/zlib/zwriter/open_spec.rb +12 -10
  88. data/spec/zlib/zwriter/rewind_spec.rb +9 -7
  89. data/spec/zlib/zwriter/seek_spec.rb +15 -17
  90. data/spec/zlib/zwriter/tell_spec.rb +11 -9
  91. data/spec/zlib/zwriter/uncompressed_size_spec.rb +6 -4
  92. data/spec/zlib/zwriter/write_spec.rb +9 -9
  93. metadata +268 -217
  94. data/CONTRIBUTORS +0 -13
  95. data/GPL +0 -676
  96. data/HACKING +0 -105
  97. data/LEGAL +0 -8
  98. data/README +0 -151
  99. data/TODO +0 -5
  100. data/default.mspec +0 -8
  101. data/spec_helper.rb +0 -49
@@ -1,7 +1,9 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/null_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -9,24 +11,23 @@ describe "Archive::Zip::Codec::NullEncryption::Decrypt#close" do
9
11
  it "closes the stream" do
10
12
  d = Archive::Zip::Codec::NullEncryption::Decrypt.new(BinaryStringIO.new)
11
13
  d.close
12
- d.closed?.should be_true
14
+ d.closed?.must_equal(true)
13
15
  end
14
16
 
15
17
  it "closes the delegate stream by default" do
16
- delegate = mock('delegate')
17
- delegate.should_receive(:close).and_return(nil)
18
+ delegate = MiniTest::Mock.new
19
+ delegate.expect(:close, nil)
18
20
  d = Archive::Zip::Codec::NullEncryption::Decrypt.new(delegate)
19
21
  d.close
20
22
  end
21
23
 
22
24
  it "optionally leaves the delegate stream open" do
23
- delegate = mock('delegate')
24
- delegate.should_receive(:close).and_return(nil)
25
+ delegate = MiniTest::Mock.new
26
+ delegate.expect(:close, nil)
25
27
  d = Archive::Zip::Codec::NullEncryption::Decrypt.new(delegate)
26
28
  d.close(true)
27
29
 
28
- delegate = mock('delegate')
29
- delegate.should_not_receive(:close)
30
+ delegate = MiniTest::Mock.new
30
31
  d = Archive::Zip::Codec::NullEncryption::Decrypt.new(delegate)
31
32
  d.close(false)
32
33
  end
@@ -1,14 +1,16 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
5
- require 'archive/zip/codec/store'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
7
+ require 'archive/zip/codec/null_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
8
10
  describe "Archive::Zip::Codec::NullEncryption::Decrypt.new" do
9
11
  it "returns a new instance" do
10
12
  d = Archive::Zip::Codec::NullEncryption::Decrypt.new(BinaryStringIO.new)
11
- d.class.should == Archive::Zip::Codec::NullEncryption::Decrypt
13
+ d.must_be_instance_of(Archive::Zip::Codec::NullEncryption::Decrypt)
12
14
  d.close
13
15
  end
14
16
  end
@@ -1,20 +1,22 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
5
- require 'archive/zip/codec/store'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
7
+ require 'archive/zip/codec/null_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
8
10
  describe "Archive::Zip::Codec::NullEncryption::Decrypt.open" do
9
11
  it "returns a new instance when run without a block" do
10
12
  d = Archive::Zip::Codec::NullEncryption::Decrypt.open(BinaryStringIO.new)
11
- d.class.should == Archive::Zip::Codec::NullEncryption::Decrypt
13
+ d.must_be_instance_of(Archive::Zip::Codec::NullEncryption::Decrypt)
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::NullEncryption::Decrypt.open(BinaryStringIO.new) do |decryptor|
17
- decryptor.class.should == Archive::Zip::Codec::NullEncryption::Decrypt
19
+ decryptor.must_be_instance_of(Archive::Zip::Codec::NullEncryption::Decrypt)
18
20
  end
19
21
  end
20
22
 
@@ -22,6 +24,6 @@ describe "Archive::Zip::Codec::NullEncryption::Decrypt.open" do
22
24
  d = Archive::Zip::Codec::NullEncryption::Decrypt.open(BinaryStringIO.new) do |decryptor|
23
25
  decryptor
24
26
  end
25
- d.closed?.should.be_true
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 File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/null_encryption'
6
8
 
7
9
  describe "Archive::Zip::Codec::NullEncryption::Decrypt#read" do
8
10
  it "calls the read method of the delegate" do
9
- delegate = mock('delegate')
10
- delegate.should_receive(:read).and_return(nil)
11
- delegate.should_receive(:close).and_return(nil)
11
+ delegate = MiniTest::Mock.new
12
+ delegate.expect(:read, nil, [Integer])
13
+ delegate.expect(:close, nil)
12
14
  Archive::Zip::Codec::NullEncryption::Decrypt.open(delegate) do |d|
13
15
  d.read
14
16
  end
@@ -17,7 +19,7 @@ describe "Archive::Zip::Codec::NullEncryption::Decrypt#read" do
17
19
  it "passes data through unmodified" do
18
20
  NullEncryptionSpecs.encrypted_data do |ed|
19
21
  Archive::Zip::Codec::NullEncryption::Decrypt.open(ed) do |d|
20
- d.read.should == NullEncryptionSpecs.test_data
22
+ d.read.must_equal(NullEncryptionSpecs.test_data)
21
23
  end
22
24
  end
23
25
  end
@@ -1,7 +1,9 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/null_encryption'
6
8
 
7
9
  describe "Archive::Zip::Codec::NullEncryption::Decrypt#rewind" do
@@ -9,17 +11,17 @@ describe "Archive::Zip::Codec::NullEncryption::Decrypt#rewind" do
9
11
  NullEncryptionSpecs.encrypted_data do |ed|
10
12
  Archive::Zip::Codec::NullEncryption::Decrypt.open(ed) do |d|
11
13
  d.read(4)
12
- lambda { d.rewind }.should_not raise_error
13
- d.read.should == NullEncryptionSpecs.test_data
14
+ d.rewind
15
+ d.read.must_equal(NullEncryptionSpecs.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 = mock('delegate')
20
- delegate.should_receive(:close).and_return(nil)
21
+ delegate = MiniTest::Mock.new
22
+ delegate.expect(:close, nil)
21
23
  Archive::Zip::Codec::NullEncryption::Decrypt.open(delegate) do |d|
22
- lambda { d.rewind }.should raise_error(Errno::EINVAL)
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 File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/null_encryption'
6
8
 
7
9
  describe "Archive::Zip::Codec::NullEncryption::Decrypt#seek" do
@@ -9,16 +11,16 @@ describe "Archive::Zip::Codec::NullEncryption::Decrypt#seek" do
9
11
  NullEncryptionSpecs.encrypted_data do |ed|
10
12
  Archive::Zip::Codec::NullEncryption::Decrypt.open(ed) do |d|
11
13
  d.read(4)
12
- lambda { d.seek(0) }.should_not raise_error
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 = mock('delegate')
19
- delegate.should_receive(:close).and_return(nil)
20
+ delegate = MiniTest::Mock.new
21
+ delegate.expect(:close, nil)
20
22
  Archive::Zip::Codec::NullEncryption::Decrypt.open(delegate) do |d|
21
- lambda { d.seek(0) }.should raise_error(Errno::EINVAL)
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::NullEncryption::Decrypt#seek" do
30
32
  d.fill_size = 0
31
33
 
32
34
  d.read(4)
33
- lambda { d.seek(1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
34
- lambda { d.seek(-1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
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::NullEncryption::Decrypt#seek" do
39
41
  it "raises Errno::EINVAL when seeking a non-zero offset relative to the beginning of the stream" do
40
42
  NullEncryptionSpecs.encrypted_data do |ed|
41
43
  Archive::Zip::Codec::NullEncryption::Decrypt.open(ed) do |d|
42
- lambda { d.seek(-1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
43
- lambda { d.seek(1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
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::NullEncryption::Decrypt#seek" do
48
50
  it "raises Errno::EINVAL when seeking relative to the end of the stream" do
49
51
  NullEncryptionSpecs.encrypted_data do |ed|
50
52
  Archive::Zip::Codec::NullEncryption::Decrypt.open(ed) do |d|
51
- lambda { d.seek(0, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
52
- lambda { d.seek(-1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
53
- lambda { d.seek(1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
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 File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/null_encryption'
6
8
 
7
9
  describe "Archive::Zip::Codec::NullEncryption::Decrypt#tell" do
8
10
  it "returns the current position of the stream" do
9
11
  NullEncryptionSpecs.encrypted_data do |ed|
10
12
  Archive::Zip::Codec::NullEncryption::Decrypt.open(ed) do |d|
11
- d.tell.should == 0
13
+ d.tell.must_equal(0)
12
14
  d.read(4)
13
- d.tell.should == 4
15
+ d.tell.must_equal(4)
14
16
  d.read
15
- d.tell.should == 235
17
+ d.tell.must_equal(235)
16
18
  d.rewind
17
- d.tell.should == 0
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 File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/null_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -9,24 +11,23 @@ describe "Archive::Zip::Codec::NullEncryption::Encrypt#close" do
9
11
  it "closes the stream" do
10
12
  e = Archive::Zip::Codec::NullEncryption::Encrypt.new(BinaryStringIO.new)
11
13
  e.close
12
- e.closed?.should be_true
14
+ e.closed?.must_equal(true)
13
15
  end
14
16
 
15
17
  it "closes the delegate stream by default" do
16
- delegate = mock('delegate')
17
- delegate.should_receive(:close).and_return(nil)
18
+ delegate = MiniTest::Mock.new
19
+ delegate.expect(:close, nil)
18
20
  e = Archive::Zip::Codec::NullEncryption::Encrypt.new(delegate)
19
21
  e.close
20
22
  end
21
23
 
22
24
  it "optionally leaves the delegate stream open" do
23
- delegate = mock('delegate')
24
- delegate.should_receive(:close).and_return(nil)
25
+ delegate = MiniTest::Mock.new
26
+ delegate.expect(:close, nil)
25
27
  e = Archive::Zip::Codec::NullEncryption::Encrypt.new(delegate)
26
28
  e.close(true)
27
29
 
28
- delegate = mock('delegate')
29
- delegate.should_not_receive(:close)
30
+ delegate = MiniTest::Mock.new
30
31
  e = Archive::Zip::Codec::NullEncryption::Encrypt.new(delegate)
31
32
  e.close(false)
32
33
  end
@@ -1,14 +1,16 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/null_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
8
10
  describe "Archive::Zip::Codec::NullEncryption::Encrypt.new" do
9
11
  it "returns a new instance" do
10
12
  e = Archive::Zip::Codec::NullEncryption::Encrypt.new(BinaryStringIO.new)
11
- e.class.should == Archive::Zip::Codec::NullEncryption::Encrypt
13
+ e.must_be_instance_of(Archive::Zip::Codec::NullEncryption::Encrypt)
12
14
  e.close
13
15
  end
14
16
  end
@@ -1,20 +1,24 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/null_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
8
10
  describe "Archive::Zip::Codec::NullEncryption::Encrypt.open" do
9
11
  it "returns a new instance when run without a block" do
10
12
  e = Archive::Zip::Codec::NullEncryption::Encrypt.open(BinaryStringIO.new)
11
- e.class.should == Archive::Zip::Codec::NullEncryption::Encrypt
13
+ e.must_be_instance_of(Archive::Zip::Codec::NullEncryption::Encrypt)
12
14
  e.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::NullEncryption::Encrypt.open(BinaryStringIO.new) do |encryptor|
17
- encryptor.class.should == Archive::Zip::Codec::NullEncryption::Encrypt
19
+ encryptor.must_be_instance_of(
20
+ Archive::Zip::Codec::NullEncryption::Encrypt
21
+ )
18
22
  end
19
23
  end
20
24
 
@@ -22,6 +26,6 @@ describe "Archive::Zip::Codec::NullEncryption::Encrypt.open" do
22
26
  e = Archive::Zip::Codec::NullEncryption::Encrypt.open(BinaryStringIO.new) do |encryptor|
23
27
  encryptor
24
28
  end
25
- e.closed?.should.be_true
29
+ e.closed?.must_equal(true)
26
30
  end
27
31
  end
@@ -1,7 +1,9 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/null_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -10,17 +12,17 @@ describe "Archive::Zip::Codec::NullEncryption::Encrypt#rewind" do
10
12
  encrypted_data = BinaryStringIO.new
11
13
  Archive::Zip::Codec::NullEncryption::Encrypt.open(encrypted_data) do |e|
12
14
  e.write('test')
13
- lambda { e.rewind }.should_not raise_error
15
+ e.rewind
14
16
  e.write(NullEncryptionSpecs.test_data)
15
17
  end
16
- encrypted_data.string.should == NullEncryptionSpecs.encrypted_data
18
+ encrypted_data.string.must_equal(NullEncryptionSpecs.encrypted_data)
17
19
  end
18
20
 
19
21
  it "raises Errno::EINVAL when attempting to rewind the stream when the delegate does not respond to rewind" do
20
- delegate = mock('delegate')
21
- delegate.should_receive(:close).once.and_return(nil)
22
+ delegate = MiniTest::Mock.new
23
+ delegate.expect(:close, nil)
22
24
  Archive::Zip::Codec::NullEncryption::Encrypt.open(delegate) do |e|
23
- lambda { e.rewind }.should raise_error(Errno::EINVAL)
25
+ lambda { e.rewind }.must_raise(Errno::EINVAL)
24
26
  end
25
27
  end
26
28
  end
@@ -1,7 +1,9 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/null_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -10,15 +12,15 @@ describe "Archive::Zip::Codec::NullEncryption::Encrypt#seek" do
10
12
  encrypted_data = BinaryStringIO.new
11
13
  Archive::Zip::Codec::NullEncryption::Encrypt.open(encrypted_data) do |e|
12
14
  e.write('test')
13
- lambda { e.seek(0) }.should_not raise_error
15
+ e.seek(0).must_equal(0)
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 = mock('delegate')
19
- delegate.should_receive(:close).and_return(nil)
20
+ delegate = MiniTest::Mock.new
21
+ delegate.expect(:close, nil)
20
22
  Archive::Zip::Codec::NullEncryption::Encrypt.open(delegate) do |e|
21
- lambda { e.seek(0) }.should raise_error(Errno::EINVAL)
23
+ lambda { e.seek(0) }.must_raise(Errno::EINVAL)
22
24
  end
23
25
  end
24
26
 
@@ -26,25 +28,25 @@ describe "Archive::Zip::Codec::NullEncryption::Encrypt#seek" do
26
28
  encrypted_data = BinaryStringIO.new
27
29
  Archive::Zip::Codec::NullEncryption::Encrypt.open(encrypted_data) do |e|
28
30
  e.write('test')
29
- lambda { e.seek(1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
30
- lambda { e.seek(-1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
31
+ lambda { e.seek(1, IO::SEEK_CUR) }.must_raise(Errno::EINVAL)
32
+ lambda { e.seek(-1, IO::SEEK_CUR) }.must_raise(Errno::EINVAL)
31
33
  end
32
34
  end
33
35
 
34
36
  it "raises Errno::EINVAL when seeking a non-zero offset relative to the beginning of the stream" do
35
37
  encrypted_data = BinaryStringIO.new
36
38
  Archive::Zip::Codec::NullEncryption::Encrypt.open(encrypted_data) do |e|
37
- lambda { e.seek(-1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
38
- lambda { e.seek(1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
39
+ lambda { e.seek(-1, IO::SEEK_SET) }.must_raise(Errno::EINVAL)
40
+ lambda { e.seek(1, IO::SEEK_SET) }.must_raise(Errno::EINVAL)
39
41
  end
40
42
  end
41
43
 
42
44
  it "raises Errno::EINVAL when seeking relative to the end of the stream" do
43
45
  encrypted_data = BinaryStringIO.new
44
46
  Archive::Zip::Codec::NullEncryption::Encrypt.open(encrypted_data) do |e|
45
- lambda { e.seek(0, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
46
- lambda { e.seek(-1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
47
- lambda { e.seek(1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
47
+ lambda { e.seek(0, IO::SEEK_END) }.must_raise(Errno::EINVAL)
48
+ lambda { e.seek(-1, IO::SEEK_END) }.must_raise(Errno::EINVAL)
49
+ lambda { e.seek(1, IO::SEEK_END) }.must_raise(Errno::EINVAL)
48
50
  end
49
51
  end
50
52
  end