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,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/support/zlib'
6
8
 
7
9
  describe "Zlib::ZReader#tell" do
8
10
  it "returns the current position of the stream" do
9
11
  ZlibSpecs.compressed_data do |cd|
10
12
  Zlib::ZReader.open(cd) do |zr|
11
- zr.tell.should == 0
13
+ zr.tell.must_equal 0
12
14
  zr.read(4)
13
- zr.tell.should == 4
15
+ zr.tell.must_equal 4
14
16
  zr.read
15
- zr.tell.should == 235
17
+ zr.tell.must_equal 235
16
18
  zr.rewind
17
- zr.tell.should == 0
19
+ zr.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/support/zlib'
6
8
 
7
9
  describe "Zlib::ZReader#uncompressed_size" do
@@ -9,10 +11,10 @@ describe "Zlib::ZReader#uncompressed_size" do
9
11
  closed_zr = ZlibSpecs.compressed_data_raw do |compressed_data|
10
12
  Zlib::ZReader.open(compressed_data, -15) do |zr|
11
13
  zr.read
12
- zr.uncompressed_size.should == 235
14
+ zr.uncompressed_size.must_equal 235
13
15
  zr
14
16
  end
15
17
  end
16
- closed_zr.uncompressed_size.should == 235
18
+ closed_zr.uncompressed_size.must_equal 235
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/support/zlib'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -11,10 +13,10 @@ describe "Zlib::ZWriter#checksum" do
11
13
  closed_zw = Zlib::ZWriter.open(compressed_data, nil, 15) do |zw|
12
14
  zw.write(ZlibSpecs.test_data)
13
15
  zw.flush
14
- zw.checksum.should == Zlib.adler32(ZlibSpecs.test_data)
16
+ zw.checksum.must_equal Zlib.adler32(ZlibSpecs.test_data)
15
17
  zw
16
18
  end
17
- closed_zw.checksum.should == Zlib.adler32(ZlibSpecs.test_data)
19
+ closed_zw.checksum.must_equal Zlib.adler32(ZlibSpecs.test_data)
18
20
  end
19
21
 
20
22
  it "computes the CRC32 checksum of gzip formatted data" do
@@ -22,10 +24,10 @@ describe "Zlib::ZWriter#checksum" do
22
24
  closed_zw = Zlib::ZWriter.open(compressed_data, nil, 31) do |zw|
23
25
  zw.write(ZlibSpecs.test_data)
24
26
  zw.flush
25
- zw.checksum.should == Zlib.crc32(ZlibSpecs.test_data)
27
+ zw.checksum.must_equal Zlib.crc32(ZlibSpecs.test_data)
26
28
  zw
27
29
  end
28
- closed_zw.checksum.should == Zlib.crc32(ZlibSpecs.test_data)
30
+ closed_zw.checksum.must_equal Zlib.crc32(ZlibSpecs.test_data)
29
31
  end
30
32
 
31
33
  it "does not compute a checksum for raw zlib data" do
@@ -33,9 +35,9 @@ describe "Zlib::ZWriter#checksum" do
33
35
  closed_zw = Zlib::ZWriter.open(compressed_data, nil, -15) do |zw|
34
36
  zw.write(ZlibSpecs.test_data)
35
37
  zw.flush
36
- zw.checksum.should == nil
38
+ zw.checksum.must_equal nil
37
39
  zw
38
40
  end
39
- closed_zw.checksum.should == nil
41
+ closed_zw.checksum.must_equal nil
40
42
  end
41
43
  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/support/zlib'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -9,6 +11,6 @@ describe "Zlib::ZWriter.close" do
9
11
  it "closes the stream" do
10
12
  zw = Zlib::ZWriter.new(BinaryStringIO.new)
11
13
  zw.close
12
- zw.closed?.should be_true
14
+ zw.closed?.must_equal true
13
15
  end
14
16
  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/support/zlib'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -11,9 +13,9 @@ describe "Zlib::ZWriter#compressed_size" do
