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/traditional_encryption'
6
8
 
7
9
  describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#rewind" do
@@ -13,26 +15,22 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#rewind" do
13
15
  TraditionalEncryptionSpecs.mtime
14
16
  ) do |d|
15
17
  d.read(4)
16
- lambda { d.rewind }.should_not raise_error
17
- d.read.should == TraditionalEncryptionSpecs.test_data
18
+ d.rewind
19
+ d.read.must_equal(TraditionalEncryptionSpecs.test_data)
18
20
  end
19
21
  end
20
22
  end
21
23
 
22
24
  it "raises Errno::EINVAL when attempting to rewind the stream when the delegate does not respond to rewind" do
23
- delegate = mock('delegate')
24
- # RSpec's mocking facility supposedly supports this, but MSpec's does not as
25
- # of version 1.5.10.
26
- #delegate.should_receive(:read).with(an_instance_of(Fixnum)).at_least(:once).and_return { |n| "\000" * n }
27
- # Use the following instead for now.
28
- delegate.should_receive(:read).once.and_return("\000" * 12)
29
- delegate.should_receive(:close).and_return(nil)
25
+ delegate = MiniTest::Mock.new
26
+ delegate.expect(:read, "\000" * 12, [Integer])
27
+ delegate.expect(:close, nil)
30
28
  Archive::Zip::Codec::TraditionalEncryption::Decrypt.open(
31
29
  delegate,
32
30
  TraditionalEncryptionSpecs.password,
33
31
  TraditionalEncryptionSpecs.mtime
34
32
  ) do |d|
35
- lambda { d.rewind }.should raise_error(Errno::EINVAL)
33
+ lambda { d.rewind }.must_raise(Errno::EINVAL)
36
34
  end
37
35
  end
38
36
  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/traditional_encryption'
6
8
 
7
9
  describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#seek" do
@@ -13,25 +15,21 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#seek" do
13
15
  TraditionalEncryptionSpecs.mtime
14
16
  ) do |d|
15
17
  d.read(4)
16
- lambda { d.seek(0) }.should_not raise_error
18
+ d.seek(0).must_equal(0)
17
19
  end
18
20
  end
19
21
  end
20
22
 
21
23
  it "raises Errno::EINVAL when attempting to seek to the beginning of the stream when the delegate does not respond to rewind" do
22
- delegate = mock('delegate')
23
- # RSpec's mocking facility supposedly supports this, but MSpec's does not as
24
- # of version 1.5.10.
25
- #delegate.should_receive(:read).with(an_instance_of(Fixnum)).at_least(:once).and_return { |n| "\000" * n }
26
- # Use the following instead for now.
27
- delegate.should_receive(:read).once.and_return("\000" * 12)
28
- delegate.should_receive(:close).and_return(nil)
24
+ delegate = MiniTest::Mock.new
25
+ delegate.expect(:read, "\000" * 12, [Integer])
26
+ delegate.expect(:close, nil)
29
27
  Archive::Zip::Codec::TraditionalEncryption::Decrypt.open(
30
28
  delegate,
31
29
  TraditionalEncryptionSpecs.password,
32
30
  TraditionalEncryptionSpecs.mtime
33
31
  ) do |d|
34
- lambda { d.seek(0) }.should raise_error(Errno::EINVAL)
32
+ lambda { d.seek(0) }.must_raise(Errno::EINVAL)
35
33
  end
36
34
  end
37
35
 
@@ -47,8 +45,8 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#seek" do
47
45
  d.fill_size = 0
48
46
 
49
47
  d.read(4)
