summaryrefslogtreecommitdiff
path: root/spec/ruby/library
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library')
-rw-r--r--spec/ruby/library/base64/decode64_spec.rb16
-rw-r--r--spec/ruby/library/base64/encode64_spec.rb9
-rw-r--r--spec/ruby/library/base64/strict_decode64_spec.rb41
-rw-r--r--spec/ruby/library/base64/strict_encode64_spec.rb19
-rw-r--r--spec/ruby/library/bigdecimal/BigDecimal_spec.rb99
-rw-r--r--spec/ruby/library/conditionvariable/signal_spec.rb35
-rw-r--r--spec/ruby/library/coverage/result_spec.rb5
-rw-r--r--spec/ruby/library/date/iso8601_spec.rb7
-rw-r--r--spec/ruby/library/date/rfc3339_spec.rb13
-rw-r--r--spec/ruby/library/mkmf/mkmf_spec.rb7
-rw-r--r--spec/ruby/library/rbconfig/rbconfig_spec.rb12
-rw-r--r--spec/ruby/library/rbconfig/sizeof/limits_spec.rb42
-rw-r--r--spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb22
-rw-r--r--spec/ruby/library/rbconfig/unicode_version_spec.rb34
-rw-r--r--spec/ruby/library/scanf/io/scanf_spec.rb4
-rw-r--r--spec/ruby/library/scanf/io/shared/block_scanf.rb2
-rw-r--r--spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb46
-rw-r--r--spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb45
-rw-r--r--spec/ruby/library/socket/tcpserver/new_spec.rb35
-rw-r--r--spec/ruby/library/uri/select_spec.rb8
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/new_spec.rb15
-rw-r--r--spec/ruby/library/zlib/deflate/append_spec.rb1
-rw-r--r--spec/ruby/library/zlib/deflate/flush_spec.rb1
-rw-r--r--spec/ruby/library/zlib/deflate_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gunzip_spec.rb14
-rw-r--r--spec/ruby/library/zlib/gzip_spec.rb15
-rw-r--r--spec/ruby/library/zlib/gzipfile/crc_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/finish_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/level_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/mtime_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/os_code_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/sync_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/to_io_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipfile/wrap_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_byte_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_line_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/eof_spec.rb6
-rw-r--r--spec/ruby/library/zlib/gzipreader/getc_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipreader/gets_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/lineno_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/open_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/pos_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipreader/read_spec.rb4
-rw-r--r--spec/ruby/library/zlib/gzipreader/readchar_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/readline_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/readlines_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/readpartial_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/rewind_spec.rb3
-rw-r--r--spec/ruby/library/zlib/gzipreader/shared/each.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/tell_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/ungetc_spec.rb2
-rw-r--r--spec/ruby/library/zlib/gzipreader/unused_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/comment_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/flush_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/new_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/open_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/orig_name_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/pos_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/print_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/printf_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/putc_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/puts_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/tell_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipwriter/write_spec.rb2
-rw-r--r--spec/ruby/library/zlib/inflate/sync_point_spec.rb1
-rw-r--r--spec/ruby/library/zlib/inflate/sync_spec.rb1
-rw-r--r--spec/ruby/library/zlib/inflate_spec.rb2
-rw-r--r--spec/ruby/library/zlib/zlib_version_spec.rb7
-rw-r--r--spec/ruby/library/zlib/zstream/close_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/closed_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/end_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/ended_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/finish_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/finished_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/flush_next_in_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/reset_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/stream_end_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/total_in_spec.rb1
-rw-r--r--spec/ruby/library/zlib/zstream/total_out_spec.rb1
81 files changed, 549 insertions, 87 deletions
diff --git a/spec/ruby/library/base64/decode64_spec.rb b/spec/ruby/library/base64/decode64_spec.rb
index 3b81203588..f6cd26d788 100644
--- a/spec/ruby/library/base64/decode64_spec.rb
+++ b/spec/ruby/library/base64/decode64_spec.rb
@@ -6,4 +6,20 @@ describe "Base64#decode64" do
it "returns the Base64-decoded version of the given string" do
Base64.decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n").should == "Send reinforcements"
end
+
+ it "returns the Base64-decoded version of the given shared string" do
+ Base64.decode64("base64: U2VuZCByZWluZm9yY2VtZW50cw==\n".split(" ").last).should == "Send reinforcements"
+ end
+
+ it "returns the Base64-decoded version of the given string with wrong padding" do
+ Base64.decode64("XU2VuZCByZWluZm9yY2VtZW50cw===").should == "]M\x95\xB9\x90\x81\xC9\x95\xA5\xB9\x99\xBD\xC9\x8D\x95\xB5\x95\xB9\xD1\xCC".b
+ end
+
+ it "returns the Base64-decoded version of the given string that contains an invalid character" do
+ Base64.decode64("%3D").should == "\xDC".b
+ end
+
+ it "returns a binary encoded string" do
+ Base64.decode64("SEk=").encoding.should == Encoding::BINARY
+ end
end
diff --git a/spec/ruby/library/base64/encode64_spec.rb b/spec/ruby/library/base64/encode64_spec.rb
index 91ac41bed0..64de6257bc 100644
--- a/spec/ruby/library/base64/encode64_spec.rb
+++ b/spec/ruby/library/base64/encode64_spec.rb
@@ -11,4 +11,13 @@ describe "Base64#encode64" do
it "returns the Base64-encoded version of the given string" do
Base64.encode64('Send reinforcements').should == "U2VuZCByZWluZm9yY2VtZW50cw==\n"
end
+
+ it "returns the Base64-encoded version of the given shared string" do
+ Base64.encode64("Now is the time for all good coders\nto learn Ruby".split("\n").last).should ==
+ "dG8gbGVhcm4gUnVieQ==\n"
+ end
+
+ it "returns a US_ASCII encoded string" do
+ Base64.encode64("HI").encoding.should == Encoding::US_ASCII
+ end
end
diff --git a/spec/ruby/library/base64/strict_decode64_spec.rb b/spec/ruby/library/base64/strict_decode64_spec.rb
new file mode 100644
index 0000000000..d258223c82
--- /dev/null
+++ b/spec/ruby/library/base64/strict_decode64_spec.rb
@@ -0,0 +1,41 @@
+require_relative '../../spec_helper'
+
+require 'base64'
+
+describe "Base64#strict_decode64" do
+ it "returns the Base64-decoded version of the given string" do
+ Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==").should == "Send reinforcements"
+ end
+
+ it "returns the Base64-decoded version of the given shared string" do
+ Base64.strict_decode64("base64: U2VuZCByZWluZm9yY2VtZW50cw==".split(" ").last).should == "Send reinforcements"
+ end
+
+ it "raises ArgumentError when the given string contains CR" do
+ -> do
+ Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==\r")
+ end.should raise_error(ArgumentError)
+ end
+
+ it "raises ArgumentError when the given string contains LF" do
+ -> do
+ Base64.strict_decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n")
+ end.should raise_error(ArgumentError)
+ end
+
+ it "raises ArgumentError when the given string has wrong padding" do
+ -> do
+ Base64.strict_decode64("=U2VuZCByZWluZm9yY2VtZW50cw==")
+ end.should raise_error(ArgumentError)
+ end
+
+ it "raises ArgumentError when the given string contains an invalid character" do
+ -> do
+ Base64.strict_decode64("%3D")
+ end.should raise_error(ArgumentError)
+ end
+
+ it "returns a binary encoded string" do
+ Base64.strict_decode64("SEk=").encoding.should == Encoding::BINARY
+ end
+end
diff --git a/spec/ruby/library/base64/strict_encode64_spec.rb b/spec/ruby/library/base64/strict_encode64_spec.rb
new file mode 100644
index 0000000000..7cabcf190c
--- /dev/null
+++ b/spec/ruby/library/base64/strict_encode64_spec.rb
@@ -0,0 +1,19 @@
+require_relative '../../spec_helper'
+
+require 'base64'
+
+describe "Base64#strict_encode64" do
+ it "returns the Base64-encoded version of the given string" do
+ Base64.strict_encode64("Now is the time for all good coders\nto learn Ruby").should ==
+ "Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4gUnVieQ=="
+ end
+
+ it "returns the Base64-encoded version of the given shared string" do
+ Base64.strict_encode64("Now is the time for all good coders\nto learn Ruby".split("\n").last).should ==
+ "dG8gbGVhcm4gUnVieQ=="
+ end
+
+ it "returns a US_ASCII encoded string" do
+ Base64.strict_encode64("HI").encoding.should == Encoding::US_ASCII
+ end
+end
diff --git a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
index e1e6fe9fb1..179bde1aed 100644
--- a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
+++ b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
@@ -24,6 +24,12 @@ describe "Kernel#BigDecimal" do
}
end
+ it "BigDecimal(Rational) with bigger-than-double numerator" do
+ rational = 99999999999999999999/100r
+ rational.numerator.should > 2**64
+ BigDecimal(rational, 100).to_s.should == "0.99999999999999999999e18"
+ end
+
it "accepts significant digits >= given precision" do
BigDecimal("3.1415923", 10).precs[1].should >= 10
end
@@ -33,8 +39,8 @@ describe "Kernel#BigDecimal" do
BigDecimal(pi_string).precs[1].should >= pi_string.size-1
end
- it "ignores leading whitespace" do
- BigDecimal(" \t\n \r1234").should == BigDecimal("1234")
+ it "ignores leading and trailing whitespace" do
+ BigDecimal(" \t\n \r1234\t\r\n ").should == BigDecimal("1234")
BigDecimal(" \t\n \rNaN \n").nan?.should == true
BigDecimal(" \t\n \rInfinity \n").infinite?.should == 1
BigDecimal(" \t\n \r-Infinity \n").infinite?.should == -1
@@ -159,4 +165,93 @@ describe "Kernel#BigDecimal" do
BigDecimal(0.0, Float::DIG).sign.should == 1
end
+ it "pre-coerces long integers" do
+ BigDecimal(3).add(1 << 50, 3).should == BigDecimal('0.113e16')
+ end
+
+ describe "when interacting with Rational" do
+ before :each do
+ @a = BigDecimal('166.666666666')
+ @b = Rational(500, 3)
+ @c = @a - @b
+ end
+
+ # Check the input is as we understand it
+
+ it "has the LHS print as expected" do
+ @a.to_s.should == "0.166666666666e3"
+ @a.to_f.to_s.should == "166.666666666"
+ Float(@a).to_s.should == "166.666666666"
+ end
+
+ it "has the RHS print as expected" do
+ @b.to_s.should == "500/3"
+ @b.to_f.to_s.should == "166.66666666666666"
+ Float(@b).to_s.should == "166.66666666666666"
+ end
+
+ it "has the expected precision on the LHS" do
+ @a.precs[0].should == 18
+ end
+
+ it "has the expected maximum precision on the LHS" do
+ @a.precs[1].should == 27
+ end
+
+ it "produces the expected result when done via Float" do
+ (Float(@a) - Float(@b)).to_s.should == "-6.666596163995564e-10"
+ end
+
+ it "produces the expected result when done via to_f" do
+ (@a.to_f - @b.to_f).to_s.should == "-6.666596163995564e-10"
+ end
+
+ # Check underlying methods work as we understand
+
+ it "BigDecimal precision is the number of digits rounded up to a multiple of nine" do
+ 1.upto(100) do |n|
+ b = BigDecimal('4' * n)
+ precs, _ = b.precs
+ (precs >= 9).should be_true
+ (precs >= n).should be_true
+ (precs % 9).should == 0
+ end
+ BigDecimal('NaN').precs[0].should == 9
+ end
+
+ it "BigDecimal maximum precision is nine more than precision except for abnormals" do
+ 1.upto(100) do |n|
+ b = BigDecimal('4' * n)
+ precs, max = b.precs
+ max.should == precs + 9
+ end
+ BigDecimal('NaN').precs[1].should == 9
+ end
+
+ it "BigDecimal(Rational, 18) produces the result we expect" do
+ BigDecimal(@b, 18).to_s.should == "0.166666666666666667e3"
+ end
+
+ it "BigDecimal(Rational, BigDecimal.precs[0]) produces the result we expect" do
+ BigDecimal(@b, @a.precs[0]).to_s.should == "0.166666666666666667e3"
+ end
+
+ # Check the top-level expression works as we expect
+
+ it "produces a BigDecimal" do
+ @c.class.should == BigDecimal
+ end
+
+ it "produces the expected result" do
+ @c.should == BigDecimal("-0.666667e-9")
+ @c.to_s.should == "-0.666667e-9"
+ end
+
+ it "produces the correct class for other arithmetic operators" do
+ (@a + @b).class.should == BigDecimal
+ (@a * @b).class.should == BigDecimal
+ (@a / @b).class.should == BigDecimal
+ (@a % @b).class.should == BigDecimal
+ end
+ end
end
diff --git a/spec/ruby/library/conditionvariable/signal_spec.rb b/spec/ruby/library/conditionvariable/signal_spec.rb
index 0dafe8527f..04b249a6c6 100644
--- a/spec/ruby/library/conditionvariable/signal_spec.rb
+++ b/spec/ruby/library/conditionvariable/signal_spec.rb
@@ -66,4 +66,39 @@ describe "ConditionVariable#signal" do
# released in the same order
r2.should == r1
end
+
+ it "allows control to be passed between a pair of threads" do
+ m = Mutex.new
+ cv = ConditionVariable.new
+ repeats = 100
+ in_synchronize = false
+
+ t1 = Thread.new do
+ m.synchronize do
+ in_synchronize = true
+ repeats.times do
+ cv.wait(m)
+ cv.signal
+ end
+ end
+ end
+
+ # Make sure t1 is waiting for a signal before launching t2.
+ Thread.pass until in_synchronize
+ Thread.pass until t1.status == 'sleep'
+
+ t2 = Thread.new do
+ m.synchronize do
+ repeats.times do
+ cv.signal
+ cv.wait(m)
+ end
+ end
+ end
+
+ # Check that both threads terminated without exception
+ t1.join
+ t2.join
+ m.locked?.should == false
+ end
end
diff --git a/spec/ruby/library/coverage/result_spec.rb b/spec/ruby/library/coverage/result_spec.rb
index ebfa5538b4..9b84530076 100644
--- a/spec/ruby/library/coverage/result_spec.rb
+++ b/spec/ruby/library/coverage/result_spec.rb
@@ -35,8 +35,9 @@ describe 'Coverage.result' do
Coverage.start
require @class_file.chomp('.rb')
Coverage.result
- -> { Coverage.result }
- .should raise_error(RuntimeError, 'coverage measurement is not enabled')
+ -> {
+ Coverage.result
+ }.should raise_error(RuntimeError, 'coverage measurement is not enabled')
end
it 'second run should give same result' do
diff --git a/spec/ruby/library/date/iso8601_spec.rb b/spec/ruby/library/date/iso8601_spec.rb
index 21b0a4cedd..2c698db514 100644
--- a/spec/ruby/library/date/iso8601_spec.rb
+++ b/spec/ruby/library/date/iso8601_spec.rb
@@ -35,3 +35,10 @@ describe "Date.iso8601" do
-> { Date.iso8601(Object.new) }.should raise_error(TypeError)
end
end
+
+describe "Date._iso8601" do
+ it "returns an empty hash if the argument is a invalid Date" do
+ h = Date._iso8601('invalid')
+ h.should == {}
+ end
+end
diff --git a/spec/ruby/library/date/rfc3339_spec.rb b/spec/ruby/library/date/rfc3339_spec.rb
new file mode 100644
index 0000000000..a8711d47b2
--- /dev/null
+++ b/spec/ruby/library/date/rfc3339_spec.rb
@@ -0,0 +1,13 @@
+require_relative '../../spec_helper'
+require 'date'
+
+describe "Date.rfc3339" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "Date._rfc3339" do
+ it "returns an empty hash if the argument is a invalid Date" do
+ h = Date._rfc3339('invalid')
+ h.should == {}
+ end
+end
diff --git a/spec/ruby/library/mkmf/mkmf_spec.rb b/spec/ruby/library/mkmf/mkmf_spec.rb
new file mode 100644
index 0000000000..18b090e703
--- /dev/null
+++ b/spec/ruby/library/mkmf/mkmf_spec.rb
@@ -0,0 +1,7 @@
+require_relative '../../spec_helper'
+
+describe 'mkmf' do
+ it 'can be required with --enable-frozen-string-literal' do
+ ruby_exe('p MakeMakefile', options: '-rmkmf --enable-frozen-string-literal').should == "MakeMakefile\n"
+ end
+end
diff --git a/spec/ruby/library/rbconfig/rbconfig_spec.rb b/spec/ruby/library/rbconfig/rbconfig_spec.rb
index 7c3fbf6c58..35b465d106 100644
--- a/spec/ruby/library/rbconfig/rbconfig_spec.rb
+++ b/spec/ruby/library/rbconfig/rbconfig_spec.rb
@@ -23,6 +23,18 @@ describe 'RbConfig::CONFIG' do
File.should.exist?("#{archdir}/etc.#{RbConfig::CONFIG['DLEXT']}")
end
end
+
+ it "contains no frozen strings even with --enable-frozen-string-literal" do
+ ruby_exe(<<-RUBY, options: '--enable-frozen-string-literal').should == "Done\n"
+ require 'rbconfig'
+ RbConfig::CONFIG.each do |k, v|
+ if v.frozen?
+ puts "\#{k} Failure"
+ end
+ end
+ puts 'Done'
+ RUBY
+ end
end
describe "RbConfig::TOPDIR" do
diff --git a/spec/ruby/library/rbconfig/sizeof/limits_spec.rb b/spec/ruby/library/rbconfig/sizeof/limits_spec.rb
new file mode 100644
index 0000000000..a026135eee
--- /dev/null
+++ b/spec/ruby/library/rbconfig/sizeof/limits_spec.rb
@@ -0,0 +1,42 @@
+require_relative '../../../spec_helper'
+require 'rbconfig/sizeof'
+
+ruby_version_is "2.5" do
+ describe "RbConfig::LIMITS" do
+ it "is a Hash" do
+ RbConfig::LIMITS.should be_kind_of(Hash)
+ end
+
+ it "has string keys and numeric values" do
+ RbConfig::LIMITS.each do |key, value|
+ key.should be_kind_of String
+ value.should be_kind_of Numeric
+ end
+ end
+
+ it "contains FIXNUM_MIN and FIXNUM_MAX" do
+ RbConfig::LIMITS["FIXNUM_MIN"].should < 0
+ RbConfig::LIMITS["FIXNUM_MAX"].should > 0
+ end
+
+ it "contains CHAR_MIN and CHAR_MAX" do
+ RbConfig::LIMITS["CHAR_MIN"].should <= 0
+ RbConfig::LIMITS["CHAR_MAX"].should > 0
+ end
+
+ it "contains SHRT_MIN and SHRT_MAX" do
+ RbConfig::LIMITS["SHRT_MIN"].should == -32768
+ RbConfig::LIMITS["SHRT_MAX"].should == 32767
+ end
+
+ it "contains INT_MIN and INT_MAX" do
+ RbConfig::LIMITS["INT_MIN"].should < 0
+ RbConfig::LIMITS["INT_MAX"].should > 0
+ end
+
+ it "contains LONG_MIN and LONG_MAX" do
+ RbConfig::LIMITS["LONG_MIN"].should < 0
+ RbConfig::LIMITS["LONG_MAX"].should > 0
+ end
+ end
+end
diff --git a/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb b/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb
new file mode 100644
index 0000000000..d3df8b7313
--- /dev/null
+++ b/spec/ruby/library/rbconfig/unicode_emoji_version_spec.rb
@@ -0,0 +1,22 @@
+require_relative '../../spec_helper'
+require 'rbconfig'
+
+describe "RbConfig::CONFIG['UNICODE_EMOJI_VERSION']" do
+ ruby_version_is "2.6"..."2.6.2" do
+ it "is 11.0 for Ruby 2.6.0 and 2.6.1" do
+ RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "11.0"
+ end
+ end
+
+ ruby_version_is "2.6.2"..."2.7" do
+ it "is 12.0 for Ruby 2.6.2+" do
+ RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "12.0"
+ end
+ end
+
+ ruby_version_is "2.7" do
+ it "is 12.1 for Ruby 2.7" do
+ RbConfig::CONFIG['UNICODE_EMOJI_VERSION'].should == "12.1"
+ end
+ end
+end
diff --git a/spec/ruby/library/rbconfig/unicode_version_spec.rb b/spec/ruby/library/rbconfig/unicode_version_spec.rb
new file mode 100644
index 0000000000..44216700c8
--- /dev/null
+++ b/spec/ruby/library/rbconfig/unicode_version_spec.rb
@@ -0,0 +1,34 @@
+require_relative '../../spec_helper'
+require 'rbconfig'
+
+describe "RbConfig::CONFIG['UNICODE_VERSION']" do
+ ruby_version_is ""..."2.5" do
+ it "is 9.0.0 for Ruby 2.4" do
+ RbConfig::CONFIG['UNICODE_VERSION'].should == "9.0.0"
+ end
+ end
+
+ ruby_version_is "2.5"..."2.6" do
+ it "is 10.0.0 for Ruby 2.5" do
+ RbConfig::CONFIG['UNICODE_VERSION'].should == "10.0.0"
+ end
+ end
+
+ ruby_version_is "2.6"..."2.6.2" do
+ it "is 11.0.0 for Ruby 2.6.0 and 2.6.1" do
+ RbConfig::CONFIG['UNICODE_VERSION'].should == "11.0.0"
+ end
+ end
+
+ ruby_version_is "2.6.2"..."2.6.3" do
+ it "is 12.0.0 for Ruby 2.6.2" do
+ RbConfig::CONFIG['UNICODE_VERSION'].should == "12.0.0"
+ end
+ end
+
+ ruby_version_is "2.6.3" do
+ it "is 12.1.0 for Ruby 2.6.3+ and Ruby 2.7" do
+ RbConfig::CONFIG['UNICODE_VERSION'].should == "12.1.0"
+ end
+ end
+end
diff --git a/spec/ruby/library/scanf/io/scanf_spec.rb b/spec/ruby/library/scanf/io/scanf_spec.rb
index 6a1fd66780..6a3e6d0d1a 100644
--- a/spec/ruby/library/scanf/io/scanf_spec.rb
+++ b/spec/ruby/library/scanf/io/scanf_spec.rb
@@ -6,8 +6,8 @@ ruby_version_is ''...'2.7' do
describe "IO#scanf" do
before :each do
- @hw = File.open(fixture(__FILE__, 'helloworld.txt'), 'r')
- @data = File.open(fixture(__FILE__, 'date.txt'), 'r')
+ @hw = File.open(fixture(__FILE__, 'helloworld.txt'), 'rb')
+ @data = File.open(fixture(__FILE__, 'date.txt'), 'rb')
end
after :each do
diff --git a/spec/ruby/library/scanf/io/shared/block_scanf.rb b/spec/ruby/library/scanf/io/shared/block_scanf.rb
index 2031f4c2b7..d938f43734 100644
--- a/spec/ruby/library/scanf/io/shared/block_scanf.rb
+++ b/spec/ruby/library/scanf/io/shared/block_scanf.rb
@@ -2,7 +2,7 @@ require 'scanf'
describe :scanf_io_block_scanf, shared: true do
before :each do
- @data = File.open(fixture(__FILE__, 'date.txt'), 'r')
+ @data = File.open(fixture(__FILE__, 'date.txt'), 'rb')
end
after :each do
diff --git a/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb
new file mode 100644
index 0000000000..1823f3d75d
--- /dev/null
+++ b/spec/ruby/library/socket/basicsocket/read_nonblock_spec.rb
@@ -0,0 +1,46 @@
+require_relative '../spec_helper'
+require_relative '../fixtures/classes'
+
+ruby_version_is "2.5" do
+ describe "BasicSocket#read_nonblock" do
+ SocketSpecs.each_ip_protocol do |family, ip_address|
+ before :each do
+ @r = Socket.new(family, :DGRAM)
+ @w = Socket.new(family, :DGRAM)
+
+ @r.bind(Socket.pack_sockaddr_in(0, ip_address))
+ @w.send("aaa", 0, @r.getsockname)
+ end
+
+ after :each do
+ @r.close unless @r.closed?
+ @w.close unless @w.closed?
+ end
+
+ it "receives data after it's ready" do
+ IO.select([@r], nil, nil, 2)
+ @r.recv_nonblock(5).should == "aaa"
+ end
+
+ platform_is :linux do
+ it 'does not set the IO in nonblock mode' do
+ require 'io/nonblock'
+ @r.nonblock?.should == false
+ IO.select([@r], nil, nil, 2)
+ @r.read_nonblock(3).should == "aaa"
+ @r.nonblock?.should == false
+ end
+ end
+
+ platform_is_not :linux, :windows do
+ it 'sets the IO in nonblock mode' do
+ require 'io/nonblock'
+ @r.nonblock?.should == false
+ IO.select([@r], nil, nil, 2)
+ @r.read_nonblock(3).should == "aaa"
+ @r.nonblock?.should == true
+ end
+ end
+ end
+ end
+end
diff --git a/spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb
new file mode 100644
index 0000000000..f2e7366eb1
--- /dev/null
+++ b/spec/ruby/library/socket/basicsocket/write_nonblock_spec.rb
@@ -0,0 +1,45 @@
+require_relative '../spec_helper'
+require_relative '../fixtures/classes'
+
+ruby_version_is "2.5" do
+ describe "BasicSocket#write_nonblock" do
+ SocketSpecs.each_ip_protocol do |family, ip_address|
+ before :each do
+ @r = Socket.new(family, :DGRAM)
+ @w = Socket.new(family, :DGRAM)
+
+ @r.bind(Socket.pack_sockaddr_in(0, ip_address))
+ @w.connect(@r.getsockname)
+ end
+
+ after :each do
+ @r.close unless @r.closed?
+ @w.close unless @w.closed?
+ end
+
+ it "sends data" do
+ @w.write_nonblock("aaa").should == 3
+ IO.select([@r], nil, nil, 2)
+ @r.recv_nonblock(5).should == "aaa"
+ end
+
+ platform_is :linux do
+ it 'does not set the IO in nonblock mode' do
+ require 'io/nonblock'
+ @w.nonblock?.should == false
+ @w.write_nonblock("aaa").should == 3
+ @w.nonblock?.should == false
+ end
+ end
+
+ platform_is_not :linux, :windows do
+ it 'sets the IO in nonblock mode' do
+ require 'io/nonblock'
+ @w.nonblock?.should == false
+ @w.write_nonblock("aaa").should == 3
+ @w.nonblock?.should == true
+ end
+ end
+ end
+ end
+end
diff --git a/spec/ruby/library/socket/tcpserver/new_spec.rb b/spec/ruby/library/socket/tcpserver/new_spec.rb
index d099f0175f..8d9696c9d8 100644
--- a/spec/ruby/library/socket/tcpserver/new_spec.rb
+++ b/spec/ruby/library/socket/tcpserver/new_spec.rb
@@ -48,6 +48,24 @@ describe "TCPServer.new" do
addr[3].should == '0.0.0.0'
end
+ it "binds to a port if the port is explicitly nil" do
+ @server = TCPServer.new('', nil)
+ addr = @server.addr
+ addr[0].should == 'AF_INET'
+ addr[1].should be_kind_of(Integer)
+ addr[2].should == '0.0.0.0'
+ addr[3].should == '0.0.0.0'
+ end
+
+ it "binds to a port if the port is an empty string" do
+ @server = TCPServer.new('', '')
+ addr = @server.addr
+ addr[0].should == 'AF_INET'
+ addr[1].should be_kind_of(Integer)
+ addr[2].should == '0.0.0.0'
+ addr[3].should == '0.0.0.0'
+ end
+
it "coerces port to string, then determines port from that number or service name" do
-> { TCPServer.new(SocketSpecs.hostname, Object.new) }.should raise_error(TypeError)
@@ -62,6 +80,23 @@ describe "TCPServer.new" do
# pick such a service port that will be able to reliably bind...
end
+ it "has a single argument form and treats it as a port number" do
+ @server = TCPServer.new(0)
+ addr = @server.addr
+ addr[1].should be_kind_of(Integer)
+ end
+
+ it "coerces port to a string when it is the only argument" do
+ -> { TCPServer.new(Object.new) }.should raise_error(TypeError)
+
+ port = Object.new
+ port.should_receive(:to_str).and_return("0")
+
+ @server = TCPServer.new(port)
+ addr = @server.addr
+ addr[1].should be_kind_of(Integer)
+ end
+
it "raises Errno::EADDRNOTAVAIL when the address is unknown" do
-> { TCPServer.new("1.2.3.4", 0) }.should raise_error(Errno::EADDRNOTAVAIL)
end
diff --git a/spec/ruby/library/uri/select_spec.rb b/spec/ruby/library/uri/select_spec.rb
index c2eb6f8733..839b68b3a1 100644
--- a/spec/ruby/library/uri/select_spec.rb
+++ b/spec/ruby/library/uri/select_spec.rb
@@ -15,12 +15,8 @@ describe "URI#select" do
end
it "raises an ArgumentError if a component is requested that isn't valid under the given scheme" do
- [
- -> {URI("mailto:spam@mailinator.com").select(:path)},
- -> {URI("http://blog.blag.web").select(:typecode)},
- ].each do |select_lambda|
- select_lambda.should raise_error(ArgumentError)
- end
+ -> { URI("mailto:spam@mailinator.com").select(:path) }.should raise_error(ArgumentError)
+ -> { URI("http://blog.blag.web").select(:typecode) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if given strings rather than symbols" do
diff --git a/spec/ruby/library/win32ole/win32ole_type/new_spec.rb b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb
index fab690c2dd..3c3aa1c390 100644
--- a/spec/ruby/library/win32ole/win32ole_type/new_spec.rb
+++ b/spec/ruby/library/win32ole/win32ole_type/new_spec.rb
@@ -12,15 +12,18 @@ platform_is :windows do
it "raises TypeError if second argument is not a String" do
-> { WIN32OLE_TYPE.new(1,2) }.should raise_error TypeError
- -> { WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation',2) }.
- should raise_error TypeError
+ -> {
+ WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation',2)
+ }.should raise_error TypeError
end
it "raise WIN32OLERuntimeError if OLE object specified is not found" do
- -> { WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation','foo') }.
- should raise_error WIN32OLERuntimeError
- -> { WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation','Application') }.
- should raise_error WIN32OLERuntimeError
+ -> {
+ WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation','foo')
+ }.should raise_error WIN32OLERuntimeError
+ -> {
+ WIN32OLE_TYPE.new('Microsoft Shell Controls And Automation','Application')
+ }.should raise_error WIN32OLERuntimeError
end
it "creates WIN32OLE_TYPE object from name and valid type" do
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/deflate/append_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/deflate/flush_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
diff --git a/spec/ruby/library/zlib/deflate_spec.rb b/spec/ruby/library/zlib/deflate_spec.rb
index 01538dd4e6..6eeaa164c5 100644
--- a/spec/ruby/library/zlib/deflate_spec.rb
+++ b/spec/ruby/library/zlib/deflate_spec.rb
@@ -1,7 +1,7 @@
require_relative '../../spec_helper'
require "zlib"
-describe "Zlib#deflate" do
+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
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/crc_spec.rb b/spec/ruby/library/zlib/gzipfile/crc_spec.rb
deleted file mode 100644
index e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipfile/crc_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipfile/finish_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipfile/level_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipfile/mtime_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipfile/os_code_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipfile/sync_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipfile/to_io_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipfile/wrap_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
diff --git a/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb b/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb
index d2c43ecaa4..48821dc833 100644
--- a/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/each_byte_spec.rb
@@ -2,7 +2,7 @@ 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_line_spec.rb b/spec/ruby/library/zlib/gzipreader/each_line_spec.rb
index b576788e27..efaf27d6bb 100644
--- a/spec/ruby/library/zlib/gzipreader/each_line_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/each_line_spec.rb
@@ -1,5 +1,5 @@
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 f9b90be316..59aa63e52c 100644
--- a/spec/ruby/library/zlib/gzipreader/each_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/each_spec.rb
@@ -1,5 +1,5 @@
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 e33d8e3133..673220fdfd 100644
--- a/spec/ruby/library/zlib/gzipreader/eof_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/eof_spec.rb
@@ -2,8 +2,7 @@ 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,
@@ -49,8 +48,7 @@ describe "GzipReader#eof?" do
gz.read(1).should == @data[i, 1]
end
gz.eof?.should be_true
- gz.read().should == ""
+ gz.read.should == ""
gz.eof?.should be_true
end
-
end
diff --git a/spec/ruby/library/zlib/gzipreader/getc_spec.rb b/spec/ruby/library/zlib/gzipreader/getc_spec.rb
index 90b5ffe37a..e567231940 100644
--- a/spec/ruby/library/zlib/gzipreader/getc_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/getc_spec.rb
@@ -2,8 +2,7 @@ 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,
@@ -37,5 +36,4 @@ describe "GzipReader#getc" do
gz.getc.should be_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 8e4465e49c..d3a2e7d263 100644
--- a/spec/ruby/library/zlib/gzipreader/gets_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/gets_spec.rb
@@ -2,7 +2,7 @@ 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"
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipreader/lineno_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipreader/open_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
diff --git a/spec/ruby/library/zlib/gzipreader/pos_spec.rb b/spec/ruby/library/zlib/gzipreader/pos_spec.rb
index df7c78ad8f..8586faec92 100644
--- a/spec/ruby/library/zlib/gzipreader/pos_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/pos_spec.rb
@@ -2,8 +2,7 @@ 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,5 +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 a13f087fe9..b81954b5ce 100644
--- a/spec/ruby/library/zlib/gzipreader/read_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/read_spec.rb
@@ -2,8 +2,7 @@ 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,
@@ -64,5 +63,4 @@ describe "GzipReader#read" do
gz.read(2**16).should be_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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipreader/readchar_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipreader/readline_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipreader/readlines_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
diff --git a/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb b/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb
index a367e5b856..559ce9f841 100644
--- a/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/readpartial_spec.rb
@@ -2,7 +2,7 @@ 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 2e22458b43..b31abb6abf 100644
--- a/spec/ruby/library/zlib/gzipreader/rewind_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/rewind_spec.rb
@@ -2,8 +2,7 @@ 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 11c15d8a66..71608e04ab 100644
--- a/spec/ruby/library/zlib/gzipreader/shared/each.rb
+++ b/spec/ruby/library/zlib/gzipreader/shared/each.rb
@@ -3,7 +3,6 @@ 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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipreader/tell_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
diff --git a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
index 6fb6915f15..7fa0608f9f 100644
--- a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
@@ -2,7 +2,7 @@ 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,
diff --git a/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb b/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
index d19ec61610..34f2a1a2ca 100644
--- a/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
@@ -2,7 +2,7 @@ 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,
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipreader/unused_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipwriter/comment_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipwriter/flush_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipwriter/new_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipwriter/open_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipwriter/orig_name_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipwriter/pos_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipwriter/print_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipwriter/printf_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipwriter/putc_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipwriter/puts_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/gzipwriter/tell_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
diff --git a/spec/ruby/library/zlib/gzipwriter/write_spec.rb b/spec/ruby/library/zlib/gzipwriter/write_spec.rb
index f694ce7cb7..522ae7f2aa 100644
--- a/spec/ruby/library/zlib/gzipwriter/write_spec.rb
+++ b/spec/ruby/library/zlib/gzipwriter/write_spec.rb
@@ -2,7 +2,7 @@ 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/sync_point_spec.rb b/spec/ruby/library/zlib/inflate/sync_point_spec.rb
deleted file mode 100644
index e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/inflate/sync_point_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/inflate/sync_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
diff --git a/spec/ruby/library/zlib/inflate_spec.rb b/spec/ruby/library/zlib/inflate_spec.rb
index 393bea4f3c..42c8dc5fbe 100644
--- a/spec/ruby/library/zlib/inflate_spec.rb
+++ b/spec/ruby/library/zlib/inflate_spec.rb
@@ -1,7 +1,7 @@
require_relative '../../spec_helper'
require "zlib"
-describe "Zlib#inflate" do
+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
diff --git a/spec/ruby/library/zlib/zlib_version_spec.rb b/spec/ruby/library/zlib/zlib_version_spec.rb
index e724feaa39..f83dfae66d 100644
--- a/spec/ruby/library/zlib/zlib_version_spec.rb
+++ b/spec/ruby/library/zlib/zlib_version_spec.rb
@@ -1 +1,8 @@
require_relative '../../spec_helper'
+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)
+ end
+end
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/zstream/close_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/zstream/closed_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/zstream/end_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/zstream/ended_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/zstream/finish_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/zstream/finished_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/zstream/flush_next_in_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/zstream/reset_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/zstream/stream_end_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/zstream/total_in_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'
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 e15f14f95f..0000000000
--- a/spec/ruby/library/zlib/zstream/total_out_spec.rb
+++ /dev/null
@@ -1 +0,0 @@
-require_relative '../../../spec_helper'