11
13
  closed_zw = Zlib::ZWriter.open(compressed_data, nil, -15) do |zw|
12
14
  zw.sync = true
13
15
  zw.write(ZlibSpecs.test_data)
14
- zw.compressed_size.should >= 0
16
+ zw.compressed_size.must_be :>=, 0
15
17
  zw
16
18
  end
17
- closed_zw.compressed_size.should == 160
19
+ closed_zw.compressed_size.must_equal 160
18
20
  end
19
21
  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/support/zlib'
6
8
  require 'archive/support/binary_stringio'
7
9
 
8
10
  describe "Zlib::ZWriter.new" do
9
11
  it "returns a new instance" do
10
12
  zw = Zlib::ZWriter.new(BinaryStringIO.new)
11
- zw.class.should == Zlib::ZWriter
13
+ zw.class.must_equal Zlib::ZWriter
12
14
  zw.close
13
15
  end
14
16
 
@@ -19,7 +21,7 @@ describe "Zlib::ZWriter.new" do
19
21
  zw.write(data)
20
22
  zw.close
21
23
 
22
- compressed_data.string.should == ZlibSpecs.compressed_data
24
+ compressed_data.string.must_equal ZlibSpecs.compressed_data
23
25
  end
24
26
 
25
27
  it "allows level to be set" do
@@ -29,7 +31,7 @@ describe "Zlib::ZWriter.new" do
29
31
  zw.write(data)
30
32
  zw.close
31
33
 
32
- compressed_data.string.should == ZlibSpecs.compressed_data_nocomp
34
+ compressed_data.string.must_equal ZlibSpecs.compressed_data_nocomp
33
35
  end
34
36
 
35
37
  it "allows window_bits to be set" do
@@ -39,7 +41,7 @@ describe "Zlib::ZWriter.new" do
39
41
  zw.write(data)
40
42
  zw.close
41
43
 
42
- compressed_data.string.should == ZlibSpecs.compressed_data_minwin
44
+ compressed_data.string.must_equal ZlibSpecs.compressed_data_minwin
43
45
  end
44
46
 
45
47
  it "allows mem_level to be set" do
@@ -49,7 +51,7 @@ describe "Zlib::ZWriter.new" do
49
51
  zw.write(data)
50
52
  zw.close
51
53
 
52
- compressed_data.string.should == ZlibSpecs.compressed_data_minmem
54
+ compressed_data.string.must_equal ZlibSpecs.compressed_data_minmem
53
55
  end
54
56
 
55
57
  it "allows strategy to be set" do
@@ -59,6 +61,6 @@ describe "Zlib::ZWriter.new" do
59
61
  zw.write(data)
60
62
  zw.close
61
63
 
62
- compressed_data.string.should == ZlibSpecs.compressed_data_huffman
64
+ compressed_data.string.must_equal ZlibSpecs.compressed_data_huffman
63
65
  end
64
66
  end
@@ -1,23 +1,25 @@
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/support/zlib'
6
8
  require 'archive/support/binary_stringio'
7
9
 
8
10
  describe "Zlib::ZWriter.open" do
9
11
  it "returns a new instance when run without a block" do
10
12
  zw = Zlib::ZWriter.open(BinaryStringIO.new)
11
- zw.class.should == Zlib::ZWriter
13
+ zw.class.must_equal Zlib::ZWriter
12
14
  zw.close
13
15
  end
14
16
 
15
17
  it "executes a block with a new instance as an argument" do
16
- Zlib::ZWriter.open(BinaryStringIO.new) { |zr| zr.class.should == Zlib::ZWriter }
18
+ Zlib::ZWriter.open(BinaryStringIO.new) { |zr| zr.class.must_equal Zlib::ZWriter }
17
19
  end
18
20
 
19
21
  it "closes the object after executing a block" do
20
- Zlib::ZWriter.open(BinaryStringIO.new) { |zr| zr }.closed?.should.be_true
22
+ Zlib::ZWriter.open(BinaryStringIO.new) { |zr| zr }.closed?.must_equal true
21
23
  end