50
- lambda { d.seek(1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
51
- lambda { d.seek(-1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
48
+ lambda { d.seek(1, IO::SEEK_CUR) }.must_raise(Errno::EINVAL)
49
+ lambda { d.seek(-1, IO::SEEK_CUR) }.must_raise(Errno::EINVAL)
52
50
  end
53
51
  end
54
52
  end
@@ -60,8 +58,8 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#seek" do
60
58
  TraditionalEncryptionSpecs.password,
61
59
  TraditionalEncryptionSpecs.mtime
62
60
  ) do |d|
63
- lambda { d.seek(-1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
64
- lambda { d.seek(1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
61
+ lambda { d.seek(-1, IO::SEEK_SET) }.must_raise(Errno::EINVAL)
62
+ lambda { d.seek(1, IO::SEEK_SET) }.must_raise(Errno::EINVAL)
65
63
  end
66
64
  end
67
65
  end
@@ -73,9 +71,9 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#seek" do
73
71
  TraditionalEncryptionSpecs.password,
74
72
  TraditionalEncryptionSpecs.mtime
75
73
  ) do |d|
76
- lambda { d.seek(0, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
77
- lambda { d.seek(-1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
78
- lambda { d.seek(1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
74
+ lambda { d.seek(0, IO::SEEK_END) }.must_raise(Errno::EINVAL)
75
+ lambda { d.seek(-1, IO::SEEK_END) }.must_raise(Errno::EINVAL)
76
+ lambda { d.seek(1, IO::SEEK_END) }.must_raise(Errno::EINVAL)
79
77
  end
80
78
  end
81
79
  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/traditional_encryption'
6
8
 
7
9
  describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#tell" do
@@ -12,13 +14,13 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Decrypt#tell" do
12
14
  TraditionalEncryptionSpecs.password,
13
15
  TraditionalEncryptionSpecs.mtime
14
16
  ) do |d|
15
- d.tell.should == 0
17
+ d.tell.must_equal(0)
16
18
  d.read(4)
17
- d.tell.should == 4
19
+ d.tell.must_equal(4)
18
20
  d.read
19
- d.tell.should == 235
21
+ d.tell.must_equal(235)
20
22
  d.rewind
21
- d.tell.should == 0
23
+ d.tell.must_equal(0)
22
24
  end
23
25
  end
24
26
  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/traditional_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -13,17 +15,13 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#close" do
13
15
  TraditionalEncryptionSpecs.mtime
14
16
  )
15
17
  e.close
16
- e.closed?.should be_true
18
+ e.closed?.must_equal(true)
17
19
  end
18
20
 
19
21
  it "closes the delegate stream by default" do
20
- delegate = mock('delegate')
21
- # RSpec's mocking facility supposedly supports this, but MSpec's does not as
22
- # of version 1.5.10.
23
- #delegate.should_receive(:write).with(an_instance_of(String)).at_least(:once).and_return { |s| s.length }
24
- # Use the following instead for now.
25
- delegate.should_receive(:write).at_least(:once).and_return(1)
26
- delegate.should_receive(:close).and_return(nil)
22
+ delegate = MiniTest::Mock.new
23
+ delegate.expect(:write, 12, [String])
24
+ delegate.expect(:close, nil)
27
25
  e = Archive::Zip::Codec::TraditionalEncryption::Encrypt.new(
28
26
  delegate,
29
27
  TraditionalEncryptionSpecs.password,
@@ -33,13 +31,9 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#close" do
33
31
  end
34
32
 
35
33
  it "optionally leaves the delegate stream open" do
36
- delegate = mock('delegate')
37
- # RSpec's mocking facility supposedly supports this, but MSpec's does not as
38
- # of version 1.5.10.
39
- #delegate.should_receive(:write).with(an_instance_of(String)).at_least(:once).and_return { |s| s.length }
40
- # Use the following instead for now.
41
- delegate.should_receive(:write).at_least(:once).and_return(1)
42
- delegate.should_receive(:close).and_return(nil)
34
+ delegate = MiniTest::Mock.new
35
+ delegate.expect(:write, 12, [String])
36
+ delegate.expect(:close, nil)
43
37
  e = Archive::Zip::Codec::TraditionalEncryption::Encrypt.new(
44
38
  delegate,
45
39
  TraditionalEncryptionSpecs.password,
@@ -47,13 +41,8 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#close" do
47
41
  )
48
42
  e.close(true)
49
43
 
50
- delegate = mock('delegate')
51
- # RSpec's mocking facility supposedly supports this, but MSpec's does not as
52
- # of version 1.5.10.
53
- #delegate.should_receive(:write).with(an_instance_of(String)).at_least(:once).and_return { |s| s.length }
54
- # Use the following instead for now.
55
- delegate.should_receive(:write).at_least(:once).and_return(1)
56
- delegate.should_not_receive(:close)
44
+ delegate = MiniTest::Mock.new
45
+ delegate.expect(:write, 12, [String])
57
46
  e = Archive::Zip::Codec::TraditionalEncryption::Encrypt.new(
58
47
  delegate,
59
48
  TraditionalEncryptionSpecs.password,
@@ -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/traditional_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -12,7 +14,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt.new" do
12
14
  TraditionalEncryptionSpecs.password,
13
15
  TraditionalEncryptionSpecs.mtime
14
16
  )
15
- e.class.should == Archive::Zip::Codec::TraditionalEncryption::Encrypt
17
+ e.must_be_instance_of(Archive::Zip::Codec::TraditionalEncryption::Encrypt)
16
18
  e.close
17
19
  end
18
20
  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/traditional_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -12,7 +14,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt.open" do
12
14
  TraditionalEncryptionSpecs.password,
13
15
  TraditionalEncryptionSpecs.mtime
14
16
  )
15
- e.class.should == Archive::Zip::Codec::TraditionalEncryption::Encrypt
17
+ e.must_be_instance_of(Archive::Zip::Codec::TraditionalEncryption::Encrypt)
16
18
  e.close
17
19
  end
18
20
 
@@ -22,7 +24,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt.open" do
22
24
  TraditionalEncryptionSpecs.password,
23
25
  TraditionalEncryptionSpecs.mtime
24
26
  ) do |encryptor|
25
- encryptor.class.should == Archive::Zip::Codec::TraditionalEncryption::Encrypt
27
+ encryptor.must_be_instance_of(Archive::Zip::Codec::TraditionalEncryption::Encrypt)
26
28
  end
27
29
  end
28
30
 
@@ -34,6 +36,6 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt.open" do
34
36
  ) do |encryptor|
35
37
  encryptor
36
38
  end
37
- e.closed?.should.be_true
39
+ e.closed?.must_equal(true)
38
40
  end
39
41
  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/traditional_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -16,26 +18,22 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#rewind" do
16
18
  e.write('test')
17
19
  # Ensure repeatable test data is used for encryption header.
18
20
  srand(0)
19
- lambda { e.rewind }.should_not raise_error
21
+ e.rewind
20
22
  e.write(TraditionalEncryptionSpecs.test_data)
21
23
  end
22
- encrypted_data.string.should == TraditionalEncryptionSpecs.encrypted_data
24
+ encrypted_data.string.must_equal(TraditionalEncryptionSpecs.encrypted_data)
23
25
  end
24
26
 
25
27
  it "raises Errno::EINVAL when attempting to rewind the stream when the delegate does not respond to rewind" do
26
- delegate = mock('delegate')
27
- # RSpec's mocking facility supposedly supports this, but MSpec's does not as
28
- # of version 1.5.10.
29
- #delegate.should_receive(:write).with(an_instance_of(String)).at_least(:once).and_return { |s| s.length }
30
- # Use the following instead for now.
31
- delegate.should_receive(:write).at_least(:once).and_return(1)
32
- delegate.should_receive(:close).once.and_return(nil)
28
+ delegate = MiniTest::Mock.new
29
+ delegate.expect(:write, 12, [String])
30
+ delegate.expect(:close, nil)
33
31
  Archive::Zip::Codec::TraditionalEncryption::Encrypt.open(
34
32
  delegate,
35
33
  TraditionalEncryptionSpecs.password,
36
34
  TraditionalEncryptionSpecs.mtime
37
35
  ) do |e|
38
- lambda { e.rewind }.should raise_error(Errno::EINVAL)
36
+ lambda { e.rewind }.must_raise(Errno::EINVAL)
39
37
  end
40
38
  end
41
39
  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/traditional_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -14,24 +16,20 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#seek" do
14
16
  TraditionalEncryptionSpecs.mtime
15
17
  ) do |e|
16
18
  e.write('test')
17
- lambda { e.seek(0) }.should_not raise_error
19
+ e.seek(0).must_equal(0)
18
20
  end
19
21
  end
20
22
 
21
23
  it "raises Errno::EINVAL when attempting to seek to the beginning of the stream when the delegate does not respond to rewind" do
22
- delegate = mock('delegate')
23
- # RSpec's mocking facility supposedly supports this, but MSpec's does not as
24
- # of version 1.5.10.
25
- #delegate.should_receive(:write).with(an_instance_of(String)).at_least(:once).and_return { |s| s.length }
26
- # Use the following instead for now.
27
- delegate.should_receive(:write).at_least(:once).and_return(1)
28
- delegate.should_receive(:close).and_return(nil)
24
+ delegate = MiniTest::Mock.new
25
+ delegate.expect(:write, 12, [String])
26
+ delegate.expect(:close, nil)
29
27
  Archive::Zip::Codec::TraditionalEncryption::Encrypt.open(
30
28
  delegate,
31
29
  TraditionalEncryptionSpecs.password,
32
30
  TraditionalEncryptionSpecs.mtime
33
31
  ) do |e|
34
- lambda { e.seek(0) }.should raise_error(Errno::EINVAL)
32
+ lambda { e.seek(0) }.must_raise(Errno::EINVAL)
35
33
  end
36
34
  end
37
35
 
@@ -43,8 +41,8 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#seek" do
43
41
  TraditionalEncryptionSpecs.mtime
44
42
  ) do |e|
45
43
  e.write('test')
46
- lambda { e.seek(1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
47
- lambda { e.seek(-1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
44
+ lambda { e.seek(1, IO::SEEK_CUR) }.must_raise(Errno::EINVAL)
45
+ lambda { e.seek(-1, IO::SEEK_CUR) }.must_raise(Errno::EINVAL)
48
46
  end
49
47
  end
50
48
 
@@ -55,8 +53,8 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#seek" do
55
53
  TraditionalEncryptionSpecs.password,
56
54
  TraditionalEncryptionSpecs.mtime
57
55
  ) do |e|
58
- lambda { e.seek(-1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
59
- lambda { e.seek(1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
56
+ lambda { e.seek(-1, IO::SEEK_SET) }.must_raise(Errno::EINVAL)
57
+ lambda { e.seek(1, IO::SEEK_SET) }.must_raise(Errno::EINVAL)
60
58
  end
61
59
  end
62
60
 
@@ -67,9 +65,9 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#seek" do
67
65
  TraditionalEncryptionSpecs.password,
68
66
  TraditionalEncryptionSpecs.mtime
69
67
  ) do |e|
70
- lambda { e.seek(0, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
71
- lambda { e.seek(-1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
72
- lambda { e.seek(1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
68
+ lambda { e.seek(0, IO::SEEK_END) }.must_raise(Errno::EINVAL)
69
+ lambda { e.seek(-1, IO::SEEK_END) }.must_raise(Errno::EINVAL)
70
+ lambda { e.seek(1, IO::SEEK_END) }.must_raise(Errno::EINVAL)
73
71
  end
74
72
  end
75
73
  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/traditional_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -13,30 +15,26 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#tell" do
13
15
  TraditionalEncryptionSpecs.password,
14
16
  TraditionalEncryptionSpecs.mtime
15
17
  ) do |e|
16
- e.tell.should == 0
18
+ e.tell.must_equal(0)
17
19
  e.write('test1')
18
- e.tell.should == 5
20
+ e.tell.must_equal(5)
19
21
  e.write('test2')
20
- e.tell.should == 10
22
+ e.tell.must_equal(10)
21
23
  e.rewind
22
- e.tell.should == 0
24
+ e.tell.must_equal(0)
23
25
  end
24
26
  end
25
27
 
26
28
  it "raises IOError on closed stream" do
27
- delegate = mock('delegate')
28
- # RSpec's mocking facility supposedly supports this, but MSpec's does not as
29
- # of version 1.5.10.
30
- #delegate.should_receive(:write).with(an_instance_of(String)).at_least(:once).and_return { |s| s.length }
31
- # Use the following instead for now.
32
- delegate.should_receive(:write).at_least(:once).and_return(1)
33
- delegate.should_receive(:close).once.and_return(nil)
29
+ delegate = MiniTest::Mock.new
30
+ delegate.expect(:write, 12, [String])
31
+ delegate.expect(:close, nil)
34
32
  lambda do
35
33
  Archive::Zip::Codec::TraditionalEncryption::Encrypt.open(
36
34
  delegate,
37
35
  TraditionalEncryptionSpecs.password,
38
36
  TraditionalEncryptionSpecs.mtime
39
37
  ) { |e| e }.tell
40
- end.should raise_error(IOError)
38
+ end.must_raise(IOError)
41
39
  end
42
40
  end
@@ -1,28 +1,13 @@
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/traditional_encryption'
6
8
  require 'archive/support/binary_stringio'
7
9
 
8
10
  describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#write" do
9
- it "calls the write method of the delegate" do
10
- delegate = mock('delegate')
11
- # RSpec's mocking facility supposedly supports this, but MSpec's does not as
12
- # of version 1.5.10.
13
- #delegate.should_receive(:write).with(an_instance_of(String)).at_least(:once).and_return { |s| s.length }
14
- # Use the following instead for now.
15
- delegate.should_receive(:write).at_least(:once).and_return(1)
16
- delegate.should_receive(:close).once.and_return(nil)
17
- Archive::Zip::Codec::TraditionalEncryption::Encrypt.open(
18
- delegate,
19
- TraditionalEncryptionSpecs.password,
20
- TraditionalEncryptionSpecs.mtime
21
- ) do |e|
22
- e.write(TraditionalEncryptionSpecs.test_data)
23
- end
24
- end
25
-
26
11
  it "writes encrypted data to the delegate" do
27
12
  # Ensure repeatable test data is used for encryption header.
28
13
  srand(0)
@@ -34,7 +19,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#write" do
34
19
  ) do |e|
35
20
  e.write(TraditionalEncryptionSpecs.test_data)
36
21
  end
37
- encrypted_data.string.should == TraditionalEncryptionSpecs.encrypted_data
22
+ encrypted_data.string.must_equal(TraditionalEncryptionSpecs.encrypted_data)
38
23
  end
39
24
 
40
25
  it "writes encrypted data to a delegate that only performs partial writes" do
@@ -56,7 +41,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#write" do
56
41
  ) do |e|
57
42
  e.write(TraditionalEncryptionSpecs.test_data)
58
43
  end
59
- encrypted_data.string.should == TraditionalEncryptionSpecs.encrypted_data
44
+ encrypted_data.string.must_equal(TraditionalEncryptionSpecs.encrypted_data)
60
45
  end
61
46
 
62
47
  it "writes encrypted data to a delegate that raises Errno::EAGAIN" do
@@ -89,7 +74,7 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#write" do
89
74
  retry
90
75
  end
91
76
  end
92
- encrypted_data.string.should == TraditionalEncryptionSpecs.encrypted_data
77
+ encrypted_data.string.must_equal(TraditionalEncryptionSpecs.encrypted_data)
93
78
  end
94
79
 
95
80
  it "writes encrypted data to a delegate that raises Errno::EINTR" do
@@ -122,6 +107,6 @@ describe "Archive::Zip::Codec::TraditionalEncryption::Encrypt#write" do
122
107
  retry
123
108
  end
124
109
  end
125
- encrypted_data.string.should == TraditionalEncryptionSpecs.encrypted_data
110
+ encrypted_data.string.must_equal(TraditionalEncryptionSpecs.encrypted_data)
126
111
  end
127
112
  end