diff options
Diffstat (limited to 'spec/ruby/library')
34 files changed, 293 insertions, 353 deletions
diff --git a/spec/ruby/library/base64/urlsafe_decode64_spec.rb b/spec/ruby/library/base64/urlsafe_decode64_spec.rb index 3c1e72f961..1b813ee1b9 100644 --- a/spec/ruby/library/base64/urlsafe_decode64_spec.rb +++ b/spec/ruby/library/base64/urlsafe_decode64_spec.rb @@ -13,15 +13,7 @@ describe "Base64#urlsafe_decode64" do decoded.should == '"Being disintegrated makes me ve-ry an-gry!" <huff, huff>' end - ruby_version_is ""..."2.3" do - it "requires padding" do - lambda { Base64.urlsafe_decode64("MQ") }.should raise_error(ArgumentError) - end - end - - ruby_version_is "2.3" do - it "does not require padding" do - Base64.urlsafe_decode64("MQ").should == "1" - end + it "does not require padding" do + Base64.urlsafe_decode64("MQ").should == "1" end end diff --git a/spec/ruby/library/base64/urlsafe_encode64_spec.rb b/spec/ruby/library/base64/urlsafe_encode64_spec.rb index e47a53add8..de1f235cea 100644 --- a/spec/ruby/library/base64/urlsafe_encode64_spec.rb +++ b/spec/ruby/library/base64/urlsafe_encode64_spec.rb @@ -13,10 +13,8 @@ describe "Base64#urlsafe_encode64" do encoded.should == 'IkJlaW5nIGRpc2ludGVncmF0ZWQgbWFrZXMgbWUgdmUtcnkgYW4tZ3J5ISIgPGh1ZmYsIGh1ZmY-' end - ruby_version_is "2.3" do - it "makes padding optional" do - Base64.urlsafe_encode64("1", padding: false).should == "MQ" - Base64.urlsafe_encode64("1").should == "MQ==" - end + it "makes padding optional" do + Base64.urlsafe_encode64("1", padding: false).should == "MQ" + Base64.urlsafe_encode64("1").should == "MQ==" end end diff --git a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb new file mode 100644 index 0000000000..d278512737 --- /dev/null +++ b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb @@ -0,0 +1,109 @@ +require_relative '../../spec_helper' +require 'bigdecimal' + +describe "Kernel#BigDecimal" do + + it "creates a new object of class BigDecimal" do + BigDecimal("3.14159").should be_kind_of(BigDecimal) + (0..9).each {|i| + BigDecimal("1#{i}").should == 10 + i + BigDecimal("-1#{i}").should == -10 - i + BigDecimal("1E#{i}").should == 10**i + BigDecimal("1000000E-#{i}").should == 10**(6-i).to_f + # ^ to_f to avoid Rational type + } + (1..9).each {|i| + BigDecimal("100.#{i}").to_s.should =~ /\A0\.100#{i}E3\z/i + BigDecimal("-100.#{i}").to_s.should =~ /\A-0\.100#{i}E3\z/i + } + end + + it "accepts significant digits >= given precision" do + BigDecimal("3.1415923", 10).precs[1].should >= 10 + end + + it "determines precision from initial value" do + pi_string = "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593014782083152134043" + BigDecimal(pi_string).precs[1].should >= pi_string.size-1 + end + + it "ignores leading whitespace" do + BigDecimal(" \t\n \r1234").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 + end + + it "ignores trailing garbage" do + BigDecimal("123E45ruby").should == BigDecimal("123E45") + BigDecimal("123x45").should == BigDecimal("123") + BigDecimal("123.4%E5").should == BigDecimal("123.4") + BigDecimal("1E2E3E4E5E").should == BigDecimal("100") + end + + ruby_version_is ""..."2.4" do + it "treats invalid strings as 0.0" do + BigDecimal("ruby").should == BigDecimal("0.0") + BigDecimal(" \t\n \r-\t\t\tInfinity \n").should == BigDecimal("0.0") + end + end + + ruby_version_is "2.4" do + it "raises ArgumentError for invalid strings" do + lambda { BigDecimal("ruby") }.should raise_error(ArgumentError) + lambda { BigDecimal(" \t\n \r-\t\t\tInfinity \n") }.should raise_error(ArgumentError) + end + end + + it "allows omitting the integer part" do + BigDecimal(".123").should == BigDecimal("0.123") + end + + it "allows for underscores in all parts" do + reference = BigDecimal("12345.67E89") + + BigDecimal("12_345.67E89").should == reference + BigDecimal("1_2_3_4_5_._6____7_E89").should == reference + BigDecimal("12345_.67E_8__9_").should == reference + end + + it "accepts NaN and [+-]Infinity" do + BigDecimal("NaN").nan?.should == true + + pos_inf = BigDecimal("Infinity") + pos_inf.finite?.should == false + pos_inf.should > 0 + pos_inf.should == BigDecimal("+Infinity") + + neg_inf = BigDecimal("-Infinity") + neg_inf.finite?.should == false + neg_inf.should < 0 + end + + it "allows for [eEdD] as exponent separator" do + reference = BigDecimal("12345.67E89") + + BigDecimal("12345.67e89").should == reference + BigDecimal("12345.67E89").should == reference + BigDecimal("12345.67d89").should == reference + BigDecimal("12345.67D89").should == reference + end + + it "allows for varying signs" do + reference = BigDecimal("123.456E1") + + BigDecimal("+123.456E1").should == reference + BigDecimal("-123.456E1").should == -reference + BigDecimal("123.456E+1").should == reference + BigDecimal("12345.6E-1").should == reference + BigDecimal("+123.456E+1").should == reference + BigDecimal("+12345.6E-1").should == reference + BigDecimal("-123.456E+1").should == -reference + BigDecimal("-12345.6E-1").should == -reference + end + + it 'raises ArgumentError when Float is used without precision' do + lambda { BigDecimal(1.0) }.should raise_error(ArgumentError) + end + +end diff --git a/spec/ruby/library/bigdecimal/divmod_spec.rb b/spec/ruby/library/bigdecimal/divmod_spec.rb index a93e0836bf..22b66c2d48 100644 --- a/spec/ruby/library/bigdecimal/divmod_spec.rb +++ b/spec/ruby/library/bigdecimal/divmod_spec.rb @@ -36,7 +36,7 @@ describe "BigDecimal#mod_part_of_divmod" do it_behaves_like :bigdecimal_modulo, :mod_part_of_divmod it "raises ZeroDivisionError if other is zero" do - bd5667 = BigDecimal.new("5667.19") + bd5667 = BigDecimal("5667.19") lambda { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError) lambda { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError) @@ -96,8 +96,8 @@ describe "BigDecimal#divmod" do it "can be reversed with * and +" do # Example taken from BigDecimal documentation - a = BigDecimal.new("42") - b = BigDecimal.new("9") + a = BigDecimal("42") + b = BigDecimal("9") q, m = a.divmod(b) c = q * b + m a.should == c diff --git a/spec/ruby/library/bigdecimal/inspect_spec.rb b/spec/ruby/library/bigdecimal/inspect_spec.rb index 0873e8bef6..7e1a8297e2 100644 --- a/spec/ruby/library/bigdecimal/inspect_spec.rb +++ b/spec/ruby/library/bigdecimal/inspect_spec.rb @@ -4,7 +4,7 @@ require 'bigdecimal' describe "BigDecimal#inspect" do before :each do - @bigdec = BigDecimal.new("1234.5678") + @bigdec = BigDecimal("1234.5678") end it "returns String" do diff --git a/spec/ruby/library/bigdecimal/limit_spec.rb b/spec/ruby/library/bigdecimal/limit_spec.rb index 7fd395dd50..75cbc8b55c 100644 --- a/spec/ruby/library/bigdecimal/limit_spec.rb +++ b/spec/ruby/library/bigdecimal/limit_spec.rb @@ -42,4 +42,14 @@ describe "BigDecimal.limit" do BigDecimal('0.888').div(BigDecimal('3'), 2).should == BigDecimal('0.30') end end + + it "picks the global precision when limit 0 specified" do + BigDecimalSpecs.with_limit(3) do + BigDecimal('0.8888').add(BigDecimal('0'), 0).should == BigDecimal('0.889') + BigDecimal('0.8888').sub(BigDecimal('0'), 0).should == BigDecimal('0.889') + BigDecimal('0.888').mult(BigDecimal('3'), 0).should == BigDecimal('2.66') + BigDecimal('0.8888').div(BigDecimal('3'), 0).should == BigDecimal('0.296') + end + end + end diff --git a/spec/ruby/library/bigdecimal/new_spec.rb b/spec/ruby/library/bigdecimal/new_spec.rb deleted file mode 100644 index 64f2a7f468..0000000000 --- a/spec/ruby/library/bigdecimal/new_spec.rb +++ /dev/null @@ -1,109 +0,0 @@ -require_relative '../../spec_helper' -require 'bigdecimal' - -describe "BigDecimal.new" do - - it "creates a new object of class BigDecimal" do - BigDecimal.new("3.14159").should be_kind_of(BigDecimal) - (0..9).each {|i| - BigDecimal.new("1#{i}").should == 10 + i - BigDecimal.new("-1#{i}").should == -10 - i - BigDecimal.new("1E#{i}").should == 10**i - BigDecimal.new("1000000E-#{i}").should == 10**(6-i).to_f - # ^ to_f to avoid Rational type - } - (1..9).each {|i| - BigDecimal.new("100.#{i}").to_s.should =~ /\A0\.100#{i}E3\z/i - BigDecimal.new("-100.#{i}").to_s.should =~ /\A-0\.100#{i}E3\z/i - } - end - - it "accepts significant digits >= given precision" do - BigDecimal.new("3.1415923", 10).precs[1].should >= 10 - end - - it "determines precision from initial value" do - pi_string = "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593014782083152134043" - BigDecimal.new(pi_string).precs[1].should >= pi_string.size-1 - end - - it "ignores leading whitespace" do - BigDecimal.new(" \t\n \r1234").should == BigDecimal.new("1234") - BigDecimal.new(" \t\n \rNaN \n").nan?.should == true - BigDecimal.new(" \t\n \rInfinity \n").infinite?.should == 1 - BigDecimal.new(" \t\n \r-Infinity \n").infinite?.should == -1 - end - - it "ignores trailing garbage" do - BigDecimal.new("123E45ruby").should == BigDecimal.new("123E45") - BigDecimal.new("123x45").should == BigDecimal.new("123") - BigDecimal.new("123.4%E5").should == BigDecimal.new("123.4") - BigDecimal.new("1E2E3E4E5E").should == BigDecimal.new("100") - end - - ruby_version_is ""..."2.4" do - it "treats invalid strings as 0.0" do - BigDecimal.new("ruby").should == BigDecimal.new("0.0") - BigDecimal.new(" \t\n \r-\t\t\tInfinity \n").should == BigDecimal.new("0.0") - end - end - - ruby_version_is "2.4" do - it "raises ArgumentError for invalid strings" do - lambda { BigDecimal.new("ruby") }.should raise_error(ArgumentError) - lambda { BigDecimal.new(" \t\n \r-\t\t\tInfinity \n") }.should raise_error(ArgumentError) - end - end - - it "allows omitting the integer part" do - BigDecimal.new(".123").should == BigDecimal.new("0.123") - end - - it "allows for underscores in all parts" do - reference = BigDecimal.new("12345.67E89") - - BigDecimal.new("12_345.67E89").should == reference - BigDecimal.new("1_2_3_4_5_._6____7_E89").should == reference - BigDecimal.new("12345_.67E_8__9_").should == reference - end - - it "accepts NaN and [+-]Infinity" do - BigDecimal.new("NaN").nan?.should == true - - pos_inf = BigDecimal.new("Infinity") - pos_inf.finite?.should == false - pos_inf.should > 0 - pos_inf.should == BigDecimal.new("+Infinity") - - neg_inf = BigDecimal.new("-Infinity") - neg_inf.finite?.should == false - neg_inf.should < 0 - end - - it "allows for [eEdD] as exponent separator" do - reference = BigDecimal.new("12345.67E89") - - BigDecimal.new("12345.67e89").should == reference - BigDecimal.new("12345.67E89").should == reference - BigDecimal.new("12345.67d89").should == reference - BigDecimal.new("12345.67D89").should == reference - end - - it "allows for varying signs" do - reference = BigDecimal.new("123.456E1") - - BigDecimal.new("+123.456E1").should == reference - BigDecimal.new("-123.456E1").should == -reference - BigDecimal.new("123.456E+1").should == reference - BigDecimal.new("12345.6E-1").should == reference - BigDecimal.new("+123.456E+1").should == reference - BigDecimal.new("+12345.6E-1").should == reference - BigDecimal.new("-123.456E+1").should == -reference - BigDecimal.new("-12345.6E-1").should == -reference - end - - it 'raises ArgumentError when Float is used without precision' do - lambda { BigDecimal(1.0) }.should raise_error(ArgumentError) - end - -end diff --git a/spec/ruby/library/bigdecimal/shared/eql.rb b/spec/ruby/library/bigdecimal/shared/eql.rb index eaad272e9a..8e3e388bab 100644 --- a/spec/ruby/library/bigdecimal/shared/eql.rb +++ b/spec/ruby/library/bigdecimal/shared/eql.rb @@ -2,8 +2,8 @@ require 'bigdecimal' describe :bigdecimal_eql, shared: true do before :each do - @bg6543_21 = BigDecimal.new("6543.21") - @bg5667_19 = BigDecimal.new("5667.19") + @bg6543_21 = BigDecimal("6543.21") + @bg5667_19 = BigDecimal("5667.19") @a = BigDecimal("1.0000000000000000000000000000000000000000005") @b = BigDecimal("1.00000000000000000000000000000000000000000005") @bigint = BigDecimal("1000.0") diff --git a/spec/ruby/library/bigdecimal/shared/modulo.rb b/spec/ruby/library/bigdecimal/shared/modulo.rb index 78ebe8360d..c9691cbf37 100644 --- a/spec/ruby/library/bigdecimal/shared/modulo.rb +++ b/spec/ruby/library/bigdecimal/shared/modulo.rb @@ -18,8 +18,8 @@ describe :bigdecimal_modulo, shared: true do end it "returns self modulo other" do - bd6543 = BigDecimal.new("6543.21") - bd5667 = BigDecimal.new("5667.19") + bd6543 = BigDecimal("6543.21") + bd5667 = BigDecimal("5667.19") a = BigDecimal("1.0000000000000000000000000000000000000000005") b = BigDecimal("1.00000000000000000000000000000000000000000005") @@ -107,7 +107,7 @@ end describe :bigdecimal_modulo_zerodivisionerror, shared: true do it "raises ZeroDivisionError if other is zero" do - bd5667 = BigDecimal.new("5667.19") + bd5667 = BigDecimal("5667.19") lambda { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError) lambda { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError) diff --git a/spec/ruby/library/bigdecimal/to_r_spec.rb b/spec/ruby/library/bigdecimal/to_r_spec.rb index e2956782bd..91d2b33993 100644 --- a/spec/ruby/library/bigdecimal/to_r_spec.rb +++ b/spec/ruby/library/bigdecimal/to_r_spec.rb @@ -8,7 +8,7 @@ describe "BigDecimal#to_r" do end it "returns a Rational with bignum values" do - r = BigDecimal.new("3.141592653589793238462643").to_r + r = BigDecimal("3.141592653589793238462643").to_r r.numerator.should eql(3141592653589793238462643) r.denominator.should eql(1000000000000000000000000) end diff --git a/spec/ruby/library/bigdecimal/to_s_spec.rb b/spec/ruby/library/bigdecimal/to_s_spec.rb index 86716c93fe..86ae1e61f6 100644 --- a/spec/ruby/library/bigdecimal/to_s_spec.rb +++ b/spec/ruby/library/bigdecimal/to_s_spec.rb @@ -34,11 +34,11 @@ describe "BigDecimal#to_s" do @bigdec.to_s(3).should =~ re str1 = '-123.45678 90123 45678 9' - BigDecimal.new("-123.45678901234567890").to_s('5F').should == str1 + BigDecimal("-123.45678901234567890").to_s('5F').should == str1 # trailing zeroes removed - BigDecimal.new("1.00000000000").to_s('1F').should == "1.0" + BigDecimal("1.00000000000").to_s('1F').should == "1.0" # 0 is treated as no spaces - BigDecimal.new("1.2345").to_s('0F').should == "1.2345" + BigDecimal("1.2345").to_s('0F').should == "1.2345" end it "can return a leading space for values > 0" do @@ -47,15 +47,15 @@ describe "BigDecimal#to_s" do end it "removes trailing spaces in floating point notation" do - BigDecimal.new('-123.45678901234567890').to_s('F').should == "-123.4567890123456789" - BigDecimal.new('1.2500').to_s('F').should == "1.25" - BigDecimal.new('0000.00000').to_s('F').should == "0.0" - BigDecimal.new('-00.000010000').to_s('F').should == "-0.00001" - BigDecimal.new("5.00000E-2").to_s("F").should == "0.05" + BigDecimal('-123.45678901234567890').to_s('F').should == "-123.4567890123456789" + BigDecimal('1.2500').to_s('F').should == "1.25" + BigDecimal('0000.00000').to_s('F').should == "0.0" + BigDecimal('-00.000010000').to_s('F').should == "-0.00001" + BigDecimal("5.00000E-2").to_s("F").should == "0.05" - BigDecimal.new("500000").to_s("F").should == "500000.0" - BigDecimal.new("5E2").to_s("F").should == "500.0" - BigDecimal.new("-5E100").to_s("F").should == "-5" + "0" * 100 + ".0" + BigDecimal("500000").to_s("F").should == "500000.0" + BigDecimal("5E2").to_s("F").should == "500.0" + BigDecimal("-5E100").to_s("F").should == "-5" + "0" * 100 + ".0" end it "can use engineering notation" do @@ -66,7 +66,7 @@ describe "BigDecimal#to_s" do @bigdec.to_s("F").should == @bigdec_str @bigneg.to_s("F").should == @bigneg_str str2 = "+123.45678901 23456789" - BigDecimal.new('123.45678901234567890').to_s('+8F').should == str2 + BigDecimal('123.45678901234567890').to_s('+8F').should == str2 end end diff --git a/spec/ruby/library/coverage/peek_result_spec.rb b/spec/ruby/library/coverage/peek_result_spec.rb index f10e85828e..897fc4d978 100644 --- a/spec/ruby/library/coverage/peek_result_spec.rb +++ b/spec/ruby/library/coverage/peek_result_spec.rb @@ -2,66 +2,64 @@ require_relative '../../spec_helper' require fixture __FILE__, 'spec_helper' require 'coverage' -ruby_version_is '2.3' do - describe 'Coverage.peek_result' do - before :all do - @class_file = fixture __FILE__, 'some_class.rb' - @second_class_file = fixture __FILE__, 'second_class.rb' - end +describe 'Coverage.peek_result' do + before :all do + @class_file = fixture __FILE__, 'some_class.rb' + @second_class_file = fixture __FILE__, 'second_class.rb' + end - after :each do - $LOADED_FEATURES.delete(@class_file) - $LOADED_FEATURES.delete(@second_class_file) - end + after :each do + $LOADED_FEATURES.delete(@class_file) + $LOADED_FEATURES.delete(@second_class_file) + end - it 'returns the result so far' do - Coverage.start - require @class_file.chomp('.rb') - result = Coverage.peek_result - Coverage.result + it 'returns the result so far' do + Coverage.start + require @class_file.chomp('.rb') + result = Coverage.peek_result + Coverage.result - result.should == { - @class_file => [ - nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil - ] - } - end + result.should == { + @class_file => [ + nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil + ] + } + end - it 'immediate second call returns same result' do - Coverage.start - require @class_file.chomp('.rb') - result1 = Coverage.peek_result - result2 = Coverage.peek_result - Coverage.result + it 'immediate second call returns same result' do + Coverage.start + require @class_file.chomp('.rb') + result1 = Coverage.peek_result + result2 = Coverage.peek_result + Coverage.result - result2.should == result1 - end + result2.should == result1 + end - it 'second call after require returns accumulated result' do - Coverage.start - require @class_file.chomp('.rb') - Coverage.peek_result - require @second_class_file.chomp('.rb') - result = Coverage.peek_result - Coverage.result + it 'second call after require returns accumulated result' do + Coverage.start + require @class_file.chomp('.rb') + Coverage.peek_result + require @second_class_file.chomp('.rb') + result = Coverage.peek_result + Coverage.result - result.should == { - @class_file => [ - nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil - ], - @second_class_file => [ - 1, 1, 0, nil, nil - ] - } - end + result.should == { + @class_file => [ + nil, nil, 1, nil, nil, 1, nil, nil, 0, nil, nil, nil, nil, nil, nil, nil + ], + @second_class_file => [ + 1, 1, 0, nil, nil + ] + } + end - it 'call right before Coverage.result should give equal result' do - Coverage.start - require @class_file.chomp('.rb') - result1 = Coverage.peek_result - result2 = Coverage.result + it 'call right before Coverage.result should give equal result' do + Coverage.start + require @class_file.chomp('.rb') + result1 = Coverage.peek_result + result2 = Coverage.result - result1.should == result2 - end + result1.should == result2 end end diff --git a/spec/ruby/library/date/minus_month_spec.rb b/spec/ruby/library/date/minus_month_spec.rb index b9b5e99bf2..563da073f0 100644 --- a/spec/ruby/library/date/minus_month_spec.rb +++ b/spec/ruby/library/date/minus_month_spec.rb @@ -13,13 +13,11 @@ describe "Date#<<" do d.should == Date.civil(2008, 2, 29) end - ruby_version_is "2.3" do - it "raises an error on non numeric parameters" do - lambda { Date.civil(2007,2,27) << :hello }.should raise_error(TypeError) - lambda { Date.civil(2007,2,27) << "hello" }.should raise_error(TypeError) - lambda { Date.civil(2007,2,27) << Date.new }.should raise_error(TypeError) - lambda { Date.civil(2007,2,27) << Object.new }.should raise_error(TypeError) - end + it "raises an error on non numeric parameters" do + lambda { Date.civil(2007,2,27) << :hello }.should raise_error(TypeError) + lambda { Date.civil(2007,2,27) << "hello" }.should raise_error(TypeError) + lambda { Date.civil(2007,2,27) << Date.new }.should raise_error(TypeError) + lambda { Date.civil(2007,2,27) << Object.new }.should raise_error(TypeError) end end diff --git a/spec/ruby/library/net/ftp/default_passive_spec.rb b/spec/ruby/library/net/ftp/default_passive_spec.rb index af8925fc1e..30eb8f9da2 100644 --- a/spec/ruby/library/net/ftp/default_passive_spec.rb +++ b/spec/ruby/library/net/ftp/default_passive_spec.rb @@ -1,10 +1,8 @@ require_relative '../../../spec_helper' require_relative 'spec_helper' -ruby_version_is "2.3" do - describe "Net::FTP#default_passive" do - it "is true by default" do - ruby_exe(fixture(__FILE__, "default_passive.rb")).should == "true\ntrue\n" - end +describe "Net::FTP#default_passive" do + it "is true by default" do + ruby_exe(fixture(__FILE__, "default_passive.rb")).should == "true\ntrue\n" end end diff --git a/spec/ruby/library/net/ftp/passive_spec.rb b/spec/ruby/library/net/ftp/passive_spec.rb index 041b9552d5..e8db030cbd 100644 --- a/spec/ruby/library/net/ftp/passive_spec.rb +++ b/spec/ruby/library/net/ftp/passive_spec.rb @@ -10,16 +10,8 @@ describe "Net::FTP#passive" do ftp.passive.should be_true end - ruby_version_is ""..."2.3" do - it "is false by default" do - ruby_exe(fixture(__FILE__, "passive.rb")).should == "false" - end - end - - ruby_version_is "2.3" do - it "is the value of Net::FTP.default_value by default" do - ruby_exe(fixture(__FILE__, "passive.rb")).should == "true" - end + it "is the value of Net::FTP.default_value by default" do + ruby_exe(fixture(__FILE__, "passive.rb")).should == "true" end end diff --git a/spec/ruby/library/net/http/http/open_timeout_spec.rb b/spec/ruby/library/net/http/http/open_timeout_spec.rb index 333ad5c5b5..44b33615e6 100644 --- a/spec/ruby/library/net/http/http/open_timeout_spec.rb +++ b/spec/ruby/library/net/http/http/open_timeout_spec.rb @@ -2,22 +2,11 @@ require_relative '../../../../spec_helper' require 'net/http' describe "Net::HTTP#open_timeout" do - ruby_version_is ""..."2.3" do - it "returns the seconds to wait till the connection is open" do - net = Net::HTTP.new("localhost") - net.open_timeout.should be_nil - net.open_timeout = 10 - net.open_timeout.should eql(10) - end - end - - ruby_version_is "2.3" do - it "returns the seconds to wait till the connection is open" do - net = Net::HTTP.new("localhost") - net.open_timeout.should eql(60) - net.open_timeout = 10 - net.open_timeout.should eql(10) - end + it "returns the seconds to wait till the connection is open" do + net = Net::HTTP.new("localhost") + net.open_timeout.should eql(60) + net.open_timeout = 10 + net.open_timeout.should eql(10) end end diff --git a/spec/ruby/library/rexml/element/namespaces_spec.rb b/spec/ruby/library/rexml/element/namespaces_spec.rb index 0fba0a1cf6..a84c1d1dab 100644 --- a/spec/ruby/library/rexml/element/namespaces_spec.rb +++ b/spec/ruby/library/rexml/element/namespaces_spec.rb @@ -28,4 +28,5 @@ describe "REXML::Element#namespaces" do values = ["2", "3", "1"] @elem.namespaces.values.sort.should == values.sort end + end diff --git a/spec/ruby/library/securerandom/random_number_spec.rb b/spec/ruby/library/securerandom/random_number_spec.rb index 67884f99bf..6b3279e6d7 100644 --- a/spec/ruby/library/securerandom/random_number_spec.rb +++ b/spec/ruby/library/securerandom/random_number_spec.rb @@ -31,34 +31,32 @@ describe "SecureRandom.random_number" do end end - ruby_version_is "2.3" do - it "generates a random value in given (integer) range limits" do - 64.times do - num = SecureRandom.random_number 11...13 - num.should be_kind_of(Integer) - (11 <= num).should == true - (num < 13).should == true - end + it "generates a random value in given (integer) range limits" do + 64.times do + num = SecureRandom.random_number 11...13 + num.should be_kind_of(Integer) + (11 <= num).should == true + (num < 13).should == true end + end - it "generates a random value in given big (integer) range limits" do - lower = 12345678901234567890 - upper = 12345678901234567890 + 5 - 32.times do - num = SecureRandom.random_number lower..upper - num.should be_kind_of(Integer) - (lower <= num).should == true - (num <= upper).should == true - end + it "generates a random value in given big (integer) range limits" do + lower = 12345678901234567890 + upper = 12345678901234567890 + 5 + 32.times do + num = SecureRandom.random_number lower..upper + num.should be_kind_of(Integer) + (lower <= num).should == true + (num <= upper).should == true end + end - it "generates a random value in given (float) range limits" do - 64.times do - num = SecureRandom.random_number 0.6..0.9 - num.should be_kind_of(Float) - (0.6 <= num).should == true - (num <= 0.9).should == true - end + it "generates a random value in given (float) range limits" do + 64.times do + num = SecureRandom.random_number 0.6..0.9 + num.should be_kind_of(Float) + (0.6 <= num).should == true + (num <= 0.9).should == true end end diff --git a/spec/ruby/library/socket/basicsocket/recv_spec.rb b/spec/ruby/library/socket/basicsocket/recv_spec.rb index d6418134c5..7677d4ff8c 100644 --- a/spec/ruby/library/socket/basicsocket/recv_spec.rb +++ b/spec/ruby/library/socket/basicsocket/recv_spec.rb @@ -76,21 +76,19 @@ describe "BasicSocket#recv" do ScratchPad.recorded.should == "firstline\377" end - ruby_version_is "2.3" do - it "allows an output buffer as third argument" do - socket = TCPSocket.new('127.0.0.1', @port) - socket.write("data") - - client = @server.accept - buf = "foo" - begin - client.recv(4, 0, buf) - ensure - client.close - end - buf.should == "data" + it "allows an output buffer as third argument" do + socket = TCPSocket.new('127.0.0.1', @port) + socket.write("data") - socket.close + client = @server.accept + buf = "foo" + begin + client.recv(4, 0, buf) + ensure + client.close end + buf.should == "data" + + socket.close end end diff --git a/spec/ruby/library/socket/shared/recv_nonblock.rb b/spec/ruby/library/socket/shared/recv_nonblock.rb index a5f6c6812e..2b584d52a2 100644 --- a/spec/ruby/library/socket/shared/recv_nonblock.rb +++ b/spec/ruby/library/socket/shared/recv_nonblock.rb @@ -30,16 +30,14 @@ describe :socket_recv_nonblock, shared: true do @s1.recv_nonblock(5).should == "aaa" end - ruby_version_is "2.3" do - it "allows an output buffer as third argument" do - @s1.bind(Socket.pack_sockaddr_in(0, "127.0.0.1")) - @s2.send("data", 0, @s1.getsockname) - IO.select([@s1], nil, nil, 2) + it "allows an output buffer as third argument" do + @s1.bind(Socket.pack_sockaddr_in(0, "127.0.0.1")) + @s2.send("data", 0, @s1.getsockname) + IO.select([@s1], nil, nil, 2) - buf = "foo" - @s1.recv_nonblock(5, 0, buf) - buf.should == "data" - end + buf = "foo" + @s1.recv_nonblock(5, 0, buf) + buf.should == "data" end it "does not block if there's no data available" do diff --git a/spec/ruby/library/socket/socket/accept_nonblock_spec.rb b/spec/ruby/library/socket/socket/accept_nonblock_spec.rb index b495cd934c..44f3be9c0e 100644 --- a/spec/ruby/library/socket/socket/accept_nonblock_spec.rb +++ b/spec/ruby/library/socket/socket/accept_nonblock_spec.rb @@ -29,9 +29,7 @@ describe "Socket#accept_nonblock" do } end - ruby_version_is '2.3' do - it 'returns :wait_readable in exceptionless mode' do - @socket.accept_nonblock(exception: false).should == :wait_readable - end + it 'returns :wait_readable in exceptionless mode' do + @socket.accept_nonblock(exception: false).should == :wait_readable end end diff --git a/spec/ruby/library/socket/socket/connect_nonblock_spec.rb b/spec/ruby/library/socket/socket/connect_nonblock_spec.rb index 98f4cd8aad..caac24401c 100644 --- a/spec/ruby/library/socket/socket/connect_nonblock_spec.rb +++ b/spec/ruby/library/socket/socket/connect_nonblock_spec.rb @@ -64,10 +64,8 @@ describe "Socket#connect_nonblock" do end.should raise_error(IO::WaitWritable) end - ruby_version_is "2.3" do - it "returns :wait_writable in exceptionless mode when the connect would block" do - @socket.connect_nonblock(@addr, exception: false).should == :wait_writable - end + it "returns :wait_writable in exceptionless mode when the connect would block" do + @socket.connect_nonblock(@addr, exception: false).should == :wait_writable end end end diff --git a/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb b/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb index be13630444..8566081d2f 100644 --- a/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb +++ b/spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb @@ -41,10 +41,8 @@ describe "Socket::TCPServer.accept_nonblock" do lambda { @server.accept_nonblock }.should raise_error(IO::WaitReadable) end - ruby_version_is '2.3' do - it 'returns :wait_readable in exceptionless mode' do - @server.accept_nonblock(exception: false).should == :wait_readable - end + it 'returns :wait_readable in exceptionless mode' do + @server.accept_nonblock(exception: false).should == :wait_readable end end end diff --git a/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb b/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb index 9ee7db8cf6..23bba526e8 100644 --- a/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb +++ b/spec/ruby/library/socket/tcpsocket/recv_nonblock_spec.rb @@ -27,10 +27,8 @@ describe "TCPSocket#recv_nonblock" do @socket.recv_nonblock(50).should == "TCPSocket#recv_nonblock" end - ruby_version_is '2.3' do - it 'returns :wait_readable in exceptionless mode' do - @socket = TCPSocket.new @hostname, @server.port - @socket.recv_nonblock(50, exception: false).should == :wait_readable - end + it 'returns :wait_readable in exceptionless mode' do + @socket = TCPSocket.new @hostname, @server.port + @socket.recv_nonblock(50, exception: false).should == :wait_readable end end diff --git a/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb b/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb index 7454297fd8..27603aeabd 100644 --- a/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb +++ b/spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb @@ -29,10 +29,8 @@ describe "UNIXServer#accept_nonblock" do @socket.should be_kind_of(UNIXSocket) end - ruby_version_is '2.3' do - it 'returns :wait_readable in exceptionless mode' do - @server.accept_nonblock(exception: false).should == :wait_readable - end + it 'returns :wait_readable in exceptionless mode' do + @server.accept_nonblock(exception: false).should == :wait_readable end end end diff --git a/spec/ruby/library/stringio/close_read_spec.rb b/spec/ruby/library/stringio/close_read_spec.rb index 48630e0a7b..05d6c9f7d2 100644 --- a/spec/ruby/library/stringio/close_read_spec.rb +++ b/spec/ruby/library/stringio/close_read_spec.rb @@ -26,11 +26,6 @@ describe "StringIO#close_read" do io = StringIO.new("example") io.close_read - ruby_version_is ''...'2.3' do - lambda { io.close_read }.should raise_error(IOError) - end - ruby_version_is '2.3' do - io.close_read.should == nil - end + io.close_read.should == nil end end diff --git a/spec/ruby/library/stringio/close_spec.rb b/spec/ruby/library/stringio/close_spec.rb index 592dfdf526..a5a931aff1 100644 --- a/spec/ruby/library/stringio/close_spec.rb +++ b/spec/ruby/library/stringio/close_spec.rb @@ -16,17 +16,8 @@ describe "StringIO#close" do lambda { @io.write('x') }.should raise_error(IOError) end - ruby_version_is ''...'2.3' do - it "raises an IOError when self was already closed" do - @io.close - lambda { @io.close }.should raise_error(IOError) - end - end - - ruby_version_is "2.3" do - it "does not raise anything when self was already closed" do - @io.close - lambda { @io.close }.should_not raise_error(IOError) - end + it "does not raise anything when self was already closed" do + @io.close + lambda { @io.close }.should_not raise_error(IOError) end end diff --git a/spec/ruby/library/stringio/close_write_spec.rb b/spec/ruby/library/stringio/close_write_spec.rb index f6292a9253..8a7ac12581 100644 --- a/spec/ruby/library/stringio/close_write_spec.rb +++ b/spec/ruby/library/stringio/close_write_spec.rb @@ -26,11 +26,6 @@ describe "StringIO#close_write" do io = StringIO.new("example") io.close_write - ruby_version_is ''...'2.3' do - lambda { io.close_write }.should raise_error(IOError) - end - ruby_version_is '2.3' do - io.close_write.should == nil - end + io.close_write.should == nil end end diff --git a/spec/ruby/library/stringio/external_encoding_spec.rb b/spec/ruby/library/stringio/external_encoding_spec.rb index 1a57081287..9c3d4041e5 100644 --- a/spec/ruby/library/stringio/external_encoding_spec.rb +++ b/spec/ruby/library/stringio/external_encoding_spec.rb @@ -8,14 +8,12 @@ describe "StringIO#external_encoding" do io.external_encoding.should == Encoding::EUC_JP end - ruby_version_is "2.3" do - it "does not set the encoding of its buffer string if the string is frozen" do - str = "foo".freeze - enc = str.encoding - io = StringIO.new(str) - io.set_encoding Encoding::EUC_JP - io.external_encoding.should == Encoding::EUC_JP - str.encoding.should == enc - end + it "does not set the encoding of its buffer string if the string is frozen" do + str = "foo".freeze + enc = str.encoding + io = StringIO.new(str) + io.set_encoding Encoding::EUC_JP + io.external_encoding.should == Encoding::EUC_JP + str.encoding.should == enc end end diff --git a/spec/ruby/library/stringio/read_nonblock_spec.rb b/spec/ruby/library/stringio/read_nonblock_spec.rb index 88728fcc18..7a79eef3c5 100644 --- a/spec/ruby/library/stringio/read_nonblock_spec.rb +++ b/spec/ruby/library/stringio/read_nonblock_spec.rb @@ -18,3 +18,12 @@ end describe "StringIO#read_nonblock when passed length" do it_behaves_like :stringio_sysread_length, :read_nonblock end + +describe "StringIO#read_nonblock" do + + it "accepts an exception option" do + stringio = StringIO.new('foo') + stringio.read_nonblock(3, exception: false).should == 'foo' + end + +end diff --git a/spec/ruby/library/thread/queue/close_spec.rb b/spec/ruby/library/thread/queue/close_spec.rb index 16c2d9d2e3..32bc0a32d7 100644 --- a/spec/ruby/library/thread/queue/close_spec.rb +++ b/spec/ruby/library/thread/queue/close_spec.rb @@ -2,8 +2,6 @@ require_relative '../../../spec_helper' require 'thread' require_relative '../shared/queue/close' -ruby_version_is "2.3" do - describe "Queue#close" do - it_behaves_like :queue_close, :close, -> { Queue.new } - end +describe "Queue#close" do + it_behaves_like :queue_close, :close, -> { Queue.new } end diff --git a/spec/ruby/library/thread/queue/closed_spec.rb b/spec/ruby/library/thread/queue/closed_spec.rb index 052c9320e0..df3596b14b 100644 --- a/spec/ruby/library/thread/queue/closed_spec.rb +++ b/spec/ruby/library/thread/queue/closed_spec.rb @@ -2,8 +2,6 @@ require_relative '../../../spec_helper' require 'thread' require_relative '../shared/queue/closed' -ruby_version_is "2.3" do - describe "Queue#closed?" do - it_behaves_like :queue_closed?, :closed?, -> { Queue.new } - end +describe "Queue#closed?" do + it_behaves_like :queue_closed?, :closed?, -> { Queue.new } end diff --git a/spec/ruby/library/thread/sizedqueue/close_spec.rb b/spec/ruby/library/thread/sizedqueue/close_spec.rb index 79ba87c127..3222772f61 100644 --- a/spec/ruby/library/thread/sizedqueue/close_spec.rb +++ b/spec/ruby/library/thread/sizedqueue/close_spec.rb @@ -2,8 +2,6 @@ require_relative '../../../spec_helper' require 'thread' require_relative '../shared/queue/close' -ruby_version_is "2.3" do - describe "SizedQueue#close" do - it_behaves_like :queue_close, :close, -> { SizedQueue.new(10) } - end +describe "SizedQueue#close" do + it_behaves_like :queue_close, :close, -> { SizedQueue.new(10) } end diff --git a/spec/ruby/library/thread/sizedqueue/closed_spec.rb b/spec/ruby/library/thread/sizedqueue/closed_spec.rb index 1cc68078c0..9e41b89640 100644 --- a/spec/ruby/library/thread/sizedqueue/closed_spec.rb +++ b/spec/ruby/library/thread/sizedqueue/closed_spec.rb @@ -2,8 +2,6 @@ require_relative '../../../spec_helper' require 'thread' require_relative '../shared/queue/closed' -ruby_version_is "2.3" do - describe "SizedQueue#closed?" do - it_behaves_like :queue_closed?, :closed?, -> { SizedQueue.new(10) } - end +describe "SizedQueue#closed?" do + it_behaves_like :queue_closed?, :closed?, -> { SizedQueue.new(10) } end |