summaryrefslogtreecommitdiff
path: root/spec/ruby/library/zlib
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/zlib')
-rw-r--r--spec/ruby/library/zlib/adler32_spec.rb2
-rw-r--r--spec/ruby/library/zlib/crc32_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipfile/close_spec.rb6
-rw-r--r--spec/ruby/library/zlib/gzipfile/comment_spec.rb3
-rw-r--r--spec/ruby/library/zlib/gzipfile/orig_name_spec.rb3
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_char_spec.rb51
-rw-r--r--spec/ruby/library/zlib/gzipreader/eof_spec.rb22
-rw-r--r--spec/ruby/library/zlib/gzipreader/getc_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/gets_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/read_spec.rb6
-rw-r--r--spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipreader/ungetc_spec.rb12
-rw-r--r--spec/ruby/library/zlib/gzipwriter/append_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipwriter/mtime_spec.rb3
-rw-r--r--spec/ruby/library/zlib/inflate/append_spec.rb2
-rw-r--r--spec/ruby/library/zlib/inflate/finish_spec.rb2
-rw-r--r--spec/ruby/library/zlib/inflate/inflate_spec.rb4
-rw-r--r--spec/ruby/library/zlib/inflate/set_dictionary_spec.rb2
-rw-r--r--spec/ruby/library/zlib/zlib_version_spec.rb2
19 files changed, 89 insertions, 43 deletions
diff --git a/spec/ruby/library/zlib/adler32_spec.rb b/spec/ruby/library/zlib/adler32_spec.rb
index 226aa18522..887c22d059 100644
--- a/spec/ruby/library/zlib/adler32_spec.rb
+++ b/spec/ruby/library/zlib/adler32_spec.rb
@@ -19,7 +19,7 @@ describe "Zlib.adler32" do
Zlib.adler32(test_string, 1).should == 66391324
Zlib.adler32(test_string, 2**8).should == 701435419
Zlib.adler32(test_string, 2**16).should == 63966491
- -> { Zlib.adler32(test_string, 2**128) }.should raise_error(RangeError)
+ -> { Zlib.adler32(test_string, 2**128) }.should.raise(RangeError)
end
it "calculates the Adler checksum for string and initial Adler value for Integers" do
diff --git a/spec/ruby/library/zlib/crc32_spec.rb b/spec/ruby/library/zlib/crc32_spec.rb
index d5f5c199cc..b94b5c627c 100644
--- a/spec/ruby/library/zlib/crc32_spec.rb
+++ b/spec/ruby/library/zlib/crc32_spec.rb
@@ -26,7 +26,7 @@ describe "Zlib.crc32" do
Zlib.crc32(test_string, 2**16).should == 1932511220
Zlib.crc32("p", ~305419896).should == 4046865307
Zlib.crc32("p", -305419897).should == 4046865307
- -> { Zlib.crc32(test_string, 2**128) }.should raise_error(RangeError)
+ -> { Zlib.crc32(test_string, 2**128) }.should.raise(RangeError)
end
it "calculates the CRC checksum for string and initial CRC value for Integers" do
diff --git a/spec/ruby/library/zlib/gzipfile/close_spec.rb b/spec/ruby/library/zlib/gzipfile/close_spec.rb
index 964b5ffb4d..07bafac961 100644
--- a/spec/ruby/library/zlib/gzipfile/close_spec.rb
+++ b/spec/ruby/library/zlib/gzipfile/close_spec.rb
@@ -10,10 +10,8 @@ describe "Zlib::GzipFile#close" do
gzio.should.closed?
- -> { gzio.orig_name }.should \
- raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
- -> { gzio.comment }.should \
- raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
+ -> { gzio.orig_name }.should.raise(Zlib::GzipFile::Error, 'closed gzip stream')
+ -> { gzio.comment }.should.raise(Zlib::GzipFile::Error, 'closed gzip stream')
end
io.string[10..-1].should == ([3] + Array.new(9,0)).pack('C*')
diff --git a/spec/ruby/library/zlib/gzipfile/comment_spec.rb b/spec/ruby/library/zlib/gzipfile/comment_spec.rb
index 70d97ecaf6..845224df98 100644
--- a/spec/ruby/library/zlib/gzipfile/comment_spec.rb
+++ b/spec/ruby/library/zlib/gzipfile/comment_spec.rb
@@ -19,8 +19,7 @@ describe "Zlib::GzipFile#comment" do
Zlib::GzipWriter.wrap @io do |gzio|
gzio.close
- -> { gzio.comment }.should \
- raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
+ -> { gzio.comment }.should.raise(Zlib::GzipFile::Error, 'closed gzip stream')
end
end
end
diff --git a/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb b/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb
index ebfd3692af..1da375390b 100644
--- a/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb
+++ b/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb
@@ -19,8 +19,7 @@ describe "Zlib::GzipFile#orig_name" do
Zlib::GzipWriter.wrap @io do |gzio|
gzio.close
- -> { gzio.orig_name }.should \
- raise_error(Zlib::GzipFile::Error, 'closed gzip stream')
+ -> { gzio.orig_name }.should.raise(Zlib::GzipFile::Error, 'closed gzip stream')
end
end
end
diff --git a/spec/ruby/library/zlib/gzipreader/each_char_spec.rb b/spec/ruby/library/zlib/gzipreader/each_char_spec.rb
new file mode 100644
index 0000000000..de6396da7e
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipreader/each_char_spec.rb
@@ -0,0 +1,51 @@
+require_relative '../../../spec_helper'
+require 'stringio'
+require 'zlib'
+
+describe "Zlib::GzipReader#each_char" do
+
+ before :each do
+ @data = '12345abcde'
+ @zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77,
+ 76, 74, 78, 73, 5, 0, 157, 5, 0, 36, 10, 0, 0, 0].pack('C*')
+
+ @io = StringIO.new @zip
+ ScratchPad.clear
+ end
+
+ it "calls the given block for each char in the stream, passing the char as an argument" do
+ gz = Zlib::GzipReader.new @io
+
+ ScratchPad.record []
+ gz.each_char { |b| ScratchPad << b }
+
+ ScratchPad.recorded.should == ["1", "2", "3", "4", "5", "a", "b", "c", "d", "e"]
+ end
+
+ it "returns an enumerator, which yields each char in the stream, when no block is passed" do
+ gz = Zlib::GzipReader.new @io
+ enum = gz.each_char
+
+ ScratchPad.record []
+ while true
+ begin
+ ScratchPad << enum.next
+ rescue StopIteration
+ break
+ end
+ end
+
+ ScratchPad.recorded.should == ["1", "2", "3", "4", "5", "a", "b", "c", "d", "e"]
+ end
+
+ it "increments position before calling the block" do
+ gz = Zlib::GzipReader.new @io
+
+ i = 1
+ gz.each_char do |ignore|
+ gz.pos.should == i
+ i += 1
+ end
+ end
+
+end
diff --git a/spec/ruby/library/zlib/gzipreader/eof_spec.rb b/spec/ruby/library/zlib/gzipreader/eof_spec.rb
index 673220fdfd..a38e144c72 100644
--- a/spec/ruby/library/zlib/gzipreader/eof_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/eof_spec.rb
@@ -12,31 +12,31 @@ describe "Zlib::GzipReader#eof?" do
it "returns true when at EOF" do
gz = Zlib::GzipReader.new @io
- gz.eof?.should be_false
+ gz.eof?.should == false
gz.read
- gz.eof?.should be_true
+ gz.eof?.should == true
end
it "returns true when at EOF with the exact length of uncompressed data" do
gz = Zlib::GzipReader.new @io
- gz.eof?.should be_false
+ gz.eof?.should == false
gz.read(10)
- gz.eof?.should be_true
+ gz.eof?.should == true
end
it "returns true when at EOF with a length greater than the size of uncompressed data" do
gz = Zlib::GzipReader.new @io
- gz.eof?.should be_false
+ gz.eof?.should == false
gz.read(11)
- gz.eof?.should be_true
+ gz.eof?.should == true
end
it "returns false when at EOF when there's data left in the buffer to read" do
gz = Zlib::GzipReader.new @io
gz.read(9)
- gz.eof?.should be_false
+ gz.eof?.should == false
gz.read
- gz.eof?.should be_true
+ gz.eof?.should == true
end
# This is especially important for JRuby, since eof? there
@@ -44,11 +44,11 @@ describe "Zlib::GzipReader#eof?" do
it "does not affect the reading data" do
gz = Zlib::GzipReader.new @io
0.upto(9) do |i|
- gz.eof?.should be_false
+ gz.eof?.should == false
gz.read(1).should == @data[i, 1]
end
- gz.eof?.should be_true
+ gz.eof?.should == true
gz.read.should == ""
- gz.eof?.should be_true
+ gz.eof?.should == true
end
end
diff --git a/spec/ruby/library/zlib/gzipreader/getc_spec.rb b/spec/ruby/library/zlib/gzipreader/getc_spec.rb
index e567231940..be13592189 100644
--- a/spec/ruby/library/zlib/gzipreader/getc_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/getc_spec.rb
@@ -33,7 +33,7 @@ describe "Zlib::GzipReader#getc" do
gz = Zlib::GzipReader.new @io
gz.read
pos = gz.pos
- gz.getc.should be_nil
+ gz.getc.should == nil
gz.pos.should == pos
end
end
diff --git a/spec/ruby/library/zlib/gzipreader/gets_spec.rb b/spec/ruby/library/zlib/gzipreader/gets_spec.rb
index d3a2e7d263..5d0809f833 100644
--- a/spec/ruby/library/zlib/gzipreader/gets_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/gets_spec.rb
@@ -16,7 +16,7 @@ describe 'Zlib::GzipReader#gets' do
gz.gets('').should == "123\n45\n\n"
gz.gets('').should == "abc\nde\n\n"
- gz.eof?.should be_true
+ gz.eof?.should == true
end
end
end
diff --git a/spec/ruby/library/zlib/gzipreader/read_spec.rb b/spec/ruby/library/zlib/gzipreader/read_spec.rb
index b81954b5ce..b07d433bdd 100644
--- a/spec/ruby/library/zlib/gzipreader/read_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/read_spec.rb
@@ -30,7 +30,7 @@ describe "Zlib::GzipReader#read" do
gz = Zlib::GzipReader.new @io
-> {
gz.read(-1)
- }.should raise_error(ArgumentError)
+ }.should.raise(ArgumentError)
end
it "returns an empty string if a 0 length is given" do
@@ -59,8 +59,8 @@ describe "Zlib::GzipReader#read" do
it "returns nil if length parameter is positive" do
gz = Zlib::GzipReader.new @io
gz.read # read till the end
- gz.read(1).should be_nil
- gz.read(2**16).should be_nil
+ gz.read(1).should == nil
+ gz.read(2**16).should == nil
end
end
end
diff --git a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
index 7fa0608f9f..53870b9177 100644
--- a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
@@ -94,7 +94,7 @@ describe "Zlib::GzipReader#ungetbyte" do
it 'makes eof? false' do
@gz.ungetbyte 0x21
- @gz.eof?.should be_false
+ @gz.eof?.should == false
end
end
@@ -112,7 +112,7 @@ describe "Zlib::GzipReader#ungetbyte" do
it 'does not make eof? false' do
@gz.ungetbyte nil
- @gz.eof?.should be_true
+ @gz.eof?.should == true
end
end
end
diff --git a/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb b/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
index 34f2a1a2ca..46dcfde989 100644
--- a/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
@@ -190,7 +190,7 @@ describe "Zlib::GzipReader#ungetc" do
it 'makes eof? false' do
@gz.ungetc 'x'
- @gz.eof?.should be_false
+ @gz.eof?.should == false
end
end
@@ -207,7 +207,7 @@ describe "Zlib::GzipReader#ungetc" do
it 'makes eof? false' do
@gz.ungetc 'ŷ'
- @gz.eof?.should be_false
+ @gz.eof?.should == false
end
end
@@ -224,7 +224,7 @@ describe "Zlib::GzipReader#ungetc" do
it 'makes eof? false' do
@gz.ungetc 'xŷž'
- @gz.eof?.should be_false
+ @gz.eof?.should == false
end
end
@@ -241,7 +241,7 @@ describe "Zlib::GzipReader#ungetc" do
it 'makes eof? false' do
@gz.ungetc 0x21
- @gz.eof?.should be_false
+ @gz.eof?.should == false
end
end
@@ -258,7 +258,7 @@ describe "Zlib::GzipReader#ungetc" do
it 'does not make eof? false' do
@gz.ungetc ''
- @gz.eof?.should be_true
+ @gz.eof?.should == true
end
end
@@ -276,7 +276,7 @@ describe "Zlib::GzipReader#ungetc" do
it 'does not make eof? false' do
@gz.ungetc nil
- @gz.eof?.should be_true
+ @gz.eof?.should == true
end
end
end
diff --git a/spec/ruby/library/zlib/gzipwriter/append_spec.rb b/spec/ruby/library/zlib/gzipwriter/append_spec.rb
index 6aa2824180..ef9e3d3a6b 100644
--- a/spec/ruby/library/zlib/gzipwriter/append_spec.rb
+++ b/spec/ruby/library/zlib/gzipwriter/append_spec.rb
@@ -9,7 +9,7 @@ describe "Zlib::GzipWriter#<<" do
it "returns self" do
Zlib::GzipWriter.wrap @io do |gzio|
- (gzio << "test").should equal(gzio)
+ (gzio << "test").should.equal?(gzio)
end
end
end
diff --git a/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb b/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb
index 621b602dc7..a70fa68069 100644
--- a/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb
+++ b/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb
@@ -31,8 +31,7 @@ describe "Zlib::GzipWriter#mtime=" do
Zlib::GzipWriter.wrap @io do |gzio|
gzio.write ''
- -> { gzio.mtime = nil }.should \
- raise_error(Zlib::GzipFile::Error, 'header is already written')
+ -> { gzio.mtime = nil }.should.raise(Zlib::GzipFile::Error, 'header is already written')
end
end
end
diff --git a/spec/ruby/library/zlib/inflate/append_spec.rb b/spec/ruby/library/zlib/inflate/append_spec.rb
index f121e66566..a4c791e31e 100644
--- a/spec/ruby/library/zlib/inflate/append_spec.rb
+++ b/spec/ruby/library/zlib/inflate/append_spec.rb
@@ -41,7 +41,7 @@ describe "Zlib::Inflate#<<" do
it "properly handles incomplete data" do
# add bytes, one by one
@foo_deflated[0, 5].each_byte { |d| @z << d.chr}
- -> { @z.finish }.should raise_error(Zlib::BufError)
+ -> { @z.finish }.should.raise(Zlib::BufError)
end
it "properly handles excessive data, byte-by-byte" do
diff --git a/spec/ruby/library/zlib/inflate/finish_spec.rb b/spec/ruby/library/zlib/inflate/finish_spec.rb
index 3e0663e265..b7494e419c 100644
--- a/spec/ruby/library/zlib/inflate/finish_spec.rb
+++ b/spec/ruby/library/zlib/inflate/finish_spec.rb
@@ -23,7 +23,7 @@ describe "Zlib::Inflate#finish" do
end
it "each chunk should have the same prefix" do
- @chunks.all? { |chunk| chunk =~ /\A0+\z/ }.should be_true
+ @chunks.all? { |chunk| chunk =~ /\A0+\z/ }.should == true
end
end
diff --git a/spec/ruby/library/zlib/inflate/inflate_spec.rb b/spec/ruby/library/zlib/inflate/inflate_spec.rb
index b308a4ba67..92e52363db 100644
--- a/spec/ruby/library/zlib/inflate/inflate_spec.rb
+++ b/spec/ruby/library/zlib/inflate/inflate_spec.rb
@@ -84,7 +84,7 @@ describe "Zlib::Inflate.inflate" do
# add bytes, one by one, but not all
result = +""
data.each_byte { |d| result << z.inflate(d.chr)}
- -> { result << z.finish }.should raise_error(Zlib::BufError)
+ -> { result << z.finish }.should.raise(Zlib::BufError)
end
it "properly handles excessive data, byte-by-byte" do
@@ -138,7 +138,7 @@ describe "Zlib::Inflate#inflate" do
end
it "properly handles chunked data" do
- @chunks.all? { |chunk| chunk =~ /\A0+\z/ }.should be_true
+ @chunks.all? { |chunk| chunk =~ /\A0+\z/ }.should == true
end
end
diff --git a/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb b/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb
index 251cec44bb..375ee3c765 100644
--- a/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb
+++ b/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb
@@ -1,4 +1,4 @@
-# -*- encoding: binary -*-
+# encoding: binary
require_relative '../../../spec_helper'
require 'zlib'
diff --git a/spec/ruby/library/zlib/zlib_version_spec.rb b/spec/ruby/library/zlib/zlib_version_spec.rb
index f83dfae66d..7edc76cdd5 100644
--- a/spec/ruby/library/zlib/zlib_version_spec.rb
+++ b/spec/ruby/library/zlib/zlib_version_spec.rb
@@ -3,6 +3,6 @@ require 'zlib'
describe "Zlib.zlib_version" do
it "returns the version of the libz library" do
- Zlib.zlib_version.should be_an_instance_of(String)
+ Zlib.zlib_version.should.instance_of?(String)
end
end