22
24
 
23
25
  it "provides default settings for level, window_bits, mem_level, and strategy" do
@@ -25,7 +27,7 @@ describe "Zlib::ZWriter.open" do
25
27
  compressed_data = BinaryStringIO.new
26
28
  Zlib::ZWriter.open(compressed_data) { |zw| zw.write(data) }
27
29
 
28
- compressed_data.string.should == ZlibSpecs.compressed_data
30
+ compressed_data.string.must_equal ZlibSpecs.compressed_data
29
31
  end
30
32
 
31
33
  it "allows level to be set" do
@@ -35,7 +37,7 @@ describe "Zlib::ZWriter.open" do
35
37
  zw.write(data)
36
38
  end
37
39
 
38
- compressed_data.string.should == ZlibSpecs.compressed_data_nocomp
40
+ compressed_data.string.must_equal ZlibSpecs.compressed_data_nocomp
39
41
  end
40
42
 
41
43
  it "allows window_bits to be set" do
@@ -43,7 +45,7 @@ describe "Zlib::ZWriter.open" do
43
45
  compressed_data = BinaryStringIO.new
44
46
  Zlib::ZWriter.open(compressed_data, nil, 8) { |zw| zw.write(data) }
45
47
 
46
- compressed_data.string.should == ZlibSpecs.compressed_data_minwin
48
+ compressed_data.string.must_equal ZlibSpecs.compressed_data_minwin
47
49
  end
48
50
 
49
51
  it "allows mem_level to be set" do
@@ -51,7 +53,7 @@ describe "Zlib::ZWriter.open" do
51
53
  compressed_data = BinaryStringIO.new
52
54
  Zlib::ZWriter.open(compressed_data, nil, nil, 1) { |zw| zw.write(data) }
53
55
 
54
- compressed_data.string.should == ZlibSpecs.compressed_data_minmem
56
+ compressed_data.string.must_equal ZlibSpecs.compressed_data_minmem
55
57
  end
56
58
 
57
59
  it "allows strategy to be set" do
@@ -63,6 +65,6 @@ describe "Zlib::ZWriter.open" do
63
65
  zw.write(data)
64
66
  end
65
67
 
66
- compressed_data.string.should == ZlibSpecs.compressed_data_huffman
68
+ compressed_data.string.must_equal ZlibSpecs.compressed_data_huffman
67
69
  end
68
70
  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/support/zlib'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -10,17 +12,17 @@ describe "Zlib::ZWriter#rewind" do
10
12
  sio = BinaryStringIO.new
11
13
  Zlib::ZWriter.open(sio) do |zw|
12
14
  zw.write('test')
13
- lambda { zw.rewind }.should_not raise_error
15
+ zw.rewind
14
16
  zw.write(ZlibSpecs.test_data)
15
17
  end
16
- sio.string.should == ZlibSpecs.compressed_data
18
+ sio.string.must_equal ZlibSpecs.compressed_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(:write).at_least(:once).and_return(1)
22
+ delegate = MiniTest::Mock.new
23
+ delegate.expect(:write, 8, [String])
22
24
  Zlib::ZWriter.open(delegate) do |zw|
