aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/library
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library')
-rw-r--r--spec/ruby/library/bigdecimal/BigDecimal_spec.rb15
-rw-r--r--spec/ruby/library/bigdecimal/gt_spec.rb16
-rw-r--r--spec/ruby/library/bigdecimal/gte_spec.rb16
-rw-r--r--spec/ruby/library/bigdecimal/inspect_spec.rb34
-rw-r--r--spec/ruby/library/bigdecimal/lt_spec.rb16
-rw-r--r--spec/ruby/library/bigdecimal/lte_spec.rb16
-rw-r--r--spec/ruby/library/bigdecimal/round_spec.rb242
-rw-r--r--spec/ruby/library/bigdecimal/to_s_spec.rb12
-rw-r--r--spec/ruby/library/cgi/cookie/parse_spec.rb25
-rw-r--r--spec/ruby/library/conditionvariable/wait_spec.rb9
-rw-r--r--spec/ruby/library/coverage/fixtures/spec_helper.rb11
-rw-r--r--spec/ruby/library/coverage/peek_result_spec.rb1
-rw-r--r--spec/ruby/library/coverage/result_spec.rb15
-rw-r--r--spec/ruby/library/csv/liberal_parsing_spec.rb26
-rw-r--r--spec/ruby/library/csv/parse_spec.rb10
-rw-r--r--spec/ruby/library/csv/readlines_spec.rb12
-rw-r--r--spec/ruby/library/datetime/now_spec.rb4
-rw-r--r--spec/ruby/library/datetime/to_time_spec.rb24
-rw-r--r--spec/ruby/library/ipaddr/operator_spec.rb8
-rw-r--r--spec/ruby/library/logger/logger/new_spec.rb78
-rw-r--r--spec/ruby/library/net/ftp/initialize_spec.rb424
-rw-r--r--spec/ruby/library/net/ftp/status_spec.rb6
-rw-r--r--spec/ruby/library/net/http/http/post_spec.rb56
-rw-r--r--spec/ruby/library/optionparser/order_spec.rb36
-rw-r--r--spec/ruby/library/optionparser/parse_spec.rb36
-rw-r--r--spec/ruby/library/pathname/empty_spec.rb46
-rw-r--r--spec/ruby/library/rbconfig/rbconfig_spec.rb10
-rw-r--r--spec/ruby/library/rexml/element/element_reference_spec.rb14
-rw-r--r--spec/ruby/library/set/compare_by_identity_spec.rb268
-rw-r--r--spec/ruby/library/shellwords/shellwords_spec.rb8
-rw-r--r--spec/ruby/library/socket/fixtures/classes.rb8
-rw-r--r--spec/ruby/library/stringio/each_line_spec.rb6
-rw-r--r--spec/ruby/library/stringio/each_spec.rb6
-rw-r--r--spec/ruby/library/stringio/gets_spec.rb10
-rw-r--r--spec/ruby/library/stringio/lines_spec.rb6
-rw-r--r--spec/ruby/library/stringio/readline_spec.rb10
-rw-r--r--spec/ruby/library/stringio/readlines_spec.rb10
-rw-r--r--spec/ruby/library/stringscanner/scan_spec.rb16
-rw-r--r--spec/ruby/library/time/to_time_spec.rb18
-rw-r--r--spec/ruby/library/timeout/timeout_spec.rb15
-rw-r--r--spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb8
-rw-r--r--spec/ruby/library/zlib/gzipreader/ungetc_spec.rb32
42 files changed, 777 insertions, 862 deletions
diff --git a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
index 03f0c0adfd..2312a4e910 100644
--- a/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
+++ b/spec/ruby/library/bigdecimal/BigDecimal_spec.rb
@@ -58,18 +58,9 @@ describe "Kernel#BigDecimal" do
end
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
+ 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
it "allows omitting the integer part" do
diff --git a/spec/ruby/library/bigdecimal/gt_spec.rb b/spec/ruby/library/bigdecimal/gt_spec.rb
index c815aa0353..8ebb631cb8 100644
--- a/spec/ruby/library/bigdecimal/gt_spec.rb
+++ b/spec/ruby/library/bigdecimal/gt_spec.rb
@@ -68,15 +68,13 @@ describe "BigDecimal#>" do
(@infinity_neg > @infinity).should == false
end
- ruby_bug "#13674", ""..."2.4" do
- it "properly handles Float infinity values" do
- @values.each { |val|
- (val > @float_infinity).should == false
- (@float_infinity > val).should == true
- (val > @float_infinity_neg).should == true
- (@float_infinity_neg > val).should == false
- }
- end
+ it "properly handles Float infinity values" do
+ @values.each { |val|
+ (val > @float_infinity).should == false
+ (@float_infinity > val).should == true
+ (val > @float_infinity_neg).should == true
+ (@float_infinity_neg > val).should == false
+ }
end
it "properly handles NaN values" do
diff --git a/spec/ruby/library/bigdecimal/gte_spec.rb b/spec/ruby/library/bigdecimal/gte_spec.rb
index 14534eec80..6b0b7f41e9 100644
--- a/spec/ruby/library/bigdecimal/gte_spec.rb
+++ b/spec/ruby/library/bigdecimal/gte_spec.rb
@@ -72,15 +72,13 @@ describe "BigDecimal#>=" do
(@infinity_neg >= @infinity).should == false
end
- ruby_bug "#13674", ""..."2.4" do
- it "properly handles Float infinity values" do
- @values.each { |val|
- (val >= @float_infinity).should == false
- (@float_infinity >= val).should == true
- (val >= @float_infinity_neg).should == true
- (@float_infinity_neg >= val).should == false
- }
- end
+ it "properly handles Float infinity values" do
+ @values.each { |val|
+ (val >= @float_infinity).should == false
+ (@float_infinity >= val).should == true
+ (val >= @float_infinity_neg).should == true
+ (@float_infinity_neg >= val).should == false
+ }
end
it "properly handles NaN values" do
diff --git a/spec/ruby/library/bigdecimal/inspect_spec.rb b/spec/ruby/library/bigdecimal/inspect_spec.rb
index 7e1a8297e2..cd2f1a3cd4 100644
--- a/spec/ruby/library/bigdecimal/inspect_spec.rb
+++ b/spec/ruby/library/bigdecimal/inspect_spec.rb
@@ -11,37 +11,7 @@ describe "BigDecimal#inspect" do
@bigdec.inspect.kind_of?(String).should == true
end
- ruby_version_is ""..."2.4" do
- it "returns String starting with #" do
- @bigdec.inspect[0].should == ?#
- end
-
- it "encloses information in angle brackets" do
- @bigdec.inspect.should =~ /^.<.*>$/
- end
-
- it "is comma separated list of three items" do
- @bigdec.inspect.should =~ /...*,.*,.*/
- end
-
- it "value after first comma is value as string" do
- @bigdec.inspect.split(",")[1].should == "\'0.12345678E4\'"
- end
-
- it "last part is number of significant digits" do
- signific_string = "#{@bigdec.precs[0]}(#{@bigdec.precs[1]})"
- @bigdec.inspect.split(",")[2].should == signific_string + ">"
- end
-
- it "looks like this" do
- regex = /^\#\<BigDecimal\:.*,'0\.12345678E4',[0-9]+\([0-9]+\)>$/
- @bigdec.inspect.should =~ regex
- end
- end
-
- ruby_version_is "2.4" do
- it "looks like this" do
- @bigdec.inspect.should == "0.12345678e4"
- end
+ it "looks like this" do
+ @bigdec.inspect.should == "0.12345678e4"
end
end
diff --git a/spec/ruby/library/bigdecimal/lt_spec.rb b/spec/ruby/library/bigdecimal/lt_spec.rb
index 8cf92fedd2..1894daf17f 100644
--- a/spec/ruby/library/bigdecimal/lt_spec.rb
+++ b/spec/ruby/library/bigdecimal/lt_spec.rb
@@ -66,15 +66,13 @@ describe "BigDecimal#<" do
(@infinity_neg < @infinity).should == true
end
- ruby_bug "#13674", ""..."2.4" do
- it "properly handles Float infinity values" do
- @values.each { |val|
- (val < @float_infinity).should == true
- (@float_infinity < val).should == false
- (val < @float_infinity_neg).should == false
- (@float_infinity_neg < val).should == true
- }
- end
+ it "properly handles Float infinity values" do
+ @values.each { |val|
+ (val < @float_infinity).should == true
+ (@float_infinity < val).should == false
+ (val < @float_infinity_neg).should == false
+ (@float_infinity_neg < val).should == true
+ }
end
it "properly handles NaN values" do
diff --git a/spec/ruby/library/bigdecimal/lte_spec.rb b/spec/ruby/library/bigdecimal/lte_spec.rb
index eff6547369..56d3caa3b1 100644
--- a/spec/ruby/library/bigdecimal/lte_spec.rb
+++ b/spec/ruby/library/bigdecimal/lte_spec.rb
@@ -72,15 +72,13 @@ describe "BigDecimal#<=" do
(@infinity_neg <= @infinity).should == true
end
- ruby_bug "#13674", ""..."2.4" do
- it "properly handles Float infinity values" do
- @values.each { |val|
- (val <= @float_infinity).should == true
- (@float_infinity <= val).should == false
- (val <= @float_infinity_neg).should == false
- (@float_infinity_neg <= val).should == true
- }
- end
+ it "properly handles Float infinity values" do
+ @values.each { |val|
+ (val <= @float_infinity).should == true
+ (@float_infinity <= val).should == false
+ (val <= @float_infinity_neg).should == false
+ (@float_infinity_neg <= val).should == true
+ }
end
it "properly handles NaN values" do
diff --git a/spec/ruby/library/bigdecimal/round_spec.rb b/spec/ruby/library/bigdecimal/round_spec.rb
index 07b96acb2b..467e2c5563 100644
--- a/spec/ruby/library/bigdecimal/round_spec.rb
+++ b/spec/ruby/library/bigdecimal/round_spec.rb
@@ -62,129 +62,157 @@ describe "BigDecimal#round" do
@n2_49.round(0).should == @neg_two
end
- describe "BigDecimal::ROUND_UP" do
- it "rounds values away from zero" do
- @p1_50.round(0, BigDecimal::ROUND_UP).should == @two
- @p1_51.round(0, BigDecimal::ROUND_UP).should == @two
- @p1_49.round(0, BigDecimal::ROUND_UP).should == @two
- @n1_50.round(0, BigDecimal::ROUND_UP).should == @neg_two
- @n1_51.round(0, BigDecimal::ROUND_UP).should == @neg_two
- @n1_49.round(0, BigDecimal::ROUND_UP).should == @neg_two
-
- @p2_50.round(0, BigDecimal::ROUND_UP).should == @three
- @p2_51.round(0, BigDecimal::ROUND_UP).should == @three
- @p2_49.round(0, BigDecimal::ROUND_UP).should == @three
- @n2_50.round(0, BigDecimal::ROUND_UP).should == @neg_three
- @n2_51.round(0, BigDecimal::ROUND_UP).should == @neg_three
- @n2_49.round(0, BigDecimal::ROUND_UP).should == @neg_three
+ ["BigDecimal::ROUND_UP", ":up"].each do |way|
+ describe way do
+ it "rounds values away from zero" do
+ mode = eval(way)
+
+ @p1_50.round(0, mode).should == @two
+ @p1_51.round(0, mode).should == @two
+ @p1_49.round(0, mode).should == @two
+ @n1_50.round(0, mode).should == @neg_two
+ @n1_51.round(0, mode).should == @neg_two
+ @n1_49.round(0, mode).should == @neg_two
+
+ @p2_50.round(0, mode).should == @three
+ @p2_51.round(0, mode).should == @three
+ @p2_49.round(0, mode).should == @three
+ @n2_50.round(0, mode).should == @neg_three
+ @n2_51.round(0, mode).should == @neg_three
+ @n2_49.round(0, mode).should == @neg_three
+ end
end
end
- describe "BigDecimal::ROUND_DOWN" do
- it "rounds values towards zero" do
- @p1_50.round(0, BigDecimal::ROUND_DOWN).should == @one
- @p1_51.round(0, BigDecimal::ROUND_DOWN).should == @one
- @p1_49.round(0, BigDecimal::ROUND_DOWN).should == @one
- @n1_50.round(0, BigDecimal::ROUND_DOWN).should == @neg_one
- @n1_51.round(0, BigDecimal::ROUND_DOWN).should == @neg_one
- @n1_49.round(0, BigDecimal::ROUND_DOWN).should == @neg_one
-
- @p2_50.round(0, BigDecimal::ROUND_DOWN).should == @two
- @p2_51.round(0, BigDecimal::ROUND_DOWN).should == @two
- @p2_49.round(0, BigDecimal::ROUND_DOWN).should == @two
- @n2_50.round(0, BigDecimal::ROUND_DOWN).should == @neg_two
- @n2_51.round(0, BigDecimal::ROUND_DOWN).should == @neg_two
- @n2_49.round(0, BigDecimal::ROUND_DOWN).should == @neg_two
+ ["BigDecimal::ROUND_DOWN", ":down", ":truncate"].each do |way|
+ describe way do
+ it "rounds values towards zero" do
+ mode = eval(way)
+
+ @p1_50.round(0, mode).should == @one
+ @p1_51.round(0, mode).should == @one
+ @p1_49.round(0, mode).should == @one
+ @n1_50.round(0, mode).should == @neg_one
+ @n1_51.round(0, mode).should == @neg_one
+ @n1_49.round(0, mode).should == @neg_one
+
+ @p2_50.round(0, mode).should == @two
+ @p2_51.round(0, mode).should == @two
+ @p2_49.round(0, mode).should == @two
+ @n2_50.round(0, mode).should == @neg_two
+ @n2_51.round(0, mode).should == @neg_two
+ @n2_49.round(0, mode).should == @neg_two
+ end
end
end
- describe "BigDecimal::ROUND_HALF_UP" do
- it "rounds values >= 5 up, otherwise down" do
- @p1_50.round(0, BigDecimal::ROUND_HALF_UP).should == @two
- @p1_51.round(0, BigDecimal::ROUND_HALF_UP).should == @two
- @p1_49.round(0, BigDecimal::ROUND_HALF_UP).should == @one
- @n1_50.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_two
- @n1_51.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_two
- @n1_49.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_one
-
- @p2_50.round(0, BigDecimal::ROUND_HALF_UP).should == @three
- @p2_51.round(0, BigDecimal::ROUND_HALF_UP).should == @three
- @p2_49.round(0, BigDecimal::ROUND_HALF_UP).should == @two
- @n2_50.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_three
- @n2_51.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_three
- @n2_49.round(0, BigDecimal::ROUND_HALF_UP).should == @neg_two
+ ["BigDecimal::ROUND_HALF_UP", ":half_up", ":default"].each do |way|
+ describe way do
+ it "rounds values >= 5 up, otherwise down" do
+ mode = eval(way)
+
+ @p1_50.round(0, mode).should == @two
+ @p1_51.round(0, mode).should == @two
+ @p1_49.round(0, mode).should == @one
+ @n1_50.round(0, mode).should == @neg_two
+ @n1_51.round(0, mode).should == @neg_two
+ @n1_49.round(0, mode).should == @neg_one
+
+ @p2_50.round(0, mode).should == @three
+ @p2_51.round(0, mode).should == @three
+ @p2_49.round(0, mode).should == @two
+ @n2_50.round(0, mode).should == @neg_three
+ @n2_51.round(0, mode).should == @neg_three
+ @n2_49.round(0, mode).should == @neg_two
+ end
end
end
- describe "BigDecimal::ROUND_HALF_DOWN" do
- it "rounds values > 5 up, otherwise down" do
- @p1_50.round(0, BigDecimal::ROUND_HALF_DOWN).should == @one
- @p1_51.round(0, BigDecimal::ROUND_HALF_DOWN).should == @two
- @p1_49.round(0, BigDecimal::ROUND_HALF_DOWN).should == @one
- @n1_50.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_one
- @n1_51.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_two
- @n1_49.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_one
-
- @p2_50.round(0, BigDecimal::ROUND_HALF_DOWN).should == @two
- @p2_51.round(0, BigDecimal::ROUND_HALF_DOWN).should == @three
- @p2_49.round(0, BigDecimal::ROUND_HALF_DOWN).should == @two
- @n2_50.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_two
- @n2_51.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_three
- @n2_49.round(0, BigDecimal::ROUND_HALF_DOWN).should == @neg_two
+ ["BigDecimal::ROUND_HALF_DOWN", ":half_down"].each do |way|
+ describe way do
+ it "rounds values > 5 up, otherwise down" do
+ mode = eval(way)
+
+ @p1_50.round(0, mode).should == @one
+ @p1_51.round(0, mode).should == @two
+ @p1_49.round(0, mode).should == @one
+ @n1_50.round(0, mode).should == @neg_one
+ @n1_51.round(0, mode).should == @neg_two
+ @n1_49.round(0, mode).should == @neg_one
+
+ @p2_50.round(0, mode).should == @two
+ @p2_51.round(0, mode).should == @three
+ @p2_49.round(0, mode).should == @two
+ @n2_50.round(0, mode).should == @neg_two
+ @n2_51.round(0, mode).should == @neg_three
+ @n2_49.round(0, mode).should == @neg_two
+ end
end
end
- describe "BigDecimal::ROUND_CEILING" do
- it "rounds values towards +infinity" do
- @p1_50.round(0, BigDecimal::ROUND_CEILING).should == @two
- @p1_51.round(0, BigDecimal::ROUND_CEILING).should == @two
- @p1_49.round(0, BigDecimal::ROUND_CEILING).should == @two
- @n1_50.round(0, BigDecimal::ROUND_CEILING).should == @neg_one
- @n1_51.round(0, BigDecimal::ROUND_CEILING).should == @neg_one
- @n1_49.round(0, BigDecimal::ROUND_CEILING).should == @neg_one
-
- @p2_50.round(0, BigDecimal::ROUND_CEILING).should == @three
- @p2_51.round(0, BigDecimal::ROUND_CEILING).should == @three
- @p2_49.round(0, BigDecimal::ROUND_CEILING).should == @three
- @n2_50.round(0, BigDecimal::ROUND_CEILING).should == @neg_two
- @n2_51.round(0, BigDecimal::ROUND_CEILING).should == @neg_two
- @n2_49.round(0, BigDecimal::ROUND_CEILING).should == @neg_two
+ ["BigDecimal::ROUND_CEILING", ":ceiling", ":ceil"].each do |way|
+ describe way do
+ it "rounds values towards +infinity" do
+ mode = eval(way)
+
+ @p1_50.round(0, mode).should == @two
+ @p1_51.round(0, mode).should == @two
+ @p1_49.round(0, mode).should == @two
+ @n1_50.round(0, mode).should == @neg_one
+ @n1_51.round(0, mode).should == @neg_one
+ @n1_49.round(0, mode).should == @neg_one
+
+ @p2_50.round(0, mode).should == @three
+ @p2_51.round(0, mode).should == @three
+ @p2_49.round(0, mode).should == @three
+ @n2_50.round(0, mode).should == @neg_two
+ @n2_51.round(0, mode).should == @neg_two
+ @n2_49.round(0, mode).should == @neg_two
+ end
end
end
- describe "BigDecimal::ROUND_FLOOR" do
- it "rounds values towards -infinity" do
- @p1_50.round(0, BigDecimal::ROUND_FLOOR).should == @one
- @p1_51.round(0, BigDecimal::ROUND_FLOOR).should == @one
- @p1_49.round(0, BigDecimal::ROUND_FLOOR).should == @one
- @n1_50.round(0, BigDecimal::ROUND_FLOOR).should == @neg_two
- @n1_51.round(0, BigDecimal::ROUND_FLOOR).should == @neg_two
- @n1_49.round(0, BigDecimal::ROUND_FLOOR).should == @neg_two
-
- @p2_50.round(0, BigDecimal::ROUND_FLOOR).should == @two
- @p2_51.round(0, BigDecimal::ROUND_FLOOR).should == @two
- @p2_49.round(0, BigDecimal::ROUND_FLOOR).should == @two
- @n2_50.round(0, BigDecimal::ROUND_FLOOR).should == @neg_three
- @n2_51.round(0, BigDecimal::ROUND_FLOOR).should == @neg_three
- @n2_49.round(0, BigDecimal::ROUND_FLOOR).should == @neg_three
+ ["BigDecimal::ROUND_FLOOR", ":floor"].each do |way|
+ describe way do
+ it "rounds values towards -infinity" do
+ mode = eval(way)
+
+ @p1_50.round(0, mode).should == @one
+ @p1_51.round(0, mode).should == @one
+ @p1_49.round(0, mode).should == @one
+ @n1_50.round(0, mode).should == @neg_two
+ @n1_51.round(0, mode).should == @neg_two
+ @n1_49.round(0, mode).should == @neg_two
+
+ @p2_50.round(0, mode).should == @two
+ @p2_51.round(0, mode).should == @two
+ @p2_49.round(0, mode).should == @two
+ @n2_50.round(0, mode).should == @neg_three
+ @n2_51.round(0, mode).should == @neg_three
+ @n2_49.round(0, mode).should == @neg_three
+ end
end
end
- describe "BigDecimal::ROUND_HALF_EVEN" do
- it "rounds values > 5 up, < 5 down and == 5 towards even neighbor" do
- @p1_50.round(0, BigDecimal::ROUND_HALF_EVEN).should == @two
- @p1_51.round(0, BigDecimal::ROUND_HALF_EVEN).should == @two
- @p1_49.round(0, BigDecimal::ROUND_HALF_EVEN).should == @one
- @n1_50.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_two
- @n1_51.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_two
- @n1_49.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_one
-
- @p2_50.round(0, BigDecimal::ROUND_HALF_EVEN).should == @two
- @p2_51.round(0, BigDecimal::ROUND_HALF_EVEN).should == @three
- @p2_49.round(0, BigDecimal::ROUND_HALF_EVEN).should == @two
- @n2_50.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_two
- @n2_51.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_three
- @n2_49.round(0, BigDecimal::ROUND_HALF_EVEN).should == @neg_two
+ ["BigDecimal::ROUND_HALF_EVEN", ":half_even", ":banker"].each do |way|
+ describe way do
+ it "rounds values > 5 up, < 5 down and == 5 towards even neighbor" do
+ mode = eval(way)
+
+ @p1_50.round(0, mode).should == @two
+ @p1_51.round(0, mode).should == @two
+ @p1_49.round(0, mode).should == @one
+ @n1_50.round(0, mode).should == @neg_two
+ @n1_51.round(0, mode).should == @neg_two
+ @n1_49.round(0, mode).should == @neg_one
+
+ @p2_50.round(0, mode).should == @two
+ @p2_51.round(0, mode).should == @three
+ @p2_49.round(0, mode).should == @two
+ @n2_50.round(0, mode).should == @neg_two
+ @n2_51.round(0, mode).should == @neg_three
+ @n2_49.round(0, mode).should == @neg_two
+ end
end
end
@@ -199,4 +227,8 @@ describe "BigDecimal#round" do
lambda { BigDecimal('Infinity').round(2) }.should_not raise_error(FloatDomainError)
lambda { BigDecimal('-Infinity').round(2) }.should_not raise_error(FloatDomainError)
end
+
+ it "raise for a non-existent round mode" do
+ lambda { @p1_50.round(0, :nonsense) }.should raise_error(ArgumentError, "invalid rounding mode")
+ end
end
diff --git a/spec/ruby/library/bigdecimal/to_s_spec.rb b/spec/ruby/library/bigdecimal/to_s_spec.rb
index 75741c5050..247db1a5d2 100644
--- a/spec/ruby/library/bigdecimal/to_s_spec.rb
+++ b/spec/ruby/library/bigdecimal/to_s_spec.rb
@@ -15,16 +15,8 @@ describe "BigDecimal#to_s" do
@bigneg.to_s.kind_of?(String).should == true
end
- ruby_version_is ''...'2.4' do
- it "the default format looks like 0.xxxxEnn" do
- @bigdec.to_s.should =~ /^0\.[0-9]*E[0-9]*$/
- end
- end
-
- ruby_version_is '2.4' do
- it "the default format looks like 0.xxxxenn" do
- @bigdec.to_s.should =~ /^0\.[0-9]*e[0-9]*$/
- end
+ it "the default format looks like 0.xxxxenn" do
+ @bigdec.to_s.should =~ /^0\.[0-9]*e[0-9]*$/
end
it "takes an optional argument" do
diff --git a/spec/ruby/library/cgi/cookie/parse_spec.rb b/spec/ruby/library/cgi/cookie/parse_spec.rb
index c714aab300..90d2c3d148 100644
--- a/spec/ruby/library/cgi/cookie/parse_spec.rb
+++ b/spec/ruby/library/cgi/cookie/parse_spec.rb
@@ -10,25 +10,12 @@ describe "CGI::Cookie.parse" do
CGI::Cookie.parse("first cookie=one&two;second cookie=three&four").should == expected
end
- ruby_version_is ""..."2.4" do
- it "uses , for cookie separators" do
- expected = {
- "first cookie" => ["one", "two"],
- "second cookie" => ["three", "four"],
- "third_cookie" => ["five", "six"]
- }
- CGI::Cookie.parse("first cookie=one&two;second cookie=three&four,third_cookie=five&six").should == expected
- end
- end
-
- ruby_version_is "2.4" do
- it "does not use , for cookie separators" do
- expected = {
- "first cookie" => ["one", "two"],
- "second cookie" => ["three", "four,third_cookie=five", "six"]
- }
- CGI::Cookie.parse("first cookie=one&two;second cookie=three&four,third_cookie=five&six").should == expected
- end
+ it "does not use , for cookie separators" do
+ expected = {
+ "first cookie" => ["one", "two"],
+ "second cookie" => ["three", "four,third_cookie=five", "six"]
+ }
+ CGI::Cookie.parse("first cookie=one&two;second cookie=three&four,third_cookie=five&six").should == expected
end
it "unescapes the Cookie values" do
diff --git a/spec/ruby/library/conditionvariable/wait_spec.rb b/spec/ruby/library/conditionvariable/wait_spec.rb
index 8bdb7829d3..f57ab4c778 100644
--- a/spec/ruby/library/conditionvariable/wait_spec.rb
+++ b/spec/ruby/library/conditionvariable/wait_spec.rb
@@ -2,6 +2,15 @@ require_relative '../../spec_helper'
require 'thread'
describe "ConditionVariable#wait" do
+ it "calls #sleep on the given object" do
+ o = Object.new
+ o.should_receive(:sleep).with(1234)
+
+ cv = ConditionVariable.new
+
+ cv.wait(o, 1234)
+ end
+
it "returns self" do
m = Mutex.new
cv = ConditionVariable.new
diff --git a/spec/ruby/library/coverage/fixtures/spec_helper.rb b/spec/ruby/library/coverage/fixtures/spec_helper.rb
deleted file mode 100644
index 19094e5c36..0000000000
--- a/spec/ruby/library/coverage/fixtures/spec_helper.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-module CoverageSpecs
- # Clear old results from the result hash
- # https://bugs.ruby-lang.org/issues/12220
- def self.filtered_result
- result = Coverage.result
- ruby_version_is ""..."2.4" do
- result = result.reject { |_k, v| v.empty? }
- end
- result
- end
-end
diff --git a/spec/ruby/library/coverage/peek_result_spec.rb b/spec/ruby/library/coverage/peek_result_spec.rb
index 897fc4d978..9d7c890faa 100644
--- a/spec/ruby/library/coverage/peek_result_spec.rb
+++ b/spec/ruby/library/coverage/peek_result_spec.rb
@@ -1,5 +1,4 @@
require_relative '../../spec_helper'
-require fixture __FILE__, 'spec_helper'
require 'coverage'
describe 'Coverage.peek_result' do
diff --git a/spec/ruby/library/coverage/result_spec.rb b/spec/ruby/library/coverage/result_spec.rb
index f964c9457a..ebfa5538b4 100644
--- a/spec/ruby/library/coverage/result_spec.rb
+++ b/spec/ruby/library/coverage/result_spec.rb
@@ -1,5 +1,4 @@
require_relative '../../spec_helper'
-require fixture __FILE__, 'spec_helper'
require 'coverage'
describe 'Coverage.result' do
@@ -16,7 +15,7 @@ describe 'Coverage.result' do
it 'gives the covered files as a hash with arrays of count or nil' do
Coverage.start
require @class_file.chomp('.rb')
- result = CoverageSpecs.filtered_result
+ result = Coverage.result
result.should == {
@class_file => [
@@ -27,7 +26,7 @@ describe 'Coverage.result' do
it 'no requires/loads should give empty hash' do
Coverage.start
- result = CoverageSpecs.filtered_result
+ result = Coverage.result
result.should == {}
end
@@ -43,11 +42,11 @@ describe 'Coverage.result' do
it 'second run should give same result' do
Coverage.start
load @class_file
- result1 = CoverageSpecs.filtered_result
+ result1 = Coverage.result
Coverage.start
load @class_file
- result2 = CoverageSpecs.filtered_result
+ result2 = Coverage.result
result2.should == result1
end
@@ -58,7 +57,7 @@ describe 'Coverage.result' do
Coverage.result
Coverage.start
- result = CoverageSpecs.filtered_result
+ result = Coverage.result
result.should == {}
end
@@ -66,13 +65,13 @@ describe 'Coverage.result' do
it 'second Coverage.start does nothing' do
Coverage.start
require @config_file.chomp('.rb')
- result = CoverageSpecs.filtered_result
+ result = Coverage.result
result.should == { @config_file => [1, 1, 1] }
end
it 'does not include the file starting coverage since it is not tracked' do
require @config_file.chomp('.rb')
- CoverageSpecs.filtered_result.should_not include(@config_file)
+ Coverage.result.should_not include(@config_file)
end
end
diff --git a/spec/ruby/library/csv/liberal_parsing_spec.rb b/spec/ruby/library/csv/liberal_parsing_spec.rb
index a2dda36c99..2929d6e2aa 100644
--- a/spec/ruby/library/csv/liberal_parsing_spec.rb
+++ b/spec/ruby/library/csv/liberal_parsing_spec.rb
@@ -1,21 +1,19 @@
require_relative '../../spec_helper'
require 'csv'
-ruby_version_is '2.4' do
- describe "CSV#liberal_parsing?" do
- it "returns true if illegal input is handled" do
- csv = CSV.new("", liberal_parsing: true)
- csv.liberal_parsing?.should == true
- end
+describe "CSV#liberal_parsing?" do
+ it "returns true if illegal input is handled" do
+ csv = CSV.new("", liberal_parsing: true)
+ csv.liberal_parsing?.should == true
+ end
- it "returns false if illegal input is not handled" do
- csv = CSV.new("", liberal_parsing: false)
- csv.liberal_parsing?.should == false
- end
+ it "returns false if illegal input is not handled" do
+ csv = CSV.new("", liberal_parsing: false)
+ csv.liberal_parsing?.should == false
+ end
- it "returns false by default" do
- csv = CSV.new("")
- csv.liberal_parsing?.should == false
- end
+ it "returns false by default" do
+ csv = CSV.new("")
+ csv.liberal_parsing?.should == false
end
end
diff --git a/spec/ruby/library/csv/parse_spec.rb b/spec/ruby/library/csv/parse_spec.rb
index fc3f04378b..ef5d4ea3ca 100644
--- a/spec/ruby/library/csv/parse_spec.rb
+++ b/spec/ruby/library/csv/parse_spec.rb
@@ -85,11 +85,9 @@ describe "CSV.parse" do
}.should raise_error(CSV::MalformedCSVError)
end
- ruby_version_is '2.4' do
- it "handles illegal input with the liberal_parsing option" do
- illegal_input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
- result = CSV.parse(illegal_input, liberal_parsing: true)
- result.should == [["Johnson, Dwayne", 'Dwayne "The Rock" Johnson']]
- end
+ it "handles illegal input with the liberal_parsing option" do
+ illegal_input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
+ result = CSV.parse(illegal_input, liberal_parsing: true)
+ result.should == [["Johnson, Dwayne", 'Dwayne "The Rock" Johnson']]
end
end
diff --git a/spec/ruby/library/csv/readlines_spec.rb b/spec/ruby/library/csv/readlines_spec.rb
index 882266657e..14dea34381 100644
--- a/spec/ruby/library/csv/readlines_spec.rb
+++ b/spec/ruby/library/csv/readlines_spec.rb
@@ -26,12 +26,10 @@ describe "CSV#readlines" do
-> { csv.readlines }.should raise_error(CSV::MalformedCSVError)
end
- ruby_version_is '2.4' do
- it "handles illegal input with the liberal_parsing option" do
- illegal_input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
- csv = CSV.new(illegal_input, liberal_parsing: true)
- result = csv.readlines
- result.should == [["Johnson, Dwayne", 'Dwayne "The Rock" Johnson']]
- end
+ it "handles illegal input with the liberal_parsing option" do
+ illegal_input = '"Johnson, Dwayne",Dwayne "The Rock" Johnson'
+ csv = CSV.new(illegal_input, liberal_parsing: true)
+ result = csv.readlines
+ result.should == [["Johnson, Dwayne", 'Dwayne "The Rock" Johnson']]
end
end
diff --git a/spec/ruby/library/datetime/now_spec.rb b/spec/ruby/library/datetime/now_spec.rb
index 9cdce80ef3..9f22153c15 100644
--- a/spec/ruby/library/datetime/now_spec.rb
+++ b/spec/ruby/library/datetime/now_spec.rb
@@ -7,13 +7,13 @@ describe "DateTime.now" do
end
it "sets the current date" do
- (DateTime.now - Date.today).to_f.should be_close(0.0, 2.0)
+ (DateTime.now - Date.today).to_f.should be_close(0.0, TIME_TOLERANCE)
end
it "sets the current time" do
dt = DateTime.now
now = Time.now
- (dt.to_time - now).should be_close(0.0, 10.0)
+ (dt.to_time - now).should be_close(0.0, TIME_TOLERANCE)
end
it "grabs the local timezone" do
diff --git a/spec/ruby/library/datetime/to_time_spec.rb b/spec/ruby/library/datetime/to_time_spec.rb
index 3bda369ca7..a11b6e30e1 100644
--- a/spec/ruby/library/datetime/to_time_spec.rb
+++ b/spec/ruby/library/datetime/to_time_spec.rb
@@ -18,21 +18,19 @@ describe "DateTime#to_time" do
time.sec.should == 59
end
- ruby_version_is "2.4" do
- it "preserves the same time regardless of local time or zone" do
- date = DateTime.new(2012, 12, 24, 12, 23, 00, '+03:00')
+ it "preserves the same time regardless of local time or zone" do
+ date = DateTime.new(2012, 12, 24, 12, 23, 00, '+03:00')
- with_timezone("Pacific/Pago_Pago", -11) do
- time = date.to_time
+ with_timezone("Pacific/Pago_Pago", -11) do
+ time = date.to_time
- time.utc_offset.should == 3 * 3600
- time.year.should == date.year
- time.mon.should == date.mon
- time.day.should == date.day
- time.hour.should == date.hour
- time.min.should == date.min
- time.sec.should == date.sec
- end
+ time.utc_offset.should == 3 * 3600
+ time.year.should == date.year
+ time.mon.should == date.mon
+ time.day.should == date.day
+ time.hour.should == date.hour
+ time.min.should == date.min
+ time.sec.should == date.sec
end
end
end
diff --git a/spec/ruby/library/ipaddr/operator_spec.rb b/spec/ruby/library/ipaddr/operator_spec.rb
index a0984bfcfe..f90c56009c 100644
--- a/spec/ruby/library/ipaddr/operator_spec.rb
+++ b/spec/ruby/library/ipaddr/operator_spec.rb
@@ -54,11 +54,9 @@ describe "IPAddr Operator" do
@a.should_not == IPAddr.new("3ffe:505:3::")
end
- ruby_version_is '2.4' do
- # https://bugs.ruby-lang.org/issues/12799
- it "tests for equality correctly if object cannot be converted to IPAddr" do
- IPAddr.new("1.1.1.1").should_not == "sometext"
- end
+ # https://bugs.ruby-lang.org/issues/12799
+ it "tests for equality correctly if object cannot be converted to IPAddr" do
+ IPAddr.new("1.1.1.1").should_not == "sometext"
end
it "sets a mask" do
diff --git a/spec/ruby/library/logger/logger/new_spec.rb b/spec/ruby/library/logger/logger/new_spec.rb
index 3a83968eb1..43f701a3dd 100644
--- a/spec/ruby/library/logger/logger/new_spec.rb
+++ b/spec/ruby/library/logger/logger/new_spec.rb
@@ -61,60 +61,58 @@ describe "Logger#new" do
rm_r path, "#{path}.0"
end
- ruby_version_is "2.4" do
- it "receives level symbol as keyword argument" do
- logger = Logger.new(STDERR, level: :info)
- logger.level.should == Logger::INFO
- end
+ it "receives level symbol as keyword argument" do
+ logger = Logger.new(STDERR, level: :info)
+ logger.level.should == Logger::INFO
+ end
- it "receives level as keyword argument" do
- logger = Logger.new(STDERR, level: Logger::INFO)
- logger.level.should == Logger::INFO
- end
+ it "receives level as keyword argument" do
+ logger = Logger.new(STDERR, level: Logger::INFO)
+ logger.level.should == Logger::INFO
+ end
- it "receives progname as keyword argument" do
- progname = "progname"
+ it "receives progname as keyword argument" do
+ progname = "progname"
- logger = Logger.new(STDERR, progname: progname)
- logger.progname.should == progname
- end
+ logger = Logger.new(STDERR, progname: progname)
+ logger.progname.should == progname
+ end
- it "receives datetime_format as keyword argument" do
- datetime_format = "%H:%M:%S"
+ it "receives datetime_format as keyword argument" do
+ datetime_format = "%H:%M:%S"
- logger = Logger.new(STDERR, datetime_format: datetime_format)
- logger.datetime_format.should == datetime_format
- end
+ logger = Logger.new(STDERR, datetime_format: datetime_format)
+ logger.datetime_format.should == datetime_format
+ end
- it "receives formatter as keyword argument" do
- formatter = Class.new do
- def call(_severity, _time, _progname, _msg); end
- end.new
+ it "receives formatter as keyword argument" do
+ formatter = Class.new do
+ def call(_severity, _time, _progname, _msg); end
+ end.new
- logger = Logger.new(STDERR, formatter: formatter)
- logger.formatter.should == formatter
- end
+ logger = Logger.new(STDERR, formatter: formatter)
+ logger.formatter.should == formatter
+ end
- it "receives shift_period_suffix " do
- shift_period_suffix = "%Y-%m-%d"
- path = tmp("shift_period_suffix_test.log")
- now = Time.now
- tomorrow = Time.at(now.to_i + 60 * 60 * 24)
- logger = Logger.new(path, 'daily', shift_period_suffix: shift_period_suffix)
+ it "receives shift_period_suffix " do
+ shift_period_suffix = "%Y-%m-%d"
+ path = tmp("shift_period_suffix_test.log")
+ now = Time.now
+ tomorrow = Time.at(now.to_i + 60 * 60 * 24)
+ logger = Logger.new(path, 'daily', shift_period_suffix: shift_period_suffix)
- logger.add Logger::INFO, 'message'
+ logger.add Logger::INFO, 'message'
- Time.stub!(:now).and_return(tomorrow)
- logger.add Logger::INFO, 'second message'
+ Time.stub!(:now).and_return(tomorrow)
+ logger.add Logger::INFO, 'second message'
- shifted_path = "#{path}.#{now.strftime(shift_period_suffix)}"
+ shifted_path = "#{path}.#{now.strftime(shift_period_suffix)}"
- File.exist?(shifted_path).should == true
+ File.exist?(shifted_path).should == true
- logger.close
+ logger.close
- rm_r path, shifted_path
- end
+ rm_r path, shifted_path
end
end
diff --git a/spec/ruby/library/net/ftp/initialize_spec.rb b/spec/ruby/library/net/ftp/initialize_spec.rb
index cd6252ac31..507320e494 100644
--- a/spec/ruby/library/net/ftp/initialize_spec.rb
+++ b/spec/ruby/library/net/ftp/initialize_spec.rb
@@ -89,318 +89,316 @@ describe "Net::FTP#initialize" do
end
end
- ruby_version_is '2.4' do
- before :each do
- @ftp.stub!(:login)
- end
+ before :each do
+ @ftp.stub!(:login)
+ end
- describe 'when the host' do
- describe 'is set' do
- describe 'and port option' do
- describe 'is set' do
- it 'tries to connect to the host on the specified port' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ port: 8080 })
- @ftp.should_receive(:connect).with('localhost', 8080)
+ describe 'when the host' do
+ describe 'is set' do
+ describe 'and port option' do
+ describe 'is set' do
+ it 'tries to connect to the host on the specified port' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ port: 8080 })
+ @ftp.should_receive(:connect).with('localhost', 8080)
- @ftp.send(:initialize, 'localhost', options)
- end
+ @ftp.send(:initialize, 'localhost', options)
end
+ end
- describe 'is not set' do
- it 'tries to connect to the host without a port' do
- @ftp.should_receive(:connect).with("localhost", *@port_args)
+ describe 'is not set' do
+ it 'tries to connect to the host without a port' do
+ @ftp.should_receive(:connect).with("localhost", *@port_args)
- @ftp.send(:initialize, 'localhost')
- end
+ @ftp.send(:initialize, 'localhost')
end
end
+ end
- describe 'when the username option' do
- describe 'is set' do
- describe 'and the password option' do
- describe 'is set' do
- describe 'and the account option' do
- describe 'is set' do
- it 'tries to log in with the supplied parameters' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ username: 'a', password: 'topsecret', account: 'b' })
- @ftp.should_receive(:login).with('a', 'topsecret', 'b')
-
- @ftp.send(:initialize, 'localhost', options)
- end
+ describe 'when the username option' do
+ describe 'is set' do
+ describe 'and the password option' do
+ describe 'is set' do
+ describe 'and the account option' do
+ describe 'is set' do
+ it 'tries to log in with the supplied parameters' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ username: 'a', password: 'topsecret', account: 'b' })
+ @ftp.should_receive(:login).with('a', 'topsecret', 'b')
+
+ @ftp.send(:initialize, 'localhost', options)
end
+ end
- describe 'is unset' do
- it 'tries to log in with the supplied parameters' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ username: 'a', password: 'topsecret' })
- @ftp.should_receive(:login).with('a', 'topsecret', nil)
+ describe 'is unset' do
+ it 'tries to log in with the supplied parameters' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ username: 'a', password: 'topsecret' })
+ @ftp.should_receive(:login).with('a', 'topsecret', nil)
- @ftp.send(:initialize, 'localhost', options)
- end
+ @ftp.send(:initialize, 'localhost', options)
end
end
end
+ end
- describe 'is unset' do
- describe 'and the account option' do
- describe 'is set' do
- it 'tries to log in with the supplied parameters' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ username: 'a', account: 'b' })
- @ftp.should_receive(:login).with('a', nil, 'b')
+ describe 'is unset' do
+ describe 'and the account option' do
+ describe 'is set' do
+ it 'tries to log in with the supplied parameters' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ username: 'a', account: 'b' })
+ @ftp.should_receive(:login).with('a', nil, 'b')
- @ftp.send(:initialize, 'localhost', options)
- end
+ @ftp.send(:initialize, 'localhost', options)
end
+ end
- describe 'is unset' do
- it 'tries to log in with the supplied parameters' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ username: 'a'})
- @ftp.should_receive(:login).with('a', nil, nil)
+ describe 'is unset' do
+ it 'tries to log in with the supplied parameters' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ username: 'a'})
+ @ftp.should_receive(:login).with('a', nil, nil)
- @ftp.send(:initialize, 'localhost', options)
- end
+ @ftp.send(:initialize, 'localhost', options)
end
end
end
end
end
+ end
- describe 'is not set' do
- it 'does not try to log in' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({})
- @ftp.should_not_receive(:login)
+ describe 'is not set' do
+ it 'does not try to log in' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({})
+ @ftp.should_not_receive(:login)
- @ftp.send(:initialize, 'localhost', options)
- end
+ @ftp.send(:initialize, 'localhost', options)
end
end
end
+ end
- describe 'is unset' do
- it 'does not try to connect' do
- @ftp.should_not_receive(:connect)
+ describe 'is unset' do
+ it 'does not try to connect' do
+ @ftp.should_not_receive(:connect)
- @ftp.send(:initialize)
- end
+ @ftp.send(:initialize)
+ end
- it 'does not try to log in' do
- @ftp.should_not_receive(:login)
+ it 'does not try to log in' do
+ @ftp.should_not_receive(:login)
- @ftp.send(:initialize)
- end
+ @ftp.send(:initialize)
end
end
+ end
- describe 'when the passive option' do
- describe 'is set' do
- describe 'to true' do
- it 'sets passive to true' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ passive: true })
-
- @ftp.send(:initialize, nil, options)
- @ftp.passive.should == true
- end
- end
-
- describe 'to false' do
- it 'sets passive to false' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ passive: false })
+ describe 'when the passive option' do
+ describe 'is set' do
+ describe 'to true' do
+ it 'sets passive to true' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ passive: true })
- @ftp.send(:initialize, nil, options)
- @ftp.passive.should == false
- end
+ @ftp.send(:initialize, nil, options)
+ @ftp.passive.should == true
end
end
- describe 'is unset' do
+ describe 'to false' do
it 'sets passive to false' do
- @ftp.send(:initialize)
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ passive: false })
+
+ @ftp.send(:initialize, nil, options)
@ftp.passive.should == false
end
end
end
- describe 'when the debug_mode option' do
- describe 'is set' do
- describe 'to true' do
- it 'sets debug_mode to true' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ debug_mode: true })
-
- @ftp.send(:initialize, nil, options)
- @ftp.debug_mode.should == true
- end
- end
+ describe 'is unset' do
+ it 'sets passive to false' do
+ @ftp.send(:initialize)
+ @ftp.passive.should == false
+ end
+ end
+ end
- describe 'to false' do
- it 'sets debug_mode to false' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ debug_mode: false })
+ describe 'when the debug_mode option' do
+ describe 'is set' do
+ describe 'to true' do
+ it 'sets debug_mode to true' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ debug_mode: true })
- @ftp.send(:initialize, nil, options)
- @ftp.debug_mode.should == false
- end
+ @ftp.send(:initialize, nil, options)
+ @ftp.debug_mode.should == true
end
end
- describe 'is unset' do
+ describe 'to false' do
it 'sets debug_mode to false' do
- @ftp.send(:initialize)
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ debug_mode: false })
+
+ @ftp.send(:initialize, nil, options)
@ftp.debug_mode.should == false
end
end
end
- describe 'when the open_timeout option' do
- describe 'is set' do
- it 'sets open_timeout to the specified value' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ open_timeout: 42 })
+ describe 'is unset' do
+ it 'sets debug_mode to false' do
+ @ftp.send(:initialize)
+ @ftp.debug_mode.should == false
+ end
+ end
+ end
- @ftp.send(:initialize, nil, options)
- @ftp.open_timeout.should == 42
- end
+ describe 'when the open_timeout option' do
+ describe 'is set' do
+ it 'sets open_timeout to the specified value' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ open_timeout: 42 })
+
+ @ftp.send(:initialize, nil, options)
+ @ftp.open_timeout.should == 42
end
+ end
- describe 'is not set' do
- it 'sets open_timeout to nil' do
- @ftp.send(:initialize)
- @ftp.open_timeout.should == nil
- end
+ describe 'is not set' do
+ it 'sets open_timeout to nil' do
+ @ftp.send(:initialize)
+ @ftp.open_timeout.should == nil
end
end
+ end
- describe 'when the read_timeout option' do
- describe 'is set' do
- it 'sets read_timeout to the specified value' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ read_timeout: 100 })
+ describe 'when the read_timeout option' do
+ describe 'is set' do
+ it 'sets read_timeout to the specified value' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ read_timeout: 100 })
- @ftp.send(:initialize, nil, options)
- @ftp.read_timeout.should == 100
- end
+ @ftp.send(:initialize, nil, options)
+ @ftp.read_timeout.should == 100
end
+ end
- describe 'is not set' do
- it 'sets read_timeout to the default value' do
- @ftp.send(:initialize)
- @ftp.read_timeout.should == 60
- end
+ describe 'is not set' do
+ it 'sets read_timeout to the default value' do
+ @ftp.send(:initialize)
+ @ftp.read_timeout.should == 60
end
end
+ end
- describe 'when the ssl_handshake_timeout option' do
- describe 'is set' do
- it 'sets ssl_handshake_timeout to the specified value' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ ssl_handshake_timeout: 23 })
+ describe 'when the ssl_handshake_timeout option' do
+ describe 'is set' do
+ it 'sets ssl_handshake_timeout to the specified value' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ ssl_handshake_timeout: 23 })
- @ftp.send(:initialize, nil, options)
- @ftp.ssl_handshake_timeout.should == 23
- end
+ @ftp.send(:initialize, nil, options)
+ @ftp.ssl_handshake_timeout.should == 23
end
+ end
- describe 'is not set' do
- it 'sets ssl_handshake_timeout to nil' do
- @ftp.send(:initialize)
- @ftp.ssl_handshake_timeout.should == nil
- end
+ describe 'is not set' do
+ it 'sets ssl_handshake_timeout to nil' do
+ @ftp.send(:initialize)
+ @ftp.ssl_handshake_timeout.should == nil
end
end
+ end
- describe 'when the ssl option' do
- describe 'is set' do
- describe "and the ssl option's value is true" do
- it 'initializes ssl_context to a blank SSLContext object' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ ssl: true })
+ describe 'when the ssl option' do
+ describe 'is set' do
+ describe "and the ssl option's value is true" do
+ it 'initializes ssl_context to a blank SSLContext object' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ ssl: true })
- ssl_context = OpenSSL::SSL::SSLContext.allocate
- ssl_context.stub!(:set_params)
+ ssl_context = OpenSSL::SSL::SSLContext.allocate
+ ssl_context.stub!(:set_params)
- OpenSSL::SSL::SSLContext.should_receive(:new).and_return(ssl_context)
- ssl_context.should_receive(:set_params).with({})
+ OpenSSL::SSL::SSLContext.should_receive(:new).and_return(ssl_context)
+ ssl_context.should_receive(:set_params).with({})
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@ssl_context).should == ssl_context
- end
+ @ftp.send(:initialize, nil, options)
+ @ftp.instance_variable_get(:@ssl_context).should == ssl_context
end
+ end
- describe "and the ssl option's value is a hash" do
- it 'initializes ssl_context to a configured SSLContext object' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ ssl: {key: 'value'} })
+ describe "and the ssl option's value is a hash" do
+ it 'initializes ssl_context to a configured SSLContext object' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ ssl: {key: 'value'} })
- ssl_context = OpenSSL::SSL::SSLContext.allocate
- ssl_context.stub!(:set_params)
+ ssl_context = OpenSSL::SSL::SSLContext.allocate
+ ssl_context.stub!(:set_params)
- OpenSSL::SSL::SSLContext.should_receive(:new).and_return(ssl_context)
- ssl_context.should_receive(:set_params).with({key: 'value'})
+ OpenSSL::SSL::SSLContext.should_receive(:new).and_return(ssl_context)
+ ssl_context.should_receive(:set_params).with({key: 'value'})
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@ssl_context).should == ssl_context
- end
+ @ftp.send(:initialize, nil, options)
+ @ftp.instance_variable_get(:@ssl_context).should == ssl_context
end
+ end
- describe 'and private_data_connection' do
- describe 'is set' do
- it 'sets private_data_connection to that value' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ ssl: true, private_data_connection: 'true' })
+ describe 'and private_data_connection' do
+ describe 'is set' do
+ it 'sets private_data_connection to that value' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ ssl: true, private_data_connection: 'true' })
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@private_data_connection).should == 'true'
- end
+ @ftp.send(:initialize, nil, options)
+ @ftp.instance_variable_get(:@private_data_connection).should == 'true'
end
+ end
- describe 'is not set' do
- it 'sets private_data_connection to nil' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ ssl: true })
+ describe 'is not set' do
+ it 'sets private_data_connection to nil' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ ssl: true })
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@private_data_connection).should == true
- end
+ @ftp.send(:initialize, nil, options)
+ @ftp.instance_variable_get(:@private_data_connection).should == true
end
end
end
+ end
- describe 'is not set' do
- it 'sets ssl_context to nil' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({})
+ describe 'is not set' do
+ it 'sets ssl_context to nil' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({})
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@ssl_context).should == nil
- end
+ @ftp.send(:initialize, nil, options)
+ @ftp.instance_variable_get(:@ssl_context).should == nil
+ end
- describe 'private_data_connection' do
- describe 'is set' do
- it 'raises an ArgumentError' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({ private_data_connection: true })
+ describe 'private_data_connection' do
+ describe 'is set' do
+ it 'raises an ArgumentError' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({ private_data_connection: true })
- -> {
- @ftp.send(:initialize, nil, options)
- }.should raise_error(ArgumentError, /private_data_connection can be set to true only when ssl is enabled/)
- end
+ -> {
+ @ftp.send(:initialize, nil, options)
+ }.should raise_error(ArgumentError, /private_data_connection can be set to true only when ssl is enabled/)
end
+ end
- describe 'is not set' do
- it 'sets private_data_connection to false' do
- options = mock('ftp initialize options')
- options.should_receive(:to_hash).and_return({})
+ describe 'is not set' do
+ it 'sets private_data_connection to false' do
+ options = mock('ftp initialize options')
+ options.should_receive(:to_hash).and_return({})
- @ftp.send(:initialize, nil, options)
- @ftp.instance_variable_get(:@private_data_connection).should == false
- end
+ @ftp.send(:initialize, nil, options)
+ @ftp.instance_variable_get(:@private_data_connection).should == false
end
end
end
diff --git a/spec/ruby/library/net/ftp/status_spec.rb b/spec/ruby/library/net/ftp/status_spec.rb
index 22d0d47254..c3874ea41e 100644
--- a/spec/ruby/library/net/ftp/status_spec.rb
+++ b/spec/ruby/library/net/ftp/status_spec.rb
@@ -22,10 +22,8 @@ describe "Net::FTP#status" do
@ftp.last_response.should == "211 System status, or system help reply. (STAT)\n"
end
- ruby_version_is "2.4" do
- it "sends the STAT command with an optional parameter to the server" do
- @ftp.status("/pub").should == "211 System status, or system help reply. (STAT /pub)\n"
- end
+ it "sends the STAT command with an optional parameter to the server" do
+ @ftp.status("/pub").should == "211 System status, or system help reply. (STAT /pub)\n"
end
it "returns the received information" do
diff --git a/spec/ruby/library/net/http/http/post_spec.rb b/spec/ruby/library/net/http/http/post_spec.rb
index c8d41b9617..9f20a03c85 100644
--- a/spec/ruby/library/net/http/http/post_spec.rb
+++ b/spec/ruby/library/net/http/http/post_spec.rb
@@ -3,40 +3,38 @@ require 'net/http'
require 'uri'
require_relative 'fixtures/http_server'
-ruby_version_is '2.4' do
- describe "Net::HTTP.post" do
- before :each do
- NetHTTPSpecs.start_server
- end
+describe "Net::HTTP.post" do
+ before :each do
+ NetHTTPSpecs.start_server
+ end
- after :each do
- NetHTTPSpecs.stop_server
- end
+ after :each do
+ NetHTTPSpecs.stop_server
+ end
- it "sends post request to the specified URI and returns response" do
- response = Net::HTTP.post(
- URI("http://localhost:#{NetHTTPSpecs.port}/request"),
- '{ "q": "ruby", "max": "50" }',
- "Content-Type" => "application/json")
- response.body.should == "Request type: POST"
- end
+ it "sends post request to the specified URI and returns response" do
+ response = Net::HTTP.post(
+ URI("http://localhost:#{NetHTTPSpecs.port}/request"),
+ '{ "q": "ruby", "max": "50" }',
+ "Content-Type" => "application/json")
+ response.body.should == "Request type: POST"
+ end
- it "returns a Net::HTTPResponse" do
- response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request"), "test=test")
- response.should be_kind_of(Net::HTTPResponse)
- end
+ it "returns a Net::HTTPResponse" do
+ response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request"), "test=test")
+ response.should be_kind_of(Net::HTTPResponse)
+ end
- it "sends Content-Type: application/x-www-form-urlencoded by default" do
- response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request/header"), "test=test")
- response.body.should include('"content-type"=>["application/x-www-form-urlencoded"]')
- end
+ it "sends Content-Type: application/x-www-form-urlencoded by default" do
+ response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request/header"), "test=test")
+ response.body.should include('"content-type"=>["application/x-www-form-urlencoded"]')
+ end
- it "does not support HTTP Basic Auth" do
- response = Net::HTTP.post(
- URI("http://john:qwerty@localhost:#{NetHTTPSpecs.port}/request/basic_auth"),
- "test=test")
- response.body.should == "username: \npassword: "
- end
+ it "does not support HTTP Basic Auth" do
+ response = Net::HTTP.post(
+ URI("http://john:qwerty@localhost:#{NetHTTPSpecs.port}/request/basic_auth"),
+ "test=test")
+ response.body.should == "username: \npassword: "
end
end
diff --git a/spec/ruby/library/optionparser/order_spec.rb b/spec/ruby/library/optionparser/order_spec.rb
index 9d8f48d320..e49bd25554 100644
--- a/spec/ruby/library/optionparser/order_spec.rb
+++ b/spec/ruby/library/optionparser/order_spec.rb
@@ -2,31 +2,27 @@ require_relative '../../spec_helper'
require 'optparse'
describe "OptionParser#order" do
- ruby_version_is '2.4' do
- it "accepts `into` keyword argument and stores result in it" do
- options = {}
- parser = OptionParser.new do |opts|
- opts.on("-v", "--[no-]verbose", "Run verbosely")
- opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
- end
- parser.order %w[--verbose --require optparse], into: options
-
- options.should == { verbose: true, require: "optparse" }
+ it "accepts `into` keyword argument and stores result in it" do
+ options = {}
+ parser = OptionParser.new do |opts|
+ opts.on("-v", "--[no-]verbose", "Run verbosely")
+ opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
end
+ parser.order %w[--verbose --require optparse], into: options
+
+ options.should == { verbose: true, require: "optparse" }
end
end
describe "OptionParser#order!" do
- ruby_version_is '2.4' do
- it "accepts `into` keyword argument and stores result in it" do
- options = {}
- parser = OptionParser.new do |opts|
- opts.on("-v", "--[no-]verbose", "Run verbosely")
- opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
- end
- parser.order! %w[--verbose --require optparse], into: options
-
- options.should == { verbose: true, require: "optparse" }
+ it "accepts `into` keyword argument and stores result in it" do
+ options = {}
+ parser = OptionParser.new do |opts|
+ opts.on("-v", "--[no-]verbose", "Run verbosely")
+ opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
end
+ parser.order! %w[--verbose --require optparse], into: options
+
+ options.should == { verbose: true, require: "optparse" }
end
end
diff --git a/spec/ruby/library/optionparser/parse_spec.rb b/spec/ruby/library/optionparser/parse_spec.rb
index 5b105a7d0e..9511acb1db 100644
--- a/spec/ruby/library/optionparser/parse_spec.rb
+++ b/spec/ruby/library/optionparser/parse_spec.rb
@@ -2,31 +2,27 @@ require_relative '../../spec_helper'
require 'optparse'
describe "OptionParser#parse" do
- ruby_version_is '2.4' do
- it "accepts `into` keyword argument and stores result in it" do
- options = {}
- parser = OptionParser.new do |opts|
- opts.on("-v", "--[no-]verbose", "Run verbosely")
- opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
- end
- parser.parse %w[--verbose --require optparse], into: options
-
- options.should == { verbose: true, require: "optparse" }
+ it "accepts `into` keyword argument and stores result in it" do
+ options = {}
+ parser = OptionParser.new do |opts|
+ opts.on("-v", "--[no-]verbose", "Run verbosely")
+ opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
end
+ parser.parse %w[--verbose --require optparse], into: options
+
+ options.should == { verbose: true, require: "optparse" }
end
end
describe "OptionParser#parse!" do
- ruby_version_is '2.4' do
- it "accepts `into` keyword argument and stores result in it" do
- options = {}
- parser = OptionParser.new do |opts|
- opts.on("-v", "--[no-]verbose", "Run verbosely")
- opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
- end
- parser.parse! %w[--verbose --require optparse], into: options
-
- options.should == { verbose: true, require: "optparse" }
+ it "accepts `into` keyword argument and stores result in it" do
+ options = {}
+ parser = OptionParser.new do |opts|
+ opts.on("-v", "--[no-]verbose", "Run verbosely")
+ opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script")
end
+ parser.parse! %w[--verbose --require optparse], into: options
+
+ options.should == { verbose: true, require: "optparse" }
end
end
diff --git a/spec/ruby/library/pathname/empty_spec.rb b/spec/ruby/library/pathname/empty_spec.rb
index 6f46486a69..4deade5b64 100644
--- a/spec/ruby/library/pathname/empty_spec.rb
+++ b/spec/ruby/library/pathname/empty_spec.rb
@@ -1,34 +1,32 @@
require_relative '../../spec_helper'
require 'pathname'
-ruby_version_is '2.4' do
- describe 'Pathname#empty?' do
- before :all do
- @file = tmp 'new_file_path_name.txt'
- touch @file
- @dir = tmp 'new_directory_path_name'
- Dir.mkdir @dir
- end
+describe 'Pathname#empty?' do
+ before :all do
+ @file = tmp 'new_file_path_name.txt'
+ touch @file
+ @dir = tmp 'new_directory_path_name'
+ Dir.mkdir @dir
+ end
- after :all do
- rm_r @file
- rm_r @dir
- end
+ after :all do
+ rm_r @file
+ rm_r @dir
+ end
- it 'returns true when file is not empty' do
- Pathname.new(__FILE__).empty?.should be_false
- end
+ it 'returns true when file is not empty' do
+ Pathname.new(__FILE__).empty?.should be_false
+ end
- it 'returns false when the directory is not empty' do
- Pathname.new(__dir__).empty?.should be_false
- end
+ it 'returns false when the directory is not empty' do
+ Pathname.new(__dir__).empty?.should be_false
+ end
- it 'return true when file is empty' do
- Pathname.new(@file).empty?.should be_true
- end
+ it 'return true when file is empty' do
+ Pathname.new(@file).empty?.should be_true
+ end
- it 'returns true when directory is empty' do
- Pathname.new(@dir).empty?.should be_true
- end
+ it 'returns true when directory is empty' do
+ Pathname.new(@dir).empty?.should be_true
end
end
diff --git a/spec/ruby/library/rbconfig/rbconfig_spec.rb b/spec/ruby/library/rbconfig/rbconfig_spec.rb
index 71e3d376d1..6725de8289 100644
--- a/spec/ruby/library/rbconfig/rbconfig_spec.rb
+++ b/spec/ruby/library/rbconfig/rbconfig_spec.rb
@@ -24,3 +24,13 @@ describe 'RbConfig::CONFIG' do
end
end
end
+
+describe "RbConfig::TOPDIR" do
+ it "either returns nil (if not installed) or the prefix" do
+ if RbConfig::TOPDIR
+ RbConfig::TOPDIR.should == RbConfig::CONFIG["prefix"]
+ else
+ RbConfig::TOPDIR.should == nil
+ end
+ end
+end
diff --git a/spec/ruby/library/rexml/element/element_reference_spec.rb b/spec/ruby/library/rexml/element/element_reference_spec.rb
index db94303b1e..9660ff7507 100644
--- a/spec/ruby/library/rexml/element/element_reference_spec.rb
+++ b/spec/ruby/library/rexml/element/element_reference_spec.rb
@@ -9,14 +9,12 @@ describe "REXML::Element#[]" do
@doc.root.add_element @child
end
- ruby_version_is "2.4" do
- it "return attribute value if argument is string or symbol" do
- @doc.root[:foo].should == 'bar'
- @doc.root['foo'].should == 'bar'
- end
+ it "return attribute value if argument is string or symbol" do
+ @doc.root[:foo].should == 'bar'
+ @doc.root['foo'].should == 'bar'
+ end
- it "return nth element if argument is int" do
- @doc.root[0].should == @child
- end
+ it "return nth element if argument is int" do
+ @doc.root[0].should == @child
end
end
diff --git a/spec/ruby/library/set/compare_by_identity_spec.rb b/spec/ruby/library/set/compare_by_identity_spec.rb
index 363a108935..01b66ec92b 100644
--- a/spec/ruby/library/set/compare_by_identity_spec.rb
+++ b/spec/ruby/library/set/compare_by_identity_spec.rb
@@ -1,147 +1,143 @@
require_relative '../../spec_helper'
require 'set'
-ruby_version_is '2.4' do
- describe "Set#compare_by_identity" do
- it "compares its members by identity" do
- a = "a"
- b1 = "b"
- b2 = "b"
-
- set = Set.new
- set.compare_by_identity
- set.merge([a, a, b1, b2])
- set.to_a.sort.should == [a, b1, b2].sort
- end
-
- it "causes future comparisons on the receiver to be made by identity" do
- elt = [1]
- set = Set.new
- set << elt
- set.member?(elt.dup).should be_true
- set.compare_by_identity
- set.member?(elt.dup).should be_false
- end
-
- it "rehashes internally so that old members can be looked up" do
- set = Set.new
- (1..10).each { |k| set << k }
- o = Object.new
- def o.hash; 123; end
- set << o
+describe "Set#compare_by_identity" do
+ it "compares its members by identity" do
+ a = "a"
+ b1 = "b"
+ b2 = "b"
+
+ set = Set.new
+ set.compare_by_identity
+ set.merge([a, a, b1, b2])
+ set.to_a.sort.should == [a, b1, b2].sort
+ end
+
+ it "causes future comparisons on the receiver to be made by identity" do
+ elt = [1]
+ set = Set.new
+ set << elt
+ set.member?(elt.dup).should be_true
+ set.compare_by_identity
+ set.member?(elt.dup).should be_false
+ end
+
+ it "rehashes internally so that old members can be looked up" do
+ set = Set.new
+ (1..10).each { |k| set << k }
+ o = Object.new
+ def o.hash; 123; end
+ set << o
+ set.compare_by_identity
+ set.member?(o).should be_true
+ end
+
+ it "returns self" do
+ set = Set.new
+ result = set.compare_by_identity
+ result.should equal(set)
+ end
+
+ it "is idempotent and has no effect on an already compare_by_identity set" do
+ set = Set.new.compare_by_identity
+ set << :foo
+ set.compare_by_identity.should equal(set)
+ set.compare_by_identity?.should == true
+ set.to_a.should == [:foo]
+ end
+
+ it "uses the semantics of BasicObject#equal? to determine members identity" do
+ :a.equal?(:a).should == true
+ Set.new.compare_by_identity.merge([:a, :a]).to_a.should == [:a]
+
+ ary1 = [1]
+ ary2 = [1]
+ ary1.equal?(ary2).should == false
+ Set.new.compare_by_identity.merge([ary1, ary2]).to_a.sort.should == [ary1, ary2].sort
+ end
+
+ it "uses #equal? semantics, but doesn't actually call #equal? to determine identity" do
+ set = Set.new.compare_by_identity
+ obj = mock("equal")
+ obj.should_not_receive(:equal?)
+ set << :foo
+ set << obj
+ set.to_a.should == [:foo, obj]
+ end
+
+ it "does not call #hash on members" do
+ elt = mock("element")
+ elt.should_not_receive(:hash)
+ set = Set.new.compare_by_identity
+ set << elt
+ set.member?(elt).should be_true
+ end
+
+ it "regards #dup'd objects as having different identities" do
+ a1 = "a"
+ a2 = a1.dup
+
+ set = Set.new.compare_by_identity
+ set.merge([a1, a2])
+ set.to_a.sort.should == [a1, a2].sort
+ end
+
+ it "regards #clone'd objects as having different identities" do
+ a1 = "a"
+ a2 = a1.clone
+
+ set = Set.new.compare_by_identity
+ set.merge([a1, a2])
+ set.to_a.sort.should == [a1, a2].sort
+ end
+
+ it "raises a #{frozen_error_class} on frozen sets" do
+ set = Set.new.freeze
+ lambda {
set.compare_by_identity
- set.member?(o).should be_true
- end
-
- it "returns self" do
- set = Set.new
- result = set.compare_by_identity
- result.should equal(set)
- end
-
- it "is idempotent and has no effect on an already compare_by_identity set" do
- set = Set.new.compare_by_identity
- set << :foo
- set.compare_by_identity.should equal(set)
- set.compare_by_identity?.should == true
- set.to_a.should == [:foo]
- end
-
- it "uses the semantics of BasicObject#equal? to determine members identity" do
- :a.equal?(:a).should == true
- Set.new.compare_by_identity.merge([:a, :a]).to_a.should == [:a]
-
- ary1 = [1]
- ary2 = [1]
- ary1.equal?(ary2).should == false
- Set.new.compare_by_identity.merge([ary1, ary2]).to_a.sort.should == [ary1, ary2].sort
- end
-
- it "uses #equal? semantics, but doesn't actually call #equal? to determine identity" do
- set = Set.new.compare_by_identity
- obj = mock("equal")
- obj.should_not_receive(:equal?)
- set << :foo
- set << obj
- set.to_a.should == [:foo, obj]
- end
-
- it "does not call #hash on members" do
- elt = mock("element")
- elt.should_not_receive(:hash)
- set = Set.new.compare_by_identity
- set << elt
- set.member?(elt).should be_true
- end
-
- it "regards #dup'd objects as having different identities" do
- a1 = "a"
- a2 = a1.dup
-
- set = Set.new.compare_by_identity
- set.merge([a1, a2])
- set.to_a.sort.should == [a1, a2].sort
- end
-
- it "regards #clone'd objects as having different identities" do
- a1 = "a"
- a2 = a1.clone
-
- set = Set.new.compare_by_identity
- set.merge([a1, a2])
- set.to_a.sort.should == [a1, a2].sort
- end
-
- it "raises a #{frozen_error_class} on frozen sets" do
- set = Set.new.freeze
- lambda {
- set.compare_by_identity
- }.should raise_error(frozen_error_class, /frozen Hash/)
- end
-
- it "persists over #dups" do
- set = Set.new.compare_by_identity
- set << :a
- set_dup = set.dup
- set_dup.should == set
- set_dup << :a
- set_dup.to_a.should == [:a]
- end
-
- it "persists over #clones" do
- set = Set.new.compare_by_identity
- set << :a
- set_clone = set.clone
- set_clone.should == set
- set_clone << :a
- set_clone.to_a.should == [:a]
- end
-
- it "is not equal to set what does not compare by identity" do
- Set.new([1, 2]).should == Set.new([1, 2])
- Set.new([1, 2]).should_not == Set.new([1, 2]).compare_by_identity
- end
+ }.should raise_error(frozen_error_class, /frozen Hash/)
+ end
+
+ it "persists over #dups" do
+ set = Set.new.compare_by_identity
+ set << :a
+ set_dup = set.dup
+ set_dup.should == set
+ set_dup << :a
+ set_dup.to_a.should == [:a]
+ end
+
+ it "persists over #clones" do
+ set = Set.new.compare_by_identity
+ set << :a
+ set_clone = set.clone
+ set_clone.should == set
+ set_clone << :a
+ set_clone.to_a.should == [:a]
+ end
+
+ it "is not equal to set what does not compare by identity" do
+ Set.new([1, 2]).should == Set.new([1, 2])
+ Set.new([1, 2]).should_not == Set.new([1, 2]).compare_by_identity
end
end
-ruby_version_is '2.4' do
- describe "Set#compare_by_identity?" do
- it "returns false by default" do
- Set.new.compare_by_identity?.should == false
- end
+describe "Set#compare_by_identity?" do
+ it "returns false by default" do
+ Set.new.compare_by_identity?.should == false
+ end
- it "returns true once #compare_by_identity has been invoked on self" do
- set = Set.new
- set.compare_by_identity
- set.compare_by_identity?.should == true
- end
+ it "returns true once #compare_by_identity has been invoked on self" do
+ set = Set.new
+ set.compare_by_identity
+ set.compare_by_identity?.should == true
+ end
- it "returns true when called multiple times on the same set" do
- set = Set.new
- set.compare_by_identity
- set.compare_by_identity?.should == true
- set.compare_by_identity?.should == true
- set.compare_by_identity?.should == true
- end
+ it "returns true when called multiple times on the same set" do
+ set = Set.new
+ set.compare_by_identity
+ set.compare_by_identity?.should == true
+ set.compare_by_identity?.should == true
+ set.compare_by_identity?.should == true
end
end
diff --git a/spec/ruby/library/shellwords/shellwords_spec.rb b/spec/ruby/library/shellwords/shellwords_spec.rb
index b245fe862d..bb6bcb3d30 100644
--- a/spec/ruby/library/shellwords/shellwords_spec.rb
+++ b/spec/ruby/library/shellwords/shellwords_spec.rb
@@ -27,10 +27,8 @@ describe "Shellwords#shellwords" do
lambda { shellwords("a 'b c d e") }.should raise_error(ArgumentError)
end
- ruby_version_is '2.4' do
- # https://bugs.ruby-lang.org/issues/10055
- it "matches POSIX sh behavior for backslashes within double quoted strings" do
- shellsplit('printf "%s\n"').should == ['printf', '%s\n']
- end
+ # https://bugs.ruby-lang.org/issues/10055
+ it "matches POSIX sh behavior for backslashes within double quoted strings" do
+ shellsplit('printf "%s\n"').should == ['printf', '%s\n']
end
end
diff --git a/spec/ruby/library/socket/fixtures/classes.rb b/spec/ruby/library/socket/fixtures/classes.rb
index b73fd0fa4c..4cfa084333 100644
--- a/spec/ruby/library/socket/fixtures/classes.rb
+++ b/spec/ruby/library/socket/fixtures/classes.rb
@@ -71,12 +71,12 @@ module SocketSpecs
end
end
- def self.loop_with_timeout(timeout = 5)
+ def self.loop_with_timeout(timeout = TIME_TOLERANCE)
require 'timeout'
- time = Time.now
+ time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
loop do
- if Time.now - time >= timeout
+ if Process.clock_gettime(Process::CLOCK_MONOTONIC) - time >= timeout
raise TimeoutError, "Did not succeed within #{timeout} seconds"
end
@@ -85,7 +85,7 @@ module SocketSpecs
end
end
- def self.wait_until_success(timeout = 5)
+ def self.wait_until_success(timeout = TIME_TOLERANCE)
loop_with_timeout(timeout) do
begin
return yield
diff --git a/spec/ruby/library/stringio/each_line_spec.rb b/spec/ruby/library/stringio/each_line_spec.rb
index f6eae02690..1389408399 100644
--- a/spec/ruby/library/stringio/each_line_spec.rb
+++ b/spec/ruby/library/stringio/each_line_spec.rb
@@ -14,8 +14,6 @@ describe "StringIO#each_line when self is not readable" do
it_behaves_like :stringio_each_not_readable, :each_line
end
-ruby_version_is "2.4" do
- describe "StringIO#each_line when passed chomp" do
- it_behaves_like :stringio_each_chomp, :each_line
- end
+describe "StringIO#each_line when passed chomp" do
+ it_behaves_like :stringio_each_chomp, :each_line
end
diff --git a/spec/ruby/library/stringio/each_spec.rb b/spec/ruby/library/stringio/each_spec.rb
index 4ecaba3dad..a76460049b 100644
--- a/spec/ruby/library/stringio/each_spec.rb
+++ b/spec/ruby/library/stringio/each_spec.rb
@@ -14,8 +14,6 @@ describe "StringIO#each when self is not readable" do
it_behaves_like :stringio_each_not_readable, :each
end
-ruby_version_is "2.4" do
- describe "StringIO#each when passed chomp" do
- it_behaves_like :stringio_each_chomp, :each
- end
+describe "StringIO#each when passed chomp" do
+ it_behaves_like :stringio_each_chomp, :each
end
diff --git a/spec/ruby/library/stringio/gets_spec.rb b/spec/ruby/library/stringio/gets_spec.rb
index 7fe00d8d19..d682b2784f 100644
--- a/spec/ruby/library/stringio/gets_spec.rb
+++ b/spec/ruby/library/stringio/gets_spec.rb
@@ -237,11 +237,9 @@ describe "StringIO#gets when in write-only mode" do
end
end
-ruby_version_is "2.4" do
- describe "StringIO#gets when passed [chomp]" do
- it "returns the data read without a trailing newline character" do
- io = StringIO.new("this>is>an>example\n")
- io.gets(chomp: true).should == "this>is>an>example"
- end
+describe "StringIO#gets when passed [chomp]" do
+ it "returns the data read without a trailing newline character" do
+ io = StringIO.new("this>is>an>example\n")
+ io.gets(chomp: true).should == "this>is>an>example"
end
end
diff --git a/spec/ruby/library/stringio/lines_spec.rb b/spec/ruby/library/stringio/lines_spec.rb
index dd5773f5a3..d9dd26c2e2 100644
--- a/spec/ruby/library/stringio/lines_spec.rb
+++ b/spec/ruby/library/stringio/lines_spec.rb
@@ -14,8 +14,6 @@ describe "StringIO#lines when self is not readable" do
it_behaves_like :stringio_each_not_readable, :lines
end
-ruby_version_is "2.4" do
- describe "StringIO#lines when passed chomp" do
- it_behaves_like :stringio_each_chomp, :lines
- end
+describe "StringIO#lines when passed chomp" do
+ it_behaves_like :stringio_each_chomp, :lines
end
diff --git a/spec/ruby/library/stringio/readline_spec.rb b/spec/ruby/library/stringio/readline_spec.rb
index fc1e75b67e..dc396f61a9 100644
--- a/spec/ruby/library/stringio/readline_spec.rb
+++ b/spec/ruby/library/stringio/readline_spec.rb
@@ -121,11 +121,9 @@ describe "StringIO#readline when in write-only mode" do
end
end
-ruby_version_is "2.4" do
- describe "StringIO#readline when passed [chomp]" do
- it "returns the data read without a trailing newline character" do
- io = StringIO.new("this>is>an>example\n")
- io.readline(chomp: true).should == "this>is>an>example"
- end
+describe "StringIO#readline when passed [chomp]" do
+ it "returns the data read without a trailing newline character" do
+ io = StringIO.new("this>is>an>example\n")
+ io.readline(chomp: true).should == "this>is>an>example"
end
end
diff --git a/spec/ruby/library/stringio/readlines_spec.rb b/spec/ruby/library/stringio/readlines_spec.rb
index c15f81b846..840470c09c 100644
--- a/spec/ruby/library/stringio/readlines_spec.rb
+++ b/spec/ruby/library/stringio/readlines_spec.rb
@@ -91,11 +91,9 @@ describe "StringIO#readlines when in write-only mode" do
end
end
-ruby_version_is "2.4" do
- describe "StringIO#readlines when passed [chomp]" do
- it "returns the data read without a trailing newline character" do
- io = StringIO.new("this>is\nan>example\r\n")
- io.readlines(chomp: true).should == ["this>is", "an>example"]
- end
+describe "StringIO#readlines when passed [chomp]" do
+ it "returns the data read without a trailing newline character" do
+ io = StringIO.new("this>is\nan>example\r\n")
+ io.readlines(chomp: true).should == ["this>is", "an>example"]
end
end
diff --git a/spec/ruby/library/stringscanner/scan_spec.rb b/spec/ruby/library/stringscanner/scan_spec.rb
index 23de7f07cb..8e26b80591 100644
--- a/spec/ruby/library/stringscanner/scan_spec.rb
+++ b/spec/ruby/library/stringscanner/scan_spec.rb
@@ -19,6 +19,22 @@ describe "StringScanner#scan" do
@s.scan(/^\s/).should == " "
end
+ it "treats ^ as matching from the beginning of the current position when it's not the first character in the regexp" do
+ @s.scan(/\w+/).should == "This"
+ @s.scan(/( is not|^ is a)/).should == " is a"
+ end
+
+ it "treats \\A as matching from the beginning of the current position" do
+ @s.scan(/\w+/).should == "This"
+ @s.scan(/\A\d/).should be_nil
+ @s.scan(/\A\s/).should == " "
+ end
+
+ it "treats \\A as matching from the beginning of the current position when it's not the first character in the regexp" do
+ @s.scan(/\w+/).should == "This"
+ @s.scan(/( is not|\A is a)/).should == " is a"
+ end
+
it "returns nil if there's no match" do
@s.scan(/\d/).should == nil
end
diff --git a/spec/ruby/library/time/to_time_spec.rb b/spec/ruby/library/time/to_time_spec.rb
index 5602915551..7e6c75a003 100644
--- a/spec/ruby/library/time/to_time_spec.rb
+++ b/spec/ruby/library/time/to_time_spec.rb
@@ -1,17 +1,15 @@
require_relative '../../spec_helper'
require 'time'
-ruby_version_is "2.4" do
- describe "Time#to_time" do
- it "returns itself in the same timezone" do
- time = Time.new(2012, 2, 21, 10, 11, 12)
+describe "Time#to_time" do
+ it "returns itself in the same timezone" do
+ time = Time.new(2012, 2, 21, 10, 11, 12)
- with_timezone("America/Regina") do
- time.to_time.should equal time
- end
-
- time2 = Time.utc(2012, 2, 21, 10, 11, 12)
- time2.to_time.should equal time2
+ with_timezone("America/Regina") do
+ time.to_time.should equal time
end
+
+ time2 = Time.utc(2012, 2, 21, 10, 11, 12)
+ time2.to_time.should equal time2
end
end
diff --git a/spec/ruby/library/timeout/timeout_spec.rb b/spec/ruby/library/timeout/timeout_spec.rb
index ac0580ec13..fc957dc36f 100644
--- a/spec/ruby/library/timeout/timeout_spec.rb
+++ b/spec/ruby/library/timeout/timeout_spec.rb
@@ -5,7 +5,7 @@ describe "Timeout.timeout" do
it "raises Timeout::Error when it times out with no specified error type" do
lambda {
Timeout.timeout(1) do
- sleep 3
+ sleep
end
}.should raise_error(Timeout::Error)
end
@@ -13,22 +13,11 @@ describe "Timeout.timeout" do
it "raises specified error type when it times out" do
lambda do
Timeout.timeout(1, StandardError) do
- sleep 3
+ sleep
end
end.should raise_error(StandardError)
end
- it "does not wait too long" do
- before_time = Time.now
- lambda do
- Timeout.timeout(1, StandardError) do
- sleep 3
- end
- end.should raise_error(StandardError)
-
- (Time.now - before_time).should be_close(1.0, 0.8)
- end
-
it "returns back the last value in the block" do
Timeout.timeout(1) do
42
diff --git a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
index f29927e20b..6fb6915f15 100644
--- a/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/ungetbyte_spec.rb
@@ -21,11 +21,9 @@ describe 'GzipReader#ungetbyte' do
@gz.read.should == '!12345abcde'
end
- ruby_bug "#13616", ""..."2.6" do
- it 'decrements pos' do
- @gz.ungetbyte 0x21
- @gz.pos.should == -1
- end
+ it 'decrements pos' do
+ @gz.ungetbyte 0x21
+ @gz.pos.should == -1
end
end
diff --git a/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb b/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
index d749d58cca..d19ec61610 100644
--- a/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
+++ b/spec/ruby/library/zlib/gzipreader/ungetc_spec.rb
@@ -21,11 +21,9 @@ describe 'GzipReader#ungetc' do
@gz.read.should == 'x12345abcde'
end
- ruby_bug "#13616", ""..."2.6" do
- it 'decrements pos' do
- @gz.ungetc 'x'
- @gz.pos.should == -1
- end
+ it 'decrements pos' do
+ @gz.ungetc 'x'
+ @gz.pos.should == -1
end
end
@@ -35,11 +33,9 @@ describe 'GzipReader#ungetc' do
@gz.read.should == 'ŷ12345abcde'
end
- ruby_bug "#13616", ""..."2.6" do
- it 'decrements pos' do
- @gz.ungetc 'ŷ'
- @gz.pos.should == -2
- end
+ it 'decrements pos' do
+ @gz.ungetc 'ŷ'
+ @gz.pos.should == -2
end
end
@@ -49,11 +45,9 @@ describe 'GzipReader#ungetc' do
@gz.read.should == 'xŷž12345abcde'
end
- ruby_bug "#13616", ""..."2.6" do
- it 'decrements pos' do
- @gz.ungetc 'xŷž'
- @gz.pos.should == -5
- end
+ it 'decrements pos' do
+ @gz.ungetc 'xŷž'
+ @gz.pos.should == -5
end
end
@@ -63,11 +57,9 @@ describe 'GzipReader#ungetc' do
@gz.read.should == '!12345abcde'
end
- ruby_bug "#13616", ""..."2.6" do
- it 'decrements pos' do
- @gz.ungetc 0x21
- @gz.pos.should == -1
- end
+ it 'decrements pos' do
+ @gz.ungetc 0x21
+ @gz.pos.should == -1
end
end