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.
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,34 +1,40 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require 'minitest/autorun'
4
+
4
5
  require 'archive/support/binary_stringio'
5
6
 
6
7
  describe "BinaryStringIO.new" do
7
8
  it "returns a new instance" do
8
9
  io = BinaryStringIO.new
9
- io.class.should == BinaryStringIO
10
+ io.must_be_instance_of BinaryStringIO
10
11
  io.close
11
12
  end
12
13
 
13
14
  it "creates a decendent of StringIO" do
14
15
  io = BinaryStringIO.new
15
- io.should be_kind_of StringIO
16
+ io.must_be_kind_of StringIO
16
17
  io.close
17
18
  end
18
19
 
20
+ # TODO:
21
+ # This is lame. Break this out as augmentation for the "returns a new
22
+ # instance" test.
19
23
  it "takes the same arguments as StringIO.new" do
20
- lambda { BinaryStringIO.new }.should_not raise_error(ArgumentError)
21
- lambda { BinaryStringIO.new('') }.should_not raise_error(ArgumentError)
22
- lambda { BinaryStringIO.new('', 'r') }.should_not raise_error(ArgumentError)
23
- lambda { BinaryStringIO.new('', 'w') }.should_not raise_error(ArgumentError)
24
+ BinaryStringIO.new.must_be_instance_of BinaryStringIO
25
+ BinaryStringIO.new('').must_be_instance_of BinaryStringIO
26
+ BinaryStringIO.new('', 'r').must_be_instance_of BinaryStringIO
27
+ BinaryStringIO.new('', 'w').must_be_instance_of BinaryStringIO
24
28
 
25
- lambda { BinaryStringIO.new('', 'w', 42) }.should raise_error(ArgumentError)
29
+ lambda { BinaryStringIO.new('', 'w', 42) }.must_raise ArgumentError
26
30
  end
27
31
 
28
- with_feature :encoding do
29
- it "sets the external encoding to binary" do
30
- io = BinaryStringIO.new
31
- io.external_encoding.should == Encoding::ASCII_8BIT
32
+ it "sets the external encoding to binary" do
33
+ unless Object.const_defined?(:Encoding)
34
+ skip("Encoding methods are not supported on current Ruby (#{RUBY_DESCRIPTION})")
32
35
  end
36
+
37
+ io = BinaryStringIO.new
38
+ io.external_encoding.must_equal Encoding::ASCII_8BIT
33
39
  end
34
40
  end
@@ -1,14 +1,17 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require 'minitest/autorun'
4
+
4
5
  require 'archive/support/binary_stringio'
5
6
 
6
- with_feature :encoding do
7
- describe "BinaryStringIO#set_encoding" do
8
- it "should be private" do
9
- lambda do
10
- BinaryStringIO.new.set_encoding('utf-8')
11
- end.should raise_error(NoMethodError)
7
+ describe "BinaryStringIO#set_encoding" do
8
+ it "raises an exception when called" do
9
+ unless Object.const_defined?(:Encoding)
10
+ skip("Encoding methods are not supported on current Ruby (#{RUBY_DESCRIPTION})")
12
11
  end
12
+
13
+ lambda do
14
+ BinaryStringIO.new.set_encoding('utf-8')
15
+ end.must_raise RuntimeError
13
16
  end
14
17
  end
@@ -1,50 +1,52 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../spec_helper'
3
+ require 'minitest/autorun'
4
+
4
5
  require 'archive/support/ioextensions.rb'
5
6
  require 'archive/support/binary_stringio'
6
7
 
7
8
  describe "IOExtensions.read_exactly" do
8
9
  it "reads and returns length bytes from a given IO object" do
9
10
  io = BinaryStringIO.new('This is test data')
10
- IOExtensions.read_exactly(io, 4).should == 'This'
11
- IOExtensions.read_exactly(io, 13).should == ' is test data'
11
+ IOExtensions.read_exactly(io, 4).must_equal 'This'
12
+ IOExtensions.read_exactly(io, 13).must_equal ' is test data'
12
13
  end
13
14
 
14
15
  it "raises an error when too little data is available" do
15
16
  io = BinaryStringIO.new('This is test data')
16
17
  lambda do
17
18
  IOExtensions.read_exactly(io, 18)
18
- end.should raise_error(EOFError)
19
+ end.must_raise EOFError
19
20
  end
