summaryrefslogtreecommitdiff
path: root/spec/ruby/library/zlib/gzipfile/close_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/zlib/gzipfile/close_spec.rb')
-rw-r--r--spec/ruby/library/zlib/gzipfile/close_spec.rb19
1 files changed, 19 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..07bafac961
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/close_spec.rb
@@ -0,0 +1,19 @@
+require_relative '../../../spec_helper'
+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.should.closed?
+
+ -> { 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