summaryrefslogtreecommitdiff
path: root/spec/ruby/library/zlib/gzipfile
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/zlib/gzipfile')
-rw-r--r--spec/ruby/library/zlib/gzipfile/close_spec.rb19
-rw-r--r--spec/ruby/library/zlib/gzipfile/closed_spec.rb16
-rw-r--r--spec/ruby/library/zlib/gzipfile/comment_spec.rb25
-rw-r--r--spec/ruby/library/zlib/gzipfile/orig_name_spec.rb25
4 files changed, 85 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
diff --git a/spec/ruby/library/zlib/gzipfile/closed_spec.rb b/spec/ruby/library/zlib/gzipfile/closed_spec.rb
new file mode 100644
index 0000000000..726f391b41
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/closed_spec.rb
@@ -0,0 +1,16 @@
+require_relative '../../../spec_helper'
+require 'stringio'
+require 'zlib'
+
+describe "Zlib::GzipFile#closed?" do
+ it "returns the closed status" do
+ io = StringIO.new
+ Zlib::GzipWriter.wrap io do |gzio|
+ gzio.should_not.closed?
+
+ gzio.close
+
+ 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
new file mode 100644
index 0000000000..845224df98
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/comment_spec.rb
@@ -0,0 +1,25 @@
+require_relative '../../../spec_helper'
+require 'stringio'
+require 'zlib'
+
+describe "Zlib::GzipFile#comment" do
+ before :each do
+ @io = StringIO.new
+ end
+
+ it "returns the name" do
+ Zlib::GzipWriter.wrap @io do |gzio|
+ gzio.comment = 'name'
+
+ gzio.comment.should == 'name'
+ end
+ end
+
+ it "raises an error on a closed stream" do
+ Zlib::GzipWriter.wrap @io do |gzio|
+ gzio.close
+
+ -> { 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
new file mode 100644
index 0000000000..1da375390b
--- /dev/null
+++ b/spec/ruby/library/zlib/gzipfile/orig_name_spec.rb
@@ -0,0 +1,25 @@
+require_relative '../../../spec_helper'
+require 'stringio'
+require 'zlib'
+
+describe "Zlib::GzipFile#orig_name" do
+ before :each do
+ @io = StringIO.new
+ end
+
+ it "returns the name" do
+ Zlib::GzipWriter.wrap @io do |gzio|
+ gzio.orig_name = 'name'
+
+ gzio.orig_name.should == 'name'
+ end
+ end
+
+ it "raises an error on a closed stream" do
+ Zlib::GzipWriter.wrap @io do |gzio|
+ gzio.close
+
+ -> { gzio.orig_name }.should.raise(Zlib::GzipFile::Error, 'closed gzip stream')
+ end
+ end
+end