20
21
 
21
22
  it "takes an optional buffer argument and fills it" do
22
23
  io = BinaryStringIO.new('This is test data')
23
24
  buffer = ''
24
25
  IOExtensions.read_exactly(io, 4, buffer)
25
- buffer.should == 'This'
26
+ buffer.must_equal 'This'
26
27
  buffer = ''
27
28
  IOExtensions.read_exactly(io, 13, buffer)
28
- buffer.should == ' is test data'
29
+ buffer.must_equal ' is test data'
29
30
  end
30
31
 
31
32
  it "empties the optional buffer before filling it" do
32
33
  io = BinaryStringIO.new('This is test data')
33
34
  buffer = ''
34
35
  IOExtensions.read_exactly(io, 4, buffer)
35
- buffer.should == 'This'
36
+ buffer.must_equal 'This'
36
37
  IOExtensions.read_exactly(io, 13, buffer)
37
- buffer.should == ' is test data'
38
+ buffer.must_equal ' is test data'
38
39
  end
39
40
 
40
41
  it "can read 0 bytes" do
41
42
  io = BinaryStringIO.new('This is test data')
42
- IOExtensions.read_exactly(io, 0).should == ''
43
+ IOExtensions.read_exactly(io, 0).must_equal ''
43
44
  end
44
45
 
45
46
  it "retries partial reads" do
46
- io = mock('io')
47
- io.should_receive(:read).exactly(2).and_return('hello')
48
- IOExtensions.read_exactly(io, 10).should == 'hellohello'
47
+ io = MiniTest::Mock.new
48
+ io.expect(:read, 'hello', [10])
49
+ io.expect(:read, 'hello', [5])
50
+ IOExtensions.read_exactly(io, 10).must_equal 'hellohello'
49
51
  end
50
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
 
7
9
  describe "Zlib::ZReader#checksum" do
@@ -9,32 +11,32 @@ describe "Zlib::ZReader#checksum" do
9
11
  closed_zr = ZlibSpecs.compressed_data do |f|
10
12
  Zlib::ZReader.open(f, 15) do |zr|
11
13
  zr.read
12
- zr.checksum.should == Zlib.adler32(ZlibSpecs.test_data)
14
+ zr.checksum.must_equal Zlib.adler32(ZlibSpecs.test_data)
13
15
  zr
14
16
  end
15
17
  end
16
- closed_zr.checksum.should == Zlib.adler32(ZlibSpecs.test_data)
18
+ closed_zr.checksum.must_equal Zlib.adler32(ZlibSpecs.test_data)
17
19
  end
18
20
 
19
21
  it "computes the CRC32 checksum of gzip formatted data" do
20
22
  closed_zr = ZlibSpecs.compressed_data_gzip do |f|
21
23
  Zlib::ZReader.open(f, 31) do |zr|
22
24
  zr.read
23
- zr.checksum.should == Zlib.crc32(ZlibSpecs.test_data)
25
+ zr.checksum.must_equal Zlib.crc32(ZlibSpecs.test_data)
24
26
  zr
25
27
  end
26
28
  end
27
- closed_zr.checksum.should == Zlib.crc32(ZlibSpecs.test_data)
29
+ closed_zr.checksum.must_equal Zlib.crc32(ZlibSpecs.test_data)
28
30
  end
29
31
 
30
32
  it "does not compute a checksum for raw zlib data" do
31
33
  closed_zr = ZlibSpecs.compressed_data_raw do |f|
32
34
  Zlib::ZReader.open(f, -15) do |zr|
33
35
  zr.read
34
- zr.checksum.should == nil
36
+ zr.checksum.must_equal nil
35
37
  zr
36
38
  end
37
39
  end
38
- closed_zr.checksum.should == nil
40
+ closed_zr.checksum.must_equal nil
39
41
  end
40
42
  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::ZReader.close" do
9
11
  it "closes the stream" do
10
12
  zr = Zlib::ZReader.new(BinaryStringIO.new)
11
13
  zr.close
12
- zr.closed?.should be_true
14
+ zr.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
 
7
9
  describe "Zlib::ZReader#compressed_size" do
@@ -9,10 +11,10 @@ describe "Zlib::ZReader#compressed_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.compressed_size.should == 160
14
+ zr.compressed_size.must_equal 160
13
15
  zr
14
16
  end
15
17
  end
