diff options
Diffstat (limited to 'spec/ruby/library/zlib')
86 files changed, 323 insertions, 268 deletions
diff --git a/spec/ruby/library/zlib/adler32_spec.rb b/spec/ruby/library/zlib/adler32_spec.rb index 1767dc2011..887c22d059 100644 --- a/spec/ruby/library/zlib/adler32_spec.rb +++ b/spec/ruby/library/zlib/adler32_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'zlib' describe "Zlib.adler32" do @@ -19,10 +19,10 @@ 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 - lambda { 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 Bignums" do + it "calculates the Adler checksum for string and initial Adler value for Integers" do test_string = "This is a test string! How exciting!%?" Zlib.adler32(test_string, 2**30).should == 1137642779 end diff --git a/spec/ruby/library/zlib/crc32_spec.rb b/spec/ruby/library/zlib/crc32_spec.rb index 22d1dac28b..b94b5c627c 100644 --- a/spec/ruby/library/zlib/crc32_spec.rb +++ b/spec/ruby/library/zlib/crc32_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'zlib' describe "Zlib.crc32" do @@ -24,10 +24,12 @@ describe "Zlib.crc32" do Zlib.crc32(test_string, 1).should == 1809313411 Zlib.crc32(test_string, 2**8).should == 1722745982 Zlib.crc32(test_string, 2**16).should == 1932511220 - lambda { Zlib.crc32(test_string, 2**128) }.should raise_error(RangeError) + Zlib.crc32("p", ~305419896).should == 4046865307 + Zlib.crc32("p", -305419897).should == 4046865307 + -> { Zlib.crc32(test_string, 2**128) }.should.raise(RangeError) end - it "calculates the CRC checksum for string and initial CRC value for Bignums" do + it "calculates the CRC checksum for string and initial CRC value for Integers" do test_string = "This is a test string! How exciting!%?" # Zlib.crc32(test_string, -2**30).should == 277228695 Zlib.crc32(test_string, 2**30).should == 46597132 diff --git a/spec/ruby/library/zlib/crc_table_spec.rb b/spec/ruby/library/zlib/crc_table_spec.rb index 22aaa32233..de8876086b 100644 --- a/spec/ruby/library/zlib/crc_table_spec.rb +++ b/spec/ruby/library/zlib/crc_table_spec.rb @@ -1,75 +1,80 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require "zlib" describe "Zlib.crc_table" do - - it "returns the same value as zlib's get_crc_table()" do - Zlib.crc_table.should == [ - 0, 1996959894, 3993919788, 2567524794, - 124634137, 1886057615, 3915621685, 2657392035, - 249268274, 2044508324, 3772115230, 2547177864, - 162941995, 2125561021, 3887607047, 2428444049, - 498536548, 1789927666, 4089016648, 2227061214, - 450548861, 1843258603, 4107580753, 2211677639, - 325883990, 1684777152, 4251122042, 2321926636, - 335633487, 1661365465, 4195302755, 2366115317, - 997073096, 1281953886, 3579855332, 2724688242, - 1006888145, 1258607687, 3524101629, 2768942443, - 901097722, 1119000684, 3686517206, 2898065728, - 853044451, 1172266101, 3705015759, 2882616665, - 651767980, 1373503546, 3369554304, 3218104598, - 565507253, 1454621731, 3485111705, 3099436303, - 671266974, 1594198024, 3322730930, 2970347812, - 795835527, 1483230225, 3244367275, 3060149565, - 1994146192, 31158534, 2563907772, 4023717930, - 1907459465, 112637215, 2680153253, 3904427059, - 2013776290, 251722036, 2517215374, 3775830040, - 2137656763, 141376813, 2439277719, 3865271297, - 1802195444, 476864866, 2238001368, 4066508878, - 1812370925, 453092731, 2181625025, 4111451223, - 1706088902, 314042704, 2344532202, 4240017532, - 1658658271, 366619977, 2362670323, 4224994405, - 1303535960, 984961486, 2747007092, 3569037538, - 1256170817, 1037604311, 2765210733, 3554079995, - 1131014506, 879679996, 2909243462, 3663771856, - 1141124467, 855842277, 2852801631, 3708648649, - 1342533948, 654459306, 3188396048, 3373015174, - 1466479909, 544179635, 3110523913, 3462522015, - 1591671054, 702138776, 2966460450, 3352799412, - 1504918807, 783551873, 3082640443, 3233442989, - 3988292384, 2596254646, 62317068, 1957810842, - 3939845945, 2647816111, 81470997, 1943803523, - 3814918930, 2489596804, 225274430, 2053790376, - 3826175755, 2466906013, 167816743, 2097651377, - 4027552580, 2265490386, 503444072, 1762050814, - 4150417245, 2154129355, 426522225, 1852507879, - 4275313526, 2312317920, 282753626, 1742555852, - 4189708143, 2394877945, 397917763, 1622183637, - 3604390888, 2714866558, 953729732, 1340076626, - 3518719985, 2797360999, 1068828381, 1219638859, - 3624741850, 2936675148, 906185462, 1090812512, - 3747672003, 2825379669, 829329135, 1181335161, - 3412177804, 3160834842, 628085408, 1382605366, - 3423369109, 3138078467, 570562233, 1426400815, - 3317316542, 2998733608, 733239954, 1555261956, - 3268935591, 3050360625, 752459403, 1541320221, - 2607071920, 3965973030, 1969922972, 40735498, - 2617837225, 3943577151, 1913087877, 83908371, - 2512341634, 3803740692, 2075208622, 213261112, - 2463272603, 3855990285, 2094854071, 198958881, - 2262029012, 4057260610, 1759359992, 534414190, - 2176718541, 4139329115, 1873836001, 414664567, - 2282248934, 4279200368, 1711684554, 285281116, - 2405801727, 4167216745, 1634467795, 376229701, - 2685067896, 3608007406, 1308918612, 956543938, - 2808555105, 3495958263, 1231636301, 1047427035, - 2932959818, 3654703836, 1088359270, 936918000, - 2847714899, 3736837829, 1202900863, 817233897, - 3183342108, 3401237130, 1404277552, 615818150, - 3134207493, 3453421203, 1423857449, 601450431, - 3009837614, 3294710456, 1567103746, 711928724, - 3020668471, 3272380065, 1510334235, 755167117, - ] + # This spec fails when zlib.h and libz.so are not from the same version. + # In older zlib (< 1.2.7 it seems), get_crc_table() is stored as u64[], + # but in newer zlib, get_crc_table() is stored as u32[]. + # Technically, there is ABI breakage between those zlib versions, + # but get_crc_table() is an "undocumented function" according to zlib.h. + guard -> { ENV["RUBY_SPEC_TEST_ZLIB_CRC_TABLE"] != "false" } do + it "returns the same value as zlib's get_crc_table()" do + Zlib.crc_table.should == [ + 0, 1996959894, 3993919788, 2567524794, + 124634137, 1886057615, 3915621685, 2657392035, + 249268274, 2044508324, 3772115230, 2547177864, + 162941995, 2125561021, 3887607047, 2428444049, + 498536548, 1789927666, 4089016648, 2227061214, + 450548861, 1843258603, 4107580753, 2211677639, + 325883990, 1684777152, 4251122042, 2321926636, + 335633487, 1661365465, 4195302755, 2366115317, + 997073096, 1281953886, 3579855332, 2724688242, + 1006888145, 1258607687, 3524101629, 2768942443, + 901097722, 1119000684, 3686517206, 2898065728, + 853044451, 1172266101, 3705015759, 2882616665, + 651767980, 1373503546, 3369554304, 3218104598, + 565507253, 1454621731, 3485111705, 3099436303, + 671266974, 1594198024, 3322730930, 2970347812, + 795835527, 1483230225, 3244367275, 3060149565, + 1994146192, 31158534, 2563907772, 4023717930, + 1907459465, 112637215, 2680153253, 3904427059, + 2013776290, 251722036, 2517215374, 3775830040, + 2137656763, 141376813, 2439277719, 3865271297, + 1802195444, 476864866, 2238001368, 4066508878, + 1812370925, 453092731, 2181625025, 4111451223, + 1706088902, 314042704, 2344532202, 4240017532, + 1658658271, 366619977, 2362670323, 4224994405, + 1303535960, 984961486, 2747007092, 3569037538, + 1256170817, 1037604311, 2765210733, 3554079995, + 1131014506, 879679996, 2909243462, 3663771856, + 1141124467, 855842277, 2852801631, 3708648649, + 1342533948, 654459306, 3188396048, 3373015174, + 1466479909, 544179635, 3110523913, 3462522015, + 1591671054, 702138776, 2966460450, 3352799412, + 1504918807, 783551873, 3082640443, 3233442989, + 3988292384, 2596254646, 62317068, 1957810842, + 3939845945, 2647816111, 81470997, 1943803523, + 3814918930, 2489596804, 225274430, 2053790376, + 3826175755, 2466906013, 167816743, 2097651377, + 4027552580, 2265490386, 503444072, 1762050814, + 4150417245, 2154129355, 426522225, 1852507879, + 4275313526, 2312317920, 282753626, 1742555852, + 4189708143, 2394877945, 397917763, 1622183637, + 3604390888, 2714866558, 953729732, 1340076626, + 3518719985, 2797360999, 1068828381, 1219638859, + 3624741850, 2936675148, 906185462, 1090812512, + 3747672003, 2825379669, 829329135, 1181335161, + 3412177804, 3160834842, 628085408, 1382605366, + 3423369109, 3138078467, 570562233, 1426400815, + 3317316542, 2998733608, 733239954, 1555261956, + 3268935591, 3050360625, 752459403, 1541320221, + 2607071920, 3965973030, 1969922972, 40735498, + 2617837225, 3943577151, 1913087877, 83908371, + 2512341634, 3803740692, 2075208622, 213261112, + 2463272603, 3855990285, 2094854071, 198958881, + 2262029012, 4057260610, 1759359992, 534414190, + 2176718541, 4139329115, 1873836001, 414664567, + 2282248934, 4279200368, 1711684554, 285281116, + 2405801727, 4167216745, 1634467795, 376229701, + 2685067896, 3608007406, 1308918612, 956543938, + 2808555105, 3495958263, 1231636301, 1047427035, + 2932959818, 3654703836, 1088359270, 936918000, + 2847714899, 3736837829, 1202900863, 817233897, + 3183342108, 3401237130, 1404277552, 615818150, + 3134207493, 3453421203, 1423857449, 601450431, + 3009837614, 3294710456, 1567103746, 711928724, + 3020668471, 3272380065, 1510334235, 755167117, + ] + end end - end diff --git a/spec/ruby/library/zlib/deflate/append_spec.rb b/spec/ruby/library/zlib/deflate/append_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/deflate/append_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/deflate/deflate_spec.rb b/spec/ruby/library/zlib/deflate/deflate_spec.rb index 44b3389701..e16e6ad0ef 100644 --- a/spec/ruby/library/zlib/deflate/deflate_spec.rb +++ b/spec/ruby/library/zlib/deflate/deflate_spec.rb @@ -1,5 +1,5 @@ require 'zlib' -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' describe "Zlib::Deflate.deflate" do it "deflates some data" do @@ -23,9 +23,9 @@ describe "Zlib::Deflate.deflate" do it "deflates chunked data" do random_generator = Random.new(0) - deflated = '' + deflated = +'' - Zlib.deflate(random_generator.bytes(20000)) do |chunk| + Zlib::Deflate.deflate(random_generator.bytes(20000)) do |chunk| deflated << chunk end @@ -58,6 +58,11 @@ describe "Zlib::Deflate#deflate" do Array.new(31, 0) + [24, 128, 0, 0, 1]).pack('C*') end + + it "has a binary encoding" do + @deflator.deflate("").encoding.should == Encoding::BINARY + @deflator.finish.encoding.should == Encoding::BINARY + end end describe "Zlib::Deflate#deflate" do @@ -65,7 +70,7 @@ describe "Zlib::Deflate#deflate" do before :each do @deflator = Zlib::Deflate.new @random_generator = Random.new(0) - @original = '' + @original = +'' @chunks = [] end diff --git a/spec/ruby/library/zlib/deflate/flush_spec.rb b/spec/ruby/library/zlib/deflate/flush_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/deflate/flush_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/deflate/new_spec.rb b/spec/ruby/library/zlib/deflate/new_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/deflate/new_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/deflate/params_spec.rb b/spec/ruby/library/zlib/deflate/params_spec.rb index 59b1353c07..0242653528 100644 --- a/spec/ruby/library/zlib/deflate/params_spec.rb +++ b/spec/ruby/library/zlib/deflate/params_spec.rb @@ -1,9 +1,9 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'zlib' describe "Zlib::Deflate#params" do it "changes the deflate parameters" do - data = 'abcdefghijklm' + data = +'abcdefghijklm' d = Zlib::Deflate.new Zlib::NO_COMPRESSION, Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, Zlib::DEFAULT_STRATEGY diff --git a/spec/ruby/library/zlib/deflate/set_dictionary_spec.rb b/spec/ruby/library/zlib/deflate/set_dictionary_spec.rb index c5c62d9529..0e461229c7 100644 --- a/spec/ruby/library/zlib/deflate/set_dictionary_spec.rb +++ b/spec/ruby/library/zlib/deflate/set_dictionary_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'zlib' describe "Zlib::Deflate#set_dictionary" do @@ -12,4 +12,3 @@ describe "Zlib::Deflate#set_dictionary" do 2, 0, 21, 134, 3, 248].pack('C*') end end - diff --git a/spec/ruby/library/zlib/deflate_spec.rb b/spec/ruby/library/zlib/deflate_spec.rb new file mode 100644 index 0000000000..6eeaa164c5 --- /dev/null +++ b/spec/ruby/library/zlib/deflate_spec.rb @@ -0,0 +1,8 @@ +require_relative '../../spec_helper' +require "zlib" + +describe "Zlib.deflate" do + it "deflates some data" do + Zlib.deflate("1" * 10).should == [120, 156, 51, 52, 132, 1, 0, 10, 145, 1, 235].pack('C*') + end +end diff --git a/spec/ruby/library/zlib/gunzip_spec.rb b/spec/ruby/library/zlib/gunzip_spec.rb new file mode 100644 index 0000000000..2417fed57c --- /dev/null +++ b/spec/ruby/library/zlib/gunzip_spec.rb @@ -0,0 +1,14 @@ +require_relative '../../spec_helper' +require 'zlib' + +describe "Zlib.gunzip" 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*') + end + + it "decodes the given gzipped string" do + Zlib.gunzip(@zip).should == @data + end +end diff --git a/spec/ruby/library/zlib/gzip_spec.rb b/spec/ruby/library/zlib/gzip_spec.rb new file mode 100644 index 0000000000..35694264f0 --- /dev/null +++ b/spec/ruby/library/zlib/gzip_spec.rb @@ -0,0 +1,15 @@ +require_relative '../../spec_helper' +require 'zlib' + +describe "Zlib.gzip" 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*') + end + + it "gzips the given string" do + # skip gzip header for now + Zlib.gzip(@data)[10..-1].should == @zip[10..-1] + end +end diff --git a/spec/ruby/library/zlib/gzipfile/close_spec.rb b/spec/ruby/library/zlib/gzipfile/close_spec.rb index 9486d6b9ec..07bafac961 100644 --- a/spec/ruby/library/zlib/gzipfile/close_spec.rb +++ b/spec/ruby/library/zlib/gzipfile/close_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' @@ -8,15 +8,12 @@ describe "Zlib::GzipFile#close" do Zlib::GzipWriter.wrap io do |gzio| gzio.close - gzio.closed?.should == true + gzio.should.closed? - lambda { gzio.orig_name }.should \ - raise_error(Zlib::GzipFile::Error, 'closed gzip stream') - lambda { 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*') end end - diff --git a/spec/ruby/library/zlib/gzipfile/closed_spec.rb b/spec/ruby/library/zlib/gzipfile/closed_spec.rb index 69785bc41c..726f391b41 100644 --- a/spec/ruby/library/zlib/gzipfile/closed_spec.rb +++ b/spec/ruby/library/zlib/gzipfile/closed_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' @@ -6,12 +6,11 @@ describe "Zlib::GzipFile#closed?" do it "returns the closed status" do io = StringIO.new Zlib::GzipWriter.wrap io do |gzio| - gzio.closed?.should == false + gzio.should_not.closed? gzio.close - gzio.closed?.should == true + gzio.should.closed? end end end - diff --git a/spec/ruby/library/zlib/gzipfile/comment_spec.rb b/spec/ruby/library/zlib/gzipfile/comment_spec.rb index 638e85a4a7..845224df98 100644 --- a/spec/ruby/library/zlib/gzipfile/comment_spec.rb +++ b/spec/ruby/library/zlib/gzipfile/comment_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' @@ -19,9 +19,7 @@ describe "Zlib::GzipFile#comment" do Zlib::GzipWriter.wrap @io do |gzio| gzio.close - lambda { 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/crc_spec.rb b/spec/ruby/library/zlib/gzipfile/crc_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipfile/crc_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipfile/finish_spec.rb b/spec/ruby/library/zlib/gzipfile/finish_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipfile/finish_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipfile/level_spec.rb b/spec/ruby/library/zlib/gzipfile/level_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipfile/level_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipfile/mtime_spec.rb b/spec/ruby/library/zlib/gzipfile/mtime_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipfile/mtime_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb b/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb index 42a3b2f376..1da375390b 100644 --- a/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb +++ b/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' @@ -19,9 +19,7 @@ describe "Zlib::GzipFile#orig_name" do Zlib::GzipWriter.wrap @io do |gzio| gzio.close - lambda { 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/gzipfile/os_code_spec.rb b/spec/ruby/library/zlib/gzipfile/os_code_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipfile/os_code_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipfile/sync_spec.rb b/spec/ruby/library/zlib/gzipfile/sync_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipfile/sync_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipfile/to_io_spec.rb b/spec/ruby/library/zlib/gzipfile/to_io_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipfile/to_io_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipfile/wrap_spec.rb b/spec/ruby/library/zlib/gzipfile/wrap_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipfile/wrap_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb b/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb index 6da9ac8323..48821dc833 100644 --- a/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb @@ -1,8 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' -describe "GzipReader#each_byte" do +describe "Zlib::GzipReader#each_byte" do before :each do @data = '12345abcde' 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/each_line_spec.rb b/spec/ruby/library/zlib/gzipreader/each_line_spec.rb index 7ff116a258..6f17365879 100644 --- a/spec/ruby/library/zlib/gzipreader/each_line_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/each_line_spec.rb @@ -1,5 +1,6 @@ -require File.expand_path('../shared/each', __FILE__) +require_relative "../../../spec_helper" +require_relative 'shared/each' -describe "GzipReader#each_line" do +describe "Zlib::GzipReader#each_line" do it_behaves_like :gzipreader_each, :each_line end diff --git a/spec/ruby/library/zlib/gzipreader/each_spec.rb b/spec/ruby/library/zlib/gzipreader/each_spec.rb index dd780e4083..3b98391a87 100644 --- a/spec/ruby/library/zlib/gzipreader/each_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/each_spec.rb @@ -1,5 +1,6 @@ -require File.expand_path('../shared/each', __FILE__) +require_relative "../../../spec_helper" +require_relative 'shared/each' -describe "GzipReader#each" do +describe "Zlib::GzipReader#each" do it_behaves_like :gzipreader_each, :each end diff --git a/spec/ruby/library/zlib/gzipreader/eof_spec.rb b/spec/ruby/library/zlib/gzipreader/eof_spec.rb index 446cbfec37..a38e144c72 100644 --- a/spec/ruby/library/zlib/gzipreader/eof_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/eof_spec.rb @@ -1,9 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' -describe "GzipReader#eof?" do - +describe "Zlib::GzipReader#eof?" do before :each do @data = '{"a":1234}' @zip = [31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 171, 86, 74, 84, 178, 50, @@ -13,31 +12,31 @@ describe "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 @@ -45,12 +44,11 @@ describe "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.read().should == "" - gz.eof?.should be_true + gz.eof?.should == true + gz.read.should == "" + 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 a3c4aecf76..be13592189 100644 --- a/spec/ruby/library/zlib/gzipreader/getc_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/getc_spec.rb @@ -1,9 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' -describe "GzipReader#getc" do - +describe "Zlib::GzipReader#getc" do before :each do @data = '12345abcde' @zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77, @@ -34,8 +33,7 @@ describe "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 d49adc2850..5d0809f833 100644 --- a/spec/ruby/library/zlib/gzipreader/gets_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/gets_spec.rb @@ -1,8 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'zlib' require 'stringio' -describe 'GzipReader#gets' do +describe 'Zlib::GzipReader#gets' do describe 'with "" separator' do it 'reads paragraphs skipping newlines' do # gz contains "\n\n\n\n\n123\n45\n\n\n\n\nabc\nde\n\n\n\n\n" @@ -16,7 +16,7 @@ describe '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/lineno_spec.rb b/spec/ruby/library/zlib/gzipreader/lineno_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipreader/lineno_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipreader/mtime_spec.rb b/spec/ruby/library/zlib/gzipreader/mtime_spec.rb new file mode 100644 index 0000000000..e8e71fa72e --- /dev/null +++ b/spec/ruby/library/zlib/gzipreader/mtime_spec.rb @@ -0,0 +1,11 @@ +require_relative '../../../spec_helper' +require 'zlib' +require 'stringio' + +describe "Zlib::GzipReader#mtime" do + it "returns the timestamp from the Gzip header" do + io = StringIO.new "\x1f\x8b\x08\x00\x44\x33\x22\x11\x00\xff\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00" + gz = Zlib::GzipReader.new(io) + gz.mtime.to_i.should == 0x11223344 + end +end diff --git a/spec/ruby/library/zlib/gzipreader/new_spec.rb b/spec/ruby/library/zlib/gzipreader/new_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipreader/new_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipreader/open_spec.rb b/spec/ruby/library/zlib/gzipreader/open_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipreader/open_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipreader/pos_spec.rb b/spec/ruby/library/zlib/gzipreader/pos_spec.rb index 66fbf388d8..8586faec92 100644 --- a/spec/ruby/library/zlib/gzipreader/pos_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/pos_spec.rb @@ -1,9 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' -describe "GzipReader#pos" do - +describe "Zlib::GzipReader#pos" do before :each do @data = '12345abcde' @zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77, @@ -22,6 +21,4 @@ describe "GzipReader#pos" do gz.read gz.pos.should == @data.length end - end - diff --git a/spec/ruby/library/zlib/gzipreader/read_spec.rb b/spec/ruby/library/zlib/gzipreader/read_spec.rb index 337f507502..b07d433bdd 100644 --- a/spec/ruby/library/zlib/gzipreader/read_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/read_spec.rb @@ -1,9 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' -describe "GzipReader#read" do - +describe "Zlib::GzipReader#read" do before :each do @data = '12345abcde' @zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77, @@ -29,9 +28,9 @@ describe "GzipReader#read" do it "does not accept a negative length to read" do gz = Zlib::GzipReader.new @io - lambda { + -> { gz.read(-1) - }.should raise_error(ArgumentError) + }.should.raise(ArgumentError) end it "returns an empty string if a 0 length is given" do @@ -49,7 +48,7 @@ describe "GzipReader#read" do end describe "at the end of data" do - it "returns empty string if length prameter is not specified or 0" do + it "returns empty string if length parameter is not specified or 0" do gz = Zlib::GzipReader.new @io gz.read # read till the end gz.read(0).should == "" @@ -57,12 +56,11 @@ describe "GzipReader#read" do gz.read(nil).should == "" end - it "returns nil if length prameter is positive" 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/readchar_spec.rb b/spec/ruby/library/zlib/gzipreader/readchar_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipreader/readchar_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipreader/readline_spec.rb b/spec/ruby/library/zlib/gzipreader/readline_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipreader/readline_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipreader/readlines_spec.rb b/spec/ruby/library/zlib/gzipreader/readlines_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipreader/readlines_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb b/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb index 2cdef54fd1..559ce9f841 100644 --- a/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb @@ -1,8 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' -describe 'GzipReader#readpartial' do +describe "Zlib::GzipReader#readpartial" do before :each do @data = '12345abcde' @zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77, diff --git a/spec/ruby/library/zlib/gzipreader/rewind_spec.rb b/spec/ruby/library/zlib/gzipreader/rewind_spec.rb index 70bee3372d..b31abb6abf 100644 --- a/spec/ruby/library/zlib/gzipreader/rewind_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/rewind_spec.rb @@ -1,9 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' -describe "GzipReader#rewind" do - +describe "Zlib::GzipReader#rewind" do before :each do @data = '12345abcde' @zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77, diff --git a/spec/ruby/library/zlib/gzipreader/shared/each.rb b/spec/ruby/library/zlib/gzipreader/shared/each.rb index 47cd284b6a..71608e04ab 100644 --- a/spec/ruby/library/zlib/gzipreader/shared/each.rb +++ b/spec/ruby/library/zlib/gzipreader/shared/each.rb @@ -1,9 +1,8 @@ -require File.expand_path('../../../../../spec_helper', __FILE__) +require_relative '../../../../spec_helper' require 'stringio' require 'zlib' describe :gzipreader_each, shared: true do - before :each do @data = "firstline\nsecondline\n\nforthline" @zip = [31, 139, 8, 0, 244, 125, 128, 88, 2, 255, 75, 203, 44, 42, 46, 201, @@ -47,5 +46,4 @@ describe :gzipreader_each, shared: true do @gzreader.pos.should == i end end - end diff --git a/spec/ruby/library/zlib/gzipreader/tell_spec.rb b/spec/ruby/library/zlib/gzipreader/tell_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipreader/tell_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb index 16f1c12272..53870b9177 100644 --- a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb @@ -1,8 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' -describe 'GzipReader#ungetbyte' do +describe "Zlib::GzipReader#ungetbyte" do before :each do @data = '12345abcde' @zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77, @@ -21,11 +21,9 @@ describe 'GzipReader#ungetbyte' do @gz.read.should == '!12345abcde' end - ruby_bug "#13616", ""..."2.6" do - it 'decrements pos' do - @gz.ungetbyte 0x21 - @gz.pos.should == -1 - end + it 'decrements pos' do + @gz.ungetbyte 0x21 + @gz.pos.should == -1 end end @@ -96,7 +94,7 @@ describe 'GzipReader#ungetbyte' do it 'makes eof? false' do @gz.ungetbyte 0x21 - @gz.eof?.should be_false + @gz.eof?.should == false end end @@ -114,7 +112,7 @@ describe '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 2d218e8d19..46dcfde989 100644 --- a/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb +++ b/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb @@ -1,8 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' -describe 'GzipReader#ungetc' do +describe "Zlib::GzipReader#ungetc" do before :each do @data = '12345abcde' @zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77, @@ -21,11 +21,9 @@ describe 'GzipReader#ungetc' do @gz.read.should == 'x12345abcde' end - ruby_bug "#13616", ""..."2.6" do - it 'decrements pos' do - @gz.ungetc 'x' - @gz.pos.should == -1 - end + it 'decrements pos' do + @gz.ungetc 'x' + @gz.pos.should == -1 end end @@ -35,11 +33,9 @@ describe 'GzipReader#ungetc' do @gz.read.should == 'ŷ12345abcde' end - ruby_bug "#13616", ""..."2.6" do - it 'decrements pos' do - @gz.ungetc 'ŷ' - @gz.pos.should == -2 - end + it 'decrements pos' do + @gz.ungetc 'ŷ' + @gz.pos.should == -2 end end @@ -49,11 +45,9 @@ describe 'GzipReader#ungetc' do @gz.read.should == 'xŷž12345abcde' end - ruby_bug "#13616", ""..."2.6" do - it 'decrements pos' do - @gz.ungetc 'xŷž' - @gz.pos.should == -5 - end + it 'decrements pos' do + @gz.ungetc 'xŷž' + @gz.pos.should == -5 end end @@ -63,11 +57,9 @@ describe 'GzipReader#ungetc' do @gz.read.should == '!12345abcde' end - ruby_bug "#13616", ""..."2.6" do - it 'decrements pos' do - @gz.ungetc 0x21 - @gz.pos.should == -1 - end + it 'decrements pos' do + @gz.ungetc 0x21 + @gz.pos.should == -1 end end @@ -198,7 +190,7 @@ describe 'GzipReader#ungetc' do it 'makes eof? false' do @gz.ungetc 'x' - @gz.eof?.should be_false + @gz.eof?.should == false end end @@ -215,7 +207,7 @@ describe 'GzipReader#ungetc' do it 'makes eof? false' do @gz.ungetc 'ŷ' - @gz.eof?.should be_false + @gz.eof?.should == false end end @@ -232,7 +224,7 @@ describe 'GzipReader#ungetc' do it 'makes eof? false' do @gz.ungetc 'xŷž' - @gz.eof?.should be_false + @gz.eof?.should == false end end @@ -249,7 +241,7 @@ describe 'GzipReader#ungetc' do it 'makes eof? false' do @gz.ungetc 0x21 - @gz.eof?.should be_false + @gz.eof?.should == false end end @@ -266,7 +258,7 @@ describe 'GzipReader#ungetc' do it 'does not make eof? false' do @gz.ungetc '' - @gz.eof?.should be_true + @gz.eof?.should == true end end @@ -284,7 +276,7 @@ describe '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/gzipreader/unused_spec.rb b/spec/ruby/library/zlib/gzipreader/unused_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipreader/unused_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/append_spec.rb b/spec/ruby/library/zlib/gzipwriter/append_spec.rb index 922e921840..ef9e3d3a6b 100644 --- a/spec/ruby/library/zlib/gzipwriter/append_spec.rb +++ b/spec/ruby/library/zlib/gzipwriter/append_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' @@ -9,9 +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 - - it "needs to be reviewed for spec completeness" end diff --git a/spec/ruby/library/zlib/gzipwriter/comment_spec.rb b/spec/ruby/library/zlib/gzipwriter/comment_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipwriter/comment_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/flush_spec.rb b/spec/ruby/library/zlib/gzipwriter/flush_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipwriter/flush_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb b/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb index af7a4ac735..a70fa68069 100644 --- a/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb +++ b/spec/ruby/library/zlib/gzipwriter/mtime_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' @@ -31,8 +31,7 @@ describe "Zlib::GzipWriter#mtime=" do Zlib::GzipWriter.wrap @io do |gzio| gzio.write '' - lambda { 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/gzipwriter/new_spec.rb b/spec/ruby/library/zlib/gzipwriter/new_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipwriter/new_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/open_spec.rb b/spec/ruby/library/zlib/gzipwriter/open_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipwriter/open_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/orig_name_spec.rb b/spec/ruby/library/zlib/gzipwriter/orig_name_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipwriter/orig_name_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/pos_spec.rb b/spec/ruby/library/zlib/gzipwriter/pos_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipwriter/pos_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/print_spec.rb b/spec/ruby/library/zlib/gzipwriter/print_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipwriter/print_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/printf_spec.rb b/spec/ruby/library/zlib/gzipwriter/printf_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipwriter/printf_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/putc_spec.rb b/spec/ruby/library/zlib/gzipwriter/putc_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipwriter/putc_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/puts_spec.rb b/spec/ruby/library/zlib/gzipwriter/puts_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipwriter/puts_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/tell_spec.rb b/spec/ruby/library/zlib/gzipwriter/tell_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/gzipwriter/tell_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/gzipwriter/write_spec.rb b/spec/ruby/library/zlib/gzipwriter/write_spec.rb index 5ff4241423..522ae7f2aa 100644 --- a/spec/ruby/library/zlib/gzipwriter/write_spec.rb +++ b/spec/ruby/library/zlib/gzipwriter/write_spec.rb @@ -1,8 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'stringio' require 'zlib' -describe "GzipWriter#write" do +describe "Zlib::GzipWriter#write" do before :each do @data = '12345abcde' @zip = [31, 139, 8, 0, 44, 220, 209, 71, 0, 3, 51, 52, 50, 54, 49, 77, diff --git a/spec/ruby/library/zlib/inflate/append_spec.rb b/spec/ruby/library/zlib/inflate/append_spec.rb index a768a766a2..a4c791e31e 100644 --- a/spec/ruby/library/zlib/inflate/append_spec.rb +++ b/spec/ruby/library/zlib/inflate/append_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'zlib' describe "Zlib::Inflate#<<" do @@ -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} - lambda { @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 f6e592fb6b..b7494e419c 100644 --- a/spec/ruby/library/zlib/inflate/finish_spec.rb +++ b/spec/ruby/library/zlib/inflate/finish_spec.rb @@ -1,3 +1,4 @@ +require_relative "../../../spec_helper" require 'zlib' describe "Zlib::Inflate#finish" do @@ -22,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 1fa16d9e98..92e52363db 100644 --- a/spec/ruby/library/zlib/inflate/inflate_spec.rb +++ b/spec/ruby/library/zlib/inflate/inflate_spec.rb @@ -1,5 +1,5 @@ require 'zlib' -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' describe "Zlib::Inflate#inflate" do @@ -39,6 +39,13 @@ describe "Zlib::Inflate#inflate" do @inflator.finish.should == 'uncompressed_data' end + it "has a binary encoding" do + data = [120, 156, 99, 96, 128, 1, 0, 0, 10, 0, 1].pack('C*') + unzipped = @inflator.inflate data + @inflator.finish.encoding.should == Encoding::BINARY + unzipped.encoding.should == Encoding::BINARY + end + end describe "Zlib::Inflate.inflate" do @@ -65,7 +72,7 @@ describe "Zlib::Inflate.inflate" do data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*') z = Zlib::Inflate.new # add bytes, one by one - result = "" + result = +"" data.each_byte { |d| result << z.inflate(d.chr)} result << z.finish result.should == "foo" @@ -75,15 +82,15 @@ describe "Zlib::Inflate.inflate" do data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*')[0,5] z = Zlib::Inflate.new # add bytes, one by one, but not all - result = "" + result = +"" data.each_byte { |d| result << z.inflate(d.chr)} - lambda { 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 main_data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*') data = main_data * 2 - result = "" + result = +"" z = Zlib::Inflate.new # add bytes, one by one @@ -98,7 +105,7 @@ describe "Zlib::Inflate.inflate" do it "properly handles excessive data, in one go" do main_data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*') data = main_data * 2 - result = "" + result = +"" z = Zlib::Inflate.new result << z.inflate(data) @@ -131,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/new_spec.rb b/spec/ruby/library/zlib/inflate/new_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/inflate/new_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb b/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb index 890815b8e6..375ee3c765 100644 --- a/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb +++ b/spec/ruby/library/zlib/inflate/set_dictionary_spec.rb @@ -1,5 +1,5 @@ -# -*- encoding: binary -*- -require File.expand_path('../../../../spec_helper', __FILE__) +# encoding: binary +require_relative '../../../spec_helper' require 'zlib' describe "Zlib::Inflate#set_dictionary" do @@ -18,4 +18,3 @@ describe "Zlib::Inflate#set_dictionary" do i.finish.should == 'abcdefghij' end end - diff --git a/spec/ruby/library/zlib/inflate/sync_point_spec.rb b/spec/ruby/library/zlib/inflate/sync_point_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/inflate/sync_point_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/inflate/sync_spec.rb b/spec/ruby/library/zlib/inflate/sync_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/inflate/sync_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/inflate_spec.rb b/spec/ruby/library/zlib/inflate_spec.rb new file mode 100644 index 0000000000..42c8dc5fbe --- /dev/null +++ b/spec/ruby/library/zlib/inflate_spec.rb @@ -0,0 +1,8 @@ +require_relative '../../spec_helper' +require "zlib" + +describe "Zlib.inflate" do + it "inflates some data" do + Zlib.inflate([120, 156, 51, 52, 132, 1, 0, 10, 145, 1, 235].pack('C*')).should == "1" * 10 + end +end diff --git a/spec/ruby/library/zlib/zlib_version_spec.rb b/spec/ruby/library/zlib/zlib_version_spec.rb index 14fb93ef07..7edc76cdd5 100644 --- a/spec/ruby/library/zlib/zlib_version_spec.rb +++ b/spec/ruby/library/zlib/zlib_version_spec.rb @@ -1 +1,8 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' +require 'zlib' + +describe "Zlib.zlib_version" do + it "returns the version of the libz library" do + Zlib.zlib_version.should.instance_of?(String) + end +end diff --git a/spec/ruby/library/zlib/zstream/adler_spec.rb b/spec/ruby/library/zlib/zstream/adler_spec.rb index e562fd260e..55ac8ae79e 100644 --- a/spec/ruby/library/zlib/zstream/adler_spec.rb +++ b/spec/ruby/library/zlib/zstream/adler_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'zlib' describe "Zlib::ZStream#adler" do diff --git a/spec/ruby/library/zlib/zstream/avail_in_spec.rb b/spec/ruby/library/zlib/zstream/avail_in_spec.rb index 25d3219a5a..eddae15830 100644 --- a/spec/ruby/library/zlib/zstream/avail_in_spec.rb +++ b/spec/ruby/library/zlib/zstream/avail_in_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'zlib' describe "Zlib::ZStream#avail_in" do diff --git a/spec/ruby/library/zlib/zstream/avail_out_spec.rb b/spec/ruby/library/zlib/zstream/avail_out_spec.rb index c747bbbc2f..2e5a394ec0 100644 --- a/spec/ruby/library/zlib/zstream/avail_out_spec.rb +++ b/spec/ruby/library/zlib/zstream/avail_out_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'zlib' describe "Zlib::ZStream#avail_out" do diff --git a/spec/ruby/library/zlib/zstream/close_spec.rb b/spec/ruby/library/zlib/zstream/close_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/zstream/close_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/zstream/closed_spec.rb b/spec/ruby/library/zlib/zstream/closed_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/zstream/closed_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/zstream/data_type_spec.rb b/spec/ruby/library/zlib/zstream/data_type_spec.rb index 614f0d10a2..8be96adf7c 100644 --- a/spec/ruby/library/zlib/zstream/data_type_spec.rb +++ b/spec/ruby/library/zlib/zstream/data_type_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'zlib' describe "Zlib::ZStream#data_type" do diff --git a/spec/ruby/library/zlib/zstream/end_spec.rb b/spec/ruby/library/zlib/zstream/end_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/zstream/end_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/zstream/ended_spec.rb b/spec/ruby/library/zlib/zstream/ended_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/zstream/ended_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/zstream/finish_spec.rb b/spec/ruby/library/zlib/zstream/finish_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/zstream/finish_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/zstream/finished_spec.rb b/spec/ruby/library/zlib/zstream/finished_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/zstream/finished_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/zstream/flush_next_in_spec.rb b/spec/ruby/library/zlib/zstream/flush_next_in_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/zstream/flush_next_in_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb b/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb index 8ba8414cd1..63676a8203 100644 --- a/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb +++ b/spec/ruby/library/zlib/zstream/flush_next_out_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'zlib' describe "Zlib::ZStream#flush_next_out" do @@ -8,9 +8,7 @@ describe "Zlib::ZStream#flush_next_out" do zs << [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*') zs.flush_next_out.should == 'foo' - zs.finished?.should == true + zs.should.finished? zs.flush_next_out.should == '' end end - - diff --git a/spec/ruby/library/zlib/zstream/reset_spec.rb b/spec/ruby/library/zlib/zstream/reset_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/zstream/reset_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/zstream/stream_end_spec.rb b/spec/ruby/library/zlib/zstream/stream_end_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/zstream/stream_end_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/zstream/total_in_spec.rb b/spec/ruby/library/zlib/zstream/total_in_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/zstream/total_in_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) diff --git a/spec/ruby/library/zlib/zstream/total_out_spec.rb b/spec/ruby/library/zlib/zstream/total_out_spec.rb deleted file mode 100644 index 6a4c1dadb4..0000000000 --- a/spec/ruby/library/zlib/zstream/total_out_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require File.expand_path('../../../../spec_helper', __FILE__) |
