diff options
Diffstat (limited to 'spec/ruby/library/zlib/gzipfile/close_spec.rb')
-rw-r--r-- | spec/ruby/library/zlib/gzipfile/close_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/ruby/library/zlib/gzipfile/close_spec.rb b/spec/ruby/library/zlib/gzipfile/close_spec.rb new file mode 100644 index 0000000000..9486d6b9ec --- /dev/null +++ b/spec/ruby/library/zlib/gzipfile/close_spec.rb @@ -0,0 +1,22 @@ +require File.expand_path('../../../../spec_helper', __FILE__) +require 'stringio' +require 'zlib' + +describe "Zlib::GzipFile#close" do + it "finishes the stream and closes the io" do + io = StringIO.new "".b + Zlib::GzipWriter.wrap io do |gzio| + gzio.close + + gzio.closed?.should == true + + 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') + end + + io.string[10..-1].should == ([3] + Array.new(9,0)).pack('C*') + end +end + |