summaryrefslogtreecommitdiff
path: root/spec/ruby/library
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library')
-rw-r--r--spec/ruby/library/bigdecimal/remainder_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/round_spec.rb4
-rw-r--r--spec/ruby/library/bigdecimal/to_s_spec.rb9
-rw-r--r--spec/ruby/library/date/deconstruct_keys_spec.rb2
-rw-r--r--spec/ruby/library/date/strftime_spec.rb4
-rw-r--r--spec/ruby/library/datetime/deconstruct_keys_spec.rb2
-rw-r--r--spec/ruby/library/datetime/strftime_spec.rb4
-rw-r--r--spec/ruby/library/datetime/to_time_spec.rb3
-rw-r--r--spec/ruby/library/erb/new_spec.rb2
-rw-r--r--spec/ruby/library/ipaddr/new_spec.rb10
-rw-r--r--spec/ruby/library/logger/device/close_spec.rb15
-rw-r--r--spec/ruby/library/logger/device/write_spec.rb15
-rw-r--r--spec/ruby/library/matrix/unitary_spec.rb6
-rw-r--r--spec/ruby/library/openssl/config/freeze_spec.rb22
-rw-r--r--spec/ruby/library/stringio/initialize_spec.rb13
-rw-r--r--spec/ruby/library/stringio/shared/each.rb4
-rw-r--r--spec/ruby/library/time/to_datetime_spec.rb3
-rw-r--r--spec/ruby/library/uri/generic/host_spec.rb2
-rw-r--r--spec/ruby/library/uri/generic/to_s_spec.rb2
19 files changed, 43 insertions, 81 deletions
diff --git a/spec/ruby/library/bigdecimal/remainder_spec.rb b/spec/ruby/library/bigdecimal/remainder_spec.rb
index 35e131a0dc..bac5f37ba9 100644
--- a/spec/ruby/library/bigdecimal/remainder_spec.rb
+++ b/spec/ruby/library/bigdecimal/remainder_spec.rb
@@ -54,7 +54,7 @@ describe "BigDecimal#remainder" do
@nan.remainder(@infinity).should.nan?
end
- version_is BigDecimal::VERSION, ""..."3.1.4" do
+ version_is BigDecimal::VERSION, ""..."3.1.4" do #ruby_version_is ""..."3.3" do
it "returns NaN if Infinity is involved" do
@infinity.remainder(@infinity).should.nan?
@infinity.remainder(@one).should.nan?
diff --git a/spec/ruby/library/bigdecimal/round_spec.rb b/spec/ruby/library/bigdecimal/round_spec.rb
index bfc6dbc763..fba52df65d 100644
--- a/spec/ruby/library/bigdecimal/round_spec.rb
+++ b/spec/ruby/library/bigdecimal/round_spec.rb
@@ -228,13 +228,13 @@ describe "BigDecimal#round" do
-> { BigDecimal('-Infinity').round(2) }.should_not raise_error(FloatDomainError)
end
- ruby_version_is ''...'3.2' do
+ version_is BigDecimal::VERSION, ''...'3.1.3' do #ruby_version_is ''...'3.2' do
it 'raise for a non-existent round mode' do
-> { @p1_50.round(0, :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode")
end
end
- ruby_version_is '3.2' do
+ version_is BigDecimal::VERSION, '3.1.3' do #ruby_version_is '3.2' do
it 'raise for a non-existent round mode' do
-> { @p1_50.round(0, :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode (nonsense)")
end
diff --git a/spec/ruby/library/bigdecimal/to_s_spec.rb b/spec/ruby/library/bigdecimal/to_s_spec.rb
index 3d03c498fb..63dfaf5e7c 100644
--- a/spec/ruby/library/bigdecimal/to_s_spec.rb
+++ b/spec/ruby/library/bigdecimal/to_s_spec.rb
@@ -40,14 +40,13 @@ describe "BigDecimal#to_s" do
end
ruby_version_is ""..."3.3" do
- it "inserts a space every n chars, if integer n is supplied" do
+ it "inserts a space every n chars to fraction part, if integer n is supplied" do
re =\
/\A0\.314 159 265 358 979 323 846 264 338 327 950 288 419 716 939 937E1\z/i
@bigdec.to_s(3).should =~ re
str1 = '-123.45678 90123 45678 9'
BigDecimal("-123.45678901234567890").to_s('5F').should == str1
- BigDecimal('1000010').to_s('5F').should == "10000 10.0"
# trailing zeroes removed
BigDecimal("1.00000000000").to_s('1F').should == "1.0"
# 0 is treated as no spaces
@@ -55,6 +54,12 @@ describe "BigDecimal#to_s" do
end
end
+ version_is BigDecimal::VERSION, "3.1.5" do #ruby_version_is '3.3' do
+ it "inserts a space every n chars to integer part, if integer n is supplied" do
+ BigDecimal('1000010').to_s('5F').should == "10 00010.0"
+ end
+ end
+
it "can return a leading space for values > 0" do
@bigdec.to_s(" F").should =~ /\ .*/
@bigneg.to_s(" F").should_not =~ /\ .*/
diff --git a/spec/ruby/library/date/deconstruct_keys_spec.rb b/spec/ruby/library/date/deconstruct_keys_spec.rb
index fc9caaf332..94b528099f 100644
--- a/spec/ruby/library/date/deconstruct_keys_spec.rb
+++ b/spec/ruby/library/date/deconstruct_keys_spec.rb
@@ -1,7 +1,7 @@
require_relative '../../spec_helper'
require 'date'
-ruby_version_is "3.2" do
+version_is Date::VERSION, "3.3" do #ruby_version_is "3.2" do
describe "Date#deconstruct_keys" do
it "returns whole hash for nil as an argument" do
d = Date.new(2022, 10, 5)
diff --git a/spec/ruby/library/date/strftime_spec.rb b/spec/ruby/library/date/strftime_spec.rb
index 33ecc4ce9d..fc6c1dae8d 100644
--- a/spec/ruby/library/date/strftime_spec.rb
+++ b/spec/ruby/library/date/strftime_spec.rb
@@ -23,14 +23,14 @@ describe "Date#strftime" do
end
# %v is %e-%b-%Y for Date/DateTime
- ruby_version_is ""..."3.1" do
+ version_is Date::VERSION, ""..."3.2" do #ruby_version_is ""..."3.1" do
it "should be able to show the commercial week" do
@date.strftime("%v").should == " 9-Apr-2000"
@date.strftime("%v").should == @date.strftime('%e-%b-%Y')
end
end
- ruby_version_is "3.1" do
+ version_is Date::VERSION, "3.2" do #ruby_version_is "3.1" do
it "should be able to show the commercial week" do
@date.strftime("%v").should == " 9-APR-2000"
@date.strftime("%v").should != @date.strftime('%e-%b-%Y')
diff --git a/spec/ruby/library/datetime/deconstruct_keys_spec.rb b/spec/ruby/library/datetime/deconstruct_keys_spec.rb
index c6c0f71f55..95a391cdd8 100644
--- a/spec/ruby/library/datetime/deconstruct_keys_spec.rb
+++ b/spec/ruby/library/datetime/deconstruct_keys_spec.rb
@@ -1,7 +1,7 @@
require_relative '../../spec_helper'
require 'date'
-ruby_version_is "3.2" do
+version_is Date::VERSION, "3.3" do #ruby_version_is "3.2" do
describe "DateTime#deconstruct_keys" do
it "returns whole hash for nil as an argument" do
d = DateTime.new(2022, 10, 5, 13, 30)
diff --git a/spec/ruby/library/datetime/strftime_spec.rb b/spec/ruby/library/datetime/strftime_spec.rb
index 725bcafb0d..847098cb50 100644
--- a/spec/ruby/library/datetime/strftime_spec.rb
+++ b/spec/ruby/library/datetime/strftime_spec.rb
@@ -33,14 +33,14 @@ describe "DateTime#strftime" do
end
# %v is %e-%b-%Y for Date/DateTime
- ruby_version_is ""..."3.1" do
+ version_is Date::VERSION, ""..."3.2" do #ruby_version_is ""..."3.1" do
it "should be able to show the commercial week" do
@time.strftime("%v").should == " 3-Feb-2001"
@time.strftime("%v").should == @time.strftime('%e-%b-%Y')
end
end
- ruby_version_is "3.1" do
+ version_is Date::VERSION, "3.2" do #ruby_version_is "3.1" do
it "should be able to show the commercial week" do
@time.strftime("%v").should == " 3-FEB-2001"
@time.strftime("%v").should != @time.strftime('%e-%b-%Y')
diff --git a/spec/ruby/library/datetime/to_time_spec.rb b/spec/ruby/library/datetime/to_time_spec.rb
index 95eca864da..84990d511c 100644
--- a/spec/ruby/library/datetime/to_time_spec.rb
+++ b/spec/ruby/library/datetime/to_time_spec.rb
@@ -18,8 +18,7 @@ describe "DateTime#to_time" do
time.sec.should == 59
end
- date_version = defined?(Date::VERSION) ? Date::VERSION : '0.0.0'
- version_is(date_version, '3.2.3') do
+ version_is(Date::VERSION, '3.2.3') do #ruby_version_is "3.2" do
it "returns a Time representing the same instant before Gregorian" do
datetime = DateTime.civil(1582, 10, 4, 23, 58, 59)
time = datetime.to_time.utc
diff --git a/spec/ruby/library/erb/new_spec.rb b/spec/ruby/library/erb/new_spec.rb
index 4d7f7bf36a..a5aeeaeed1 100644
--- a/spec/ruby/library/erb/new_spec.rb
+++ b/spec/ruby/library/erb/new_spec.rb
@@ -140,7 +140,7 @@ END
end
describe "warning about arguments" do
- ruby_version_is "3.1" do
+ version_is ERB.version, "2.2.1" do #ruby_version_is "3.1" do
it "warns when passed safe_level and later arguments" do
-> {
ERB.new(@eruby_str, nil, '%')
diff --git a/spec/ruby/library/ipaddr/new_spec.rb b/spec/ruby/library/ipaddr/new_spec.rb
index 053928c3cf..714c1e2f1a 100644
--- a/spec/ruby/library/ipaddr/new_spec.rb
+++ b/spec/ruby/library/ipaddr/new_spec.rb
@@ -77,7 +77,13 @@ describe "IPAddr#new" do
a.family.should == Socket::AF_INET6
end
- ruby_version_is ""..."3.1" do
+ ipaddr_version = if defined?(IPAddr::VERSION) #ruby_version_is ""..."3.1" do
+ IPAddr::VERSION
+ else
+ "1.2.2"
+ end
+
+ version_is ipaddr_version, ""..."1.2.3" do #ruby_version_is ""..."3.1" do
it "raises on incorrect IPAddr strings" do
[
["fe80::1%fxp0"],
@@ -93,7 +99,7 @@ describe "IPAddr#new" do
end
end
- ruby_version_is "3.1" do
+ version_is ipaddr_version, "1.2.3" do #ruby_version_is "3.1" do
it "raises on incorrect IPAddr strings" do
[
["::1/255.255.255.0"],
diff --git a/spec/ruby/library/logger/device/close_spec.rb b/spec/ruby/library/logger/device/close_spec.rb
index 7c5e118d56..1db5d582a7 100644
--- a/spec/ruby/library/logger/device/close_spec.rb
+++ b/spec/ruby/library/logger/device/close_spec.rb
@@ -15,17 +15,8 @@ describe "Logger::LogDevice#close" do
rm_r @file_path
end
- version_is Logger::VERSION, ""..."1.4.0" do
- it "closes the LogDevice's stream" do
- @device.close
- -> { @device.write("Test") }.should complain(/\Alog writing failed\./)
- end
- end
-
- version_is Logger::VERSION, "1.4.0" do
- it "closes the LogDevice's stream" do
- @device.close
- -> { @device.write("Test") }.should complain(/\Alog shifting failed\./)
- end
+ it "closes the LogDevice's stream" do
+ @device.close
+ -> { @device.write("Test") }.should complain(/\Alog shifting failed\./)
end
end
diff --git a/spec/ruby/library/logger/device/write_spec.rb b/spec/ruby/library/logger/device/write_spec.rb
index cd2d7e27a9..87ecf2ad6a 100644
--- a/spec/ruby/library/logger/device/write_spec.rb
+++ b/spec/ruby/library/logger/device/write_spec.rb
@@ -35,17 +35,8 @@ describe "Logger::LogDevice#write" do
rm_r path
end
- version_is Logger::VERSION, ""..."1.4.0" do
- it "fails if the device is already closed" do
- @device.close
- -> { @device.write "foo" }.should complain(/\Alog writing failed\./)
- end
- end
-
- version_is Logger::VERSION, "1.4.0" do
- it "fails if the device is already closed" do
- @device.close
- -> { @device.write "foo" }.should complain(/\Alog shifting failed\./)
- end
+ it "fails if the device is already closed" do
+ @device.close
+ -> { @device.write "foo" }.should complain(/\Alog shifting failed\./)
end
end
diff --git a/spec/ruby/library/matrix/unitary_spec.rb b/spec/ruby/library/matrix/unitary_spec.rb
index b579cb244d..04e6df8be0 100644
--- a/spec/ruby/library/matrix/unitary_spec.rb
+++ b/spec/ruby/library/matrix/unitary_spec.rb
@@ -14,10 +14,8 @@ ruby_version_is ""..."3.1" do
Matrix[[0, Complex(0, 1)], [Complex(0, 1), 0]].should.unitary?
end
- version_is((Matrix::const_defined?(:VERSION) ? Matrix::VERSION : "0.1.0"), "0.3.0") do
- it "returns true for unitary matrices with a Complex and a negative #imag" do
- Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].should.unitary?
- end
+ it "returns true for unitary matrices with a Complex and a negative #imag" do
+ Matrix[[0, Complex(0, 1)], [Complex(0, -1), 0]].should.unitary?
end
it "raises an error for rectangular matrices" do
diff --git a/spec/ruby/library/openssl/config/freeze_spec.rb b/spec/ruby/library/openssl/config/freeze_spec.rb
deleted file mode 100644
index c814341b86..0000000000
--- a/spec/ruby/library/openssl/config/freeze_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require_relative '../../../spec_helper'
-require_relative '../shared/constants'
-
-require 'openssl'
-
-version_is(OpenSSL::VERSION, ""..."2.2") do
- describe "OpenSSL::Config#freeze" do
- it "needs to be reviewed for completeness"
-
- it "freezes" do
- c = OpenSSL::Config.new
- -> {
- c['foo'] = [ ['key', 'value'] ]
- }.should_not raise_error
- c.freeze
- c.frozen?.should be_true
- -> {
- c['foo'] = [ ['key', 'value'] ]
- }.should raise_error(TypeError)
- end
- end
-end
diff --git a/spec/ruby/library/stringio/initialize_spec.rb b/spec/ruby/library/stringio/initialize_spec.rb
index c597e328d3..158c08488b 100644
--- a/spec/ruby/library/stringio/initialize_spec.rb
+++ b/spec/ruby/library/stringio/initialize_spec.rb
@@ -294,14 +294,9 @@ describe "StringIO#initialize sets" do
io.string.encoding.should == Encoding::EUC_JP
end
- guard_not -> { # [Bug #16497]
- stringio_version = StringIO.const_defined?(:VERSION) ? StringIO::VERSION : "0.0.2"
- version_is(stringio_version, "0.0.3"..."0.1.1")
- } do
- it "the #external_encoding to the encoding of the String when passed a String" do
- s = ''.force_encoding(Encoding::EUC_JP)
- io = StringIO.new(s)
- io.external_encoding.should == Encoding::EUC_JP
- end
+ it "the #external_encoding to the encoding of the String when passed a String" do
+ s = ''.force_encoding(Encoding::EUC_JP)
+ io = StringIO.new(s)
+ io.external_encoding.should == Encoding::EUC_JP
end
end
diff --git a/spec/ruby/library/stringio/shared/each.rb b/spec/ruby/library/stringio/shared/each.rb
index bf3265ee46..acd8d22c14 100644
--- a/spec/ruby/library/stringio/shared/each.rb
+++ b/spec/ruby/library/stringio/shared/each.rb
@@ -36,7 +36,7 @@ describe :stringio_each_separator, shared: true do
seen.should == ["2 1 2 1 2"]
end
- ruby_version_is ''..."3.2" do
+ version_is StringIO::VERSION, ""..."3.0.4" do #ruby_version_is ""..."3.2" do
it "yields each paragraph with two separation characters when passed an empty String as separator" do
seen = []
io = StringIO.new("para1\n\npara2\n\n\npara3")
@@ -45,7 +45,7 @@ describe :stringio_each_separator, shared: true do
end
end
- ruby_version_is "3.2" do
+ version_is StringIO::VERSION, "3.0.4" do #ruby_version_is "3.2" do
it "yields each paragraph with all separation characters when passed an empty String as separator" do
seen = []
io = StringIO.new("para1\n\npara2\n\n\npara3")
diff --git a/spec/ruby/library/time/to_datetime_spec.rb b/spec/ruby/library/time/to_datetime_spec.rb
index 6025950b59..6e4d67eb53 100644
--- a/spec/ruby/library/time/to_datetime_spec.rb
+++ b/spec/ruby/library/time/to_datetime_spec.rb
@@ -13,8 +13,7 @@ describe "Time#to_datetime" do
datetime.sec.should == 59
end
- date_version = defined?(Date::VERSION) ? Date::VERSION : '0.0.0'
- version_is(date_version, '3.2.3') do
+ version_is(Date::VERSION, '3.2.3') do #ruby_version_is '3.2' do
it "returns a DateTime representing the same instant before Gregorian" do
time = Time.utc(1582, 10, 14, 23, 58, 59)
datetime = time.to_datetime
diff --git a/spec/ruby/library/uri/generic/host_spec.rb b/spec/ruby/library/uri/generic/host_spec.rb
index 2de0e7ec09..210124ef66 100644
--- a/spec/ruby/library/uri/generic/host_spec.rb
+++ b/spec/ruby/library/uri/generic/host_spec.rb
@@ -2,7 +2,7 @@ require_relative '../../../spec_helper'
require 'uri'
describe "URI::Generic#host" do
- ruby_version_is "3.2" do
+ version_is URI::VERSION, "0.12" do #ruby_version_is "3.2" do
# https://hackerone.com/reports/156615
it "returns empty string when host is empty" do
URI.parse('http:////foo.com').host.should == ''
diff --git a/spec/ruby/library/uri/generic/to_s_spec.rb b/spec/ruby/library/uri/generic/to_s_spec.rb
index 1dd1f2d134..8cebd374a1 100644
--- a/spec/ruby/library/uri/generic/to_s_spec.rb
+++ b/spec/ruby/library/uri/generic/to_s_spec.rb
@@ -2,7 +2,7 @@ require_relative '../../../spec_helper'
require 'uri'
describe "URI::Generic#to_s" do
- ruby_version_is "3.2" do
+ version_is URI::VERSION, "0.12" do #ruby_version_is "3.2" do
# https://hackerone.com/reports/156615
it "preserves / characters when host is empty" do
URI('http:///foo.com').to_s.should == 'http:///foo.com'