16
- closed_zr.compressed_size.should == 160
18
+ closed_zr.compressed_size.must_equal 160
17
19
  end
18
20
  end
@@ -1,13 +1,15 @@
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::ZReader.new" do
9
11
  it "returns a new instance" do
10
- Zlib::ZReader.new(BinaryStringIO.new).class.should == Zlib::ZReader
12
+ Zlib::ZReader.new(BinaryStringIO.new).class.must_equal Zlib::ZReader
11
13
  end
12
14
 
13
15
  it "does not require window_bits to be set" do
@@ -19,7 +21,7 @@ describe "Zlib::ZReader.new" do
19
21
  compressed_data.rewind
20
22
 
21
23
  zr = Zlib::ZReader.new(compressed_data)
22
- zr.read.should == data
24
+ zr.read.must_equal data
23
25
  zr.close
24
26
  end
25
27
 
@@ -35,7 +37,7 @@ describe "Zlib::ZReader.new" do
35
37
  compressed_data.rewind
36
38
 
37
39
  zr = Zlib::ZReader.new(compressed_data, window_bits)
38
- zr.read.should == data
40
+ zr.read.must_equal data
39
41
  zr.close
40
42
  end
41
43
  end
@@ -1,21 +1,23 @@
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::ZReader.open" do
9
11
  it "returns a new instance when run without a block" do
10
- Zlib::ZReader.open(BinaryStringIO.new).class.should == Zlib::ZReader
12
+ Zlib::ZReader.open(BinaryStringIO.new).class.must_equal Zlib::ZReader
11
13
  end
12
14
 
13
15
  it "executes a block with a new instance as an argument" do
14
- Zlib::ZReader.open(BinaryStringIO.new) { |zr| zr.class.should == Zlib::ZReader }
16
+ Zlib::ZReader.open(BinaryStringIO.new) { |zr| zr.class.must_equal Zlib::ZReader }
15
17
  end
16
18
 
17
19
  it "closes the object after executing a block" do
18
- Zlib::ZReader.open(BinaryStringIO.new) { |zr| zr }.closed?.should.be_true
20
+ Zlib::ZReader.open(BinaryStringIO.new) { |zr| zr }.closed?.must_equal true
19
21
  end
20
22
 
21
23
  it "does not require window_bits to be set" do
@@ -27,7 +29,7 @@ describe "Zlib::ZReader.open" do
27
29
  compressed_data.rewind
28
30
 
29
31
  Zlib::ZReader.open(compressed_data) do |zr|
30
- zr.read.should == data
32
+ zr.read.must_equal data
31
33
  end
32
34
  end
33
35
 
@@ -43,7 +45,7 @@ describe "Zlib::ZReader.open" do
43
45
  compressed_data.rewind
44
46
 
45
47
  Zlib::ZReader.open(compressed_data, window_bits) do |zr|
46
- zr.read.should == data
48
+ zr.read.must_equal data
47
49
  end
48
50
  end
49
51
  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::ZReader#read" do
9
11
  it "calls the read method of the delegate" do
10
- delegate = mock('delegate')
11
- delegate.should_receive(:read).and_return(nil)
12
+ delegate = MiniTest::Mock.new
13
+ delegate.expect(:read, nil, [Integer])
12
14
  Zlib::ZReader.open(delegate) do |zr|
13
15
  # Capture and ignore the Zlib::BufError which is generated due to mocking.
14
16
  begin
@@ -21,27 +23,27 @@ describe "Zlib::ZReader#read" do
21
23
  it "decompresses compressed data" do
22
24
  ZlibSpecs.compressed_data do |cd|
23
25
  Zlib::ZReader.open(cd) do |zr|
24
- zr.read.should == ZlibSpecs.test_data
26
+ zr.read.must_equal ZlibSpecs.test_data
25
27
  end
26
28
  end
27
29
  end
28
30
 
29
31
  it "raises Zlib::DataError when reading invalid data" do
30
32
  Zlib::ZReader.open(BinaryStringIO.new('This is not compressed data')) do |zr|
31
- lambda { zr.read }.should raise_error(Zlib::DataError)
33
+ lambda { zr.read }.must_raise Zlib::DataError
32
34
  end
33
35
  end
34
36
 
35
37
  it "raises Zlib::BufError when reading truncated data" do