23
- lambda { zw.rewind }.should raise_error(Errno::EINVAL)
25
+ lambda { zw.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/support/zlib'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -10,19 +12,15 @@ describe "Zlib::ZWriter#seek" do
10
12
  compressed_data = BinaryStringIO.new
11
13
  Zlib::ZWriter.open(compressed_data) do |c|
12
14
  c.write('test')
13
- lambda { c.seek(0) }.should_not raise_error
15
+ c.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
- # RSpec's mocking facility supposedly supports this, but MSpec's does not as
20
- # of version 1.5.10.
21
- #delegate.should_receive(:write).with(an_instance_of(String)).at_least(:once).and_return { |s| s.length }
22
- # Use the following instead for now.
23
- delegate.should_receive(:write).at_least(:once).and_return(1)
20
+ delegate = MiniTest::Mock.new
21
+ delegate.expect(:write, 8, [String])
24
22
  Zlib::ZWriter.open(delegate) do |c|
25
- lambda { c.seek(0) }.should raise_error(Errno::EINVAL)
23
+ lambda { c.seek(0) }.must_raise Errno::EINVAL
26
24
  end
27
25
  end
28
26
 
@@ -30,25 +28,25 @@ describe "Zlib::ZWriter#seek" do
30
28
  compressed_data = BinaryStringIO.new
31
29
  Zlib::ZWriter.open(compressed_data) do |c|
32
30
  c.write('test')
33
- lambda { c.seek(1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
34
- lambda { c.seek(-1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
31
+ lambda { c.seek(1, IO::SEEK_CUR) }.must_raise Errno::EINVAL
32
+ lambda { c.seek(-1, IO::SEEK_CUR) }.must_raise Errno::EINVAL
35
33
  end
36
34
  end
37
35
 
38
36
  it "raises Errno::EINVAL when seeking a non-zero offset relative to the beginning of the stream" do
39
37
  compressed_data = BinaryStringIO.new
40
38
  Zlib::ZWriter.open(compressed_data) do |c|
41
- lambda { c.seek(-1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
42
- lambda { c.seek(1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
39
+ lambda { c.seek(-1, IO::SEEK_SET) }.must_raise Errno::EINVAL
40
+ lambda { c.seek(1, IO::SEEK_SET) }.must_raise Errno::EINVAL
43
41
  end
44
42
  end
45
43
 
46
44
  it "raises Errno::EINVAL when seeking relative to the end of the stream" do
47
45
  compressed_data = BinaryStringIO.new
48
46
  Zlib::ZWriter.open(compressed_data) do |c|
49
- lambda { c.seek(0, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
50
- lambda { c.seek(-1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
51
- lambda { c.seek(1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
47
+ lambda { c.seek(0, IO::SEEK_END) }.must_raise Errno::EINVAL
48
+ lambda { c.seek(-1, IO::SEEK_END) }.must_raise Errno::EINVAL
49
+ lambda { c.seek(1, IO::SEEK_END) }.must_raise Errno::EINVAL
52
50
  end
53
51
  end
54
52
  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/support/zlib'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -9,21 +11,21 @@ describe "Zlib::ZWriter#tell" do
9
11
  it "returns the current position of the stream" do
10
12
  sio = BinaryStringIO.new
11
13
  Zlib::ZWriter.open(sio) do |zw|
12
- zw.tell.should == 0
14
+ zw.tell.must_equal 0
13
15
  zw.write('test1')
14
- zw.tell.should == 5
16
+ zw.tell.must_equal 5
15
17
  zw.write('test2')
16
- zw.tell.should == 10
18
+ zw.tell.must_equal 10
17
19
  zw.rewind
18
- zw.tell.should == 0
20
+ zw.tell.must_equal 0
19
21
  end
20
22
  end
21
23
 
22
24
  it "raises IOError on closed stream" do
23
- delegate = mock('delegate')
24
- delegate.should_receive(:write).at_least(:once).and_return(1)
25
+ delegate = MiniTest::Mock.new
26
+ delegate.expect(:write, 8, [String])
25
27
  lambda do
26
28
  Zlib::ZWriter.open(delegate) { |zw| zw }.tell
27
- end.should raise_error(IOError)
29
+ end.must_raise IOError
28
30
  end
29
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/support/zlib'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -11,9 +13,9 @@ describe "Zlib::ZWriter#uncompressed_size" do
11
13
  closed_zw = Zlib::ZWriter.open(compressed_data, nil, -15) do |zw|
12
14
  zw.sync = true
13
15
  zw.write(ZlibSpecs.test_data)
14
- zw.uncompressed_size.should == 235
16
+ zw.uncompressed_size.must_equal 235
15
17
  zw
16
18
  end
17
- closed_zw.uncompressed_size.should == 235
19
+ closed_zw.uncompressed_size.must_equal 235
18
20
  end
19
21
  end