36
38
  truncated_data = ZlibSpecs.compressed_data { |cd| cd.read(100) }
37
39
  Zlib::ZReader.open(BinaryStringIO.new(truncated_data)) do |zr|
38
- lambda { zr.read }.should raise_error(Zlib::BufError)
40
+ lambda { zr.read }.must_raise Zlib::BufError
39
41
  end
40
42
  end
41
43
 
42
44
  it "raises Zlib::BufError when reading empty data" do
43
45
  Zlib::ZReader.open(BinaryStringIO.new()) do |zr|
44
- lambda { zr.read }.should raise_error(Zlib::BufError)
46
+ lambda { zr.read }.must_raise Zlib::BufError
45
47
  end
46
48
  end
47
49
  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#rewind" do
@@ -9,15 +11,15 @@ describe "Zlib::ZReader#rewind" do
9
11
  ZlibSpecs.compressed_data do |cd|
10
12
  Zlib::ZReader.open(cd) do |zr|
11
13
  zr.read(4)
12
- lambda { zr.rewind }.should_not raise_error
13
- zr.read.should == ZlibSpecs.test_data
14
+ zr.rewind
15
+ zr.read.must_equal ZlibSpecs.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
21
  Zlib::ZReader.open(Object.new) do |zr|
20
- lambda { zr.rewind }.should raise_error(Errno::EINVAL)
22
+ lambda { zr.rewind }.must_raise Errno::EINVAL
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/support/zlib'
6
8
 
7
9
  describe "Zlib::ZReader#seek" do
@@ -9,14 +11,14 @@ describe "Zlib::ZReader#seek" do
9
11
  ZlibSpecs.compressed_data do |cd|
10
12
  Zlib::ZReader.open(cd) do |zr|
11
13
  zr.read(4)
12
- lambda { zr.seek(0) }.should_not raise_error
14
+ zr.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
20
  Zlib::ZReader.open(Object.new) do |zr|
19
- lambda { zr.seek(0) }.should raise_error(Errno::EINVAL)
21
+ lambda { zr.seek(0) }.must_raise Errno::EINVAL
20
22
  end
21
23
  end
22
24
 
@@ -28,8 +30,8 @@ describe "Zlib::ZReader#seek" do
28
30
  zr.fill_size = 0
29
31
 
30
32
  zr.read(4)
31
- lambda { zr.seek(1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
32
- lambda { zr.seek(-1, IO::SEEK_CUR) }.should raise_error(Errno::EINVAL)
33
+ lambda { zr.seek(1, IO::SEEK_CUR) }.must_raise Errno::EINVAL
34
+ lambda { zr.seek(-1, IO::SEEK_CUR) }.must_raise Errno::EINVAL
33
35
  end
34
36
  end
35
37
  end
@@ -37,8 +39,8 @@ describe "Zlib::ZReader#seek" do
37
39
  it "raises Errno::EINVAL when seeking a non-zero offset relative to the beginning of the stream" do
38
40
  ZlibSpecs.compressed_data do |cd|
39
41
  Zlib::ZReader.open(cd) do |zr|
40
- lambda { zr.seek(-1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
41
- lambda { zr.seek(1, IO::SEEK_SET) }.should raise_error(Errno::EINVAL)
42
+ lambda { zr.seek(-1, IO::SEEK_SET) }.must_raise Errno::EINVAL
43
+ lambda { zr.seek(1, IO::SEEK_SET) }.must_raise Errno::EINVAL
42
44
  end
43
45
  end
44
46
  end
@@ -46,9 +48,9 @@ describe "Zlib::ZReader#seek" do
46
48
  it "raises Errno::EINVAL when seeking relative to the end of the stream" do
47
49
  ZlibSpecs.compressed_data do |cd|
48
50
  Zlib::ZReader.open(cd) do |zr|
49
- lambda { zr.seek(0, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
50
- lambda { zr.seek(-1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
51
- lambda { zr.seek(1, IO::SEEK_END) }.should raise_error(Errno::EINVAL)
51
+ lambda { zr.seek(0, IO::SEEK_END) }.must_raise Errno::EINVAL
52
+ lambda { zr.seek(-1, IO::SEEK_END) }.must_raise Errno::EINVAL
53
+ lambda { zr.seek(1, IO::SEEK_END) }.must_raise Errno::EINVAL
52
54
  end
53
55
  end
54
56
  end