summaryrefslogtreecommitdiff
path: root/spec/ruby/core/kernel
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2019-07-27 12:40:09 +0200
committerBenoit Daloze <eregontp@gmail.com>2019-07-27 12:40:09 +0200
commit5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch)
tree05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/core/kernel
parenta06301b103371b0b7da8eaca26ba744961769f99 (diff)
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/core/kernel')
-rw-r--r--spec/ruby/core/kernel/Array_spec.rb4
-rw-r--r--spec/ruby/core/kernel/Complex_spec.rb12
-rw-r--r--spec/ruby/core/kernel/Float_spec.rb82
-rw-r--r--spec/ruby/core/kernel/Hash_spec.rb4
-rw-r--r--spec/ruby/core/kernel/Integer_spec.rb200
-rw-r--r--spec/ruby/core/kernel/String_spec.rb8
-rw-r--r--spec/ruby/core/kernel/backtick_spec.rb4
-rw-r--r--spec/ruby/core/kernel/binding_spec.rb2
-rw-r--r--spec/ruby/core/kernel/catch_spec.rb6
-rw-r--r--spec/ruby/core/kernel/define_singleton_method_spec.rb16
-rw-r--r--spec/ruby/core/kernel/dup_spec.rb6
-rw-r--r--spec/ruby/core/kernel/eval_spec.rb12
-rw-r--r--spec/ruby/core/kernel/extend_spec.rb8
-rw-r--r--spec/ruby/core/kernel/fail_spec.rb8
-rw-r--r--spec/ruby/core/kernel/fixtures/classes.rb25
-rw-r--r--spec/ruby/core/kernel/fixtures/eval_return_with_lambda.rb2
-rw-r--r--spec/ruby/core/kernel/freeze_spec.rb4
-rw-r--r--spec/ruby/core/kernel/gsub_spec.rb2
-rw-r--r--spec/ruby/core/kernel/instance_of_spec.rb6
-rw-r--r--spec/ruby/core/kernel/instance_variable_defined_spec.rb2
-rw-r--r--spec/ruby/core/kernel/instance_variable_get_spec.rb24
-rw-r--r--spec/ruby/core/kernel/instance_variable_set_spec.rb20
-rw-r--r--spec/ruby/core/kernel/instance_variables_spec.rb2
-rw-r--r--spec/ruby/core/kernel/loop_spec.rb2
-rw-r--r--spec/ruby/core/kernel/open_spec.rb8
-rw-r--r--spec/ruby/core/kernel/p_spec.rb18
-rw-r--r--spec/ruby/core/kernel/printf_spec.rb4
-rw-r--r--spec/ruby/core/kernel/proc_spec.rb2
-rw-r--r--spec/ruby/core/kernel/public_method_spec.rb6
-rw-r--r--spec/ruby/core/kernel/public_send_spec.rb12
-rw-r--r--spec/ruby/core/kernel/rand_spec.rb6
-rw-r--r--spec/ruby/core/kernel/remove_instance_variable_spec.rb6
-rw-r--r--spec/ruby/core/kernel/require_relative_spec.rb36
-rw-r--r--spec/ruby/core/kernel/respond_to_spec.rb4
-rw-r--r--spec/ruby/core/kernel/shared/dup_clone.rb4
-rw-r--r--spec/ruby/core/kernel/shared/kind_of.rb8
-rw-r--r--spec/ruby/core/kernel/shared/lambda.rb2
-rw-r--r--spec/ruby/core/kernel/shared/load.rb4
-rw-r--r--spec/ruby/core/kernel/shared/method.rb4
-rw-r--r--spec/ruby/core/kernel/shared/require.rb32
-rw-r--r--spec/ruby/core/kernel/shared/sprintf.rb24
-rw-r--r--spec/ruby/core/kernel/shared/sprintf_encoding.rb2
-rw-r--r--spec/ruby/core/kernel/singleton_class_spec.rb4
-rw-r--r--spec/ruby/core/kernel/sleep_spec.rb8
-rw-r--r--spec/ruby/core/kernel/spawn_spec.rb4
-rw-r--r--spec/ruby/core/kernel/sprintf_spec.rb8
-rw-r--r--spec/ruby/core/kernel/srand_spec.rb6
-rw-r--r--spec/ruby/core/kernel/system_spec.rb18
-rw-r--r--spec/ruby/core/kernel/taint_spec.rb6
-rw-r--r--spec/ruby/core/kernel/tap_spec.rb2
-rw-r--r--spec/ruby/core/kernel/throw_spec.rb10
-rw-r--r--spec/ruby/core/kernel/trace_var_spec.rb2
-rw-r--r--spec/ruby/core/kernel/trust_spec.rb2
-rw-r--r--spec/ruby/core/kernel/untaint_spec.rb2
-rw-r--r--spec/ruby/core/kernel/untrust_spec.rb2
-rw-r--r--spec/ruby/core/kernel/untrusted_spec.rb2
-rw-r--r--spec/ruby/core/kernel/warn_spec.rb18
57 files changed, 374 insertions, 363 deletions
diff --git a/spec/ruby/core/kernel/Array_spec.rb b/spec/ruby/core/kernel/Array_spec.rb
index 5aa54cbcb6..b4a8bb7599 100644
--- a/spec/ruby/core/kernel/Array_spec.rb
+++ b/spec/ruby/core/kernel/Array_spec.rb
@@ -77,14 +77,14 @@ describe :kernel_Array, shared: true do
obj = mock("Array() string")
obj.should_receive(:to_ary).and_return("string")
- lambda { @object.send(@method, obj) }.should raise_error(TypeError)
+ -> { @object.send(@method, obj) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_a does not return an Array" do
obj = mock("Array() string")
obj.should_receive(:to_a).and_return("string")
- lambda { @object.send(@method, obj) }.should raise_error(TypeError)
+ -> { @object.send(@method, obj) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/Complex_spec.rb b/spec/ruby/core/kernel/Complex_spec.rb
index cb90718759..37f9843931 100644
--- a/spec/ruby/core/kernel/Complex_spec.rb
+++ b/spec/ruby/core/kernel/Complex_spec.rb
@@ -126,16 +126,16 @@ describe "Kernel.Complex()" do
describe "when passed a non-Numeric second argument" do
it "raises TypeError" do
- lambda { Complex(:sym, :sym) }.should raise_error(TypeError)
- lambda { Complex(0, :sym) }.should raise_error(TypeError)
+ -> { Complex(:sym, :sym) }.should raise_error(TypeError)
+ -> { Complex(0, :sym) }.should raise_error(TypeError)
end
end
describe "when passed nil" do
it "raises TypeError" do
- lambda { Complex(nil) }.should raise_error(TypeError, "can't convert nil into Complex")
- lambda { Complex(0, nil) }.should raise_error(TypeError, "can't convert nil into Complex")
- lambda { Complex(nil, 0) }.should raise_error(TypeError, "can't convert nil into Complex")
+ -> { Complex(nil) }.should raise_error(TypeError, "can't convert nil into Complex")
+ -> { Complex(0, nil) }.should raise_error(TypeError, "can't convert nil into Complex")
+ -> { Complex(nil, 0) }.should raise_error(TypeError, "can't convert nil into Complex")
end
end
@@ -155,7 +155,7 @@ describe "Kernel.Complex()" do
describe "and [non-Numeric, Numeric] argument" do
it "throws a TypeError" do
- lambda { Complex(:sym, 0, exception: false) }.should raise_error(TypeError, "not a real")
+ -> { Complex(:sym, 0, exception: false) }.should raise_error(TypeError, "not a real")
end
end
diff --git a/spec/ruby/core/kernel/Float_spec.rb b/spec/ruby/core/kernel/Float_spec.rb
index 43daefa6aa..6580c38137 100644
--- a/spec/ruby/core/kernel/Float_spec.rb
+++ b/spec/ruby/core/kernel/Float_spec.rb
@@ -22,7 +22,7 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError for nil" do
- lambda { @object.send(:Float, nil) }.should raise_error(TypeError)
+ -> { @object.send(:Float, nil) }.should raise_error(TypeError)
end
it "returns the identical NaN for NaN" do
@@ -51,24 +51,24 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError for a String of word characters" do
- lambda { @object.send(:Float, "float") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "float") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are two decimal points in the String" do
- lambda { @object.send(:Float, "10.0.0") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "10.0.0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String of numbers followed by word characters" do
- lambda { @object.send(:Float, "10D") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "10D") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String of word characters followed by numbers" do
- lambda { @object.send(:Float, "D10") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "D10") }.should raise_error(ArgumentError)
end
it "is strict about the string form even across newlines" do
- lambda { @object.send(:Float, "not a number\n10") }.should raise_error(ArgumentError)
- lambda { @object.send(:Float, "10\nnot a number") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "not a number\n10") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "10\nnot a number") }.should raise_error(ArgumentError)
end
it "converts String subclasses to floats without calling #to_f" do
@@ -90,17 +90,17 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError if a + or - is embedded in a String" do
- lambda { @object.send(:Float, "1+1") }.should raise_error(ArgumentError)
- lambda { @object.send(:Float, "1-1") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "1+1") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "1-1") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if a String has a trailing + or -" do
- lambda { @object.send(:Float, "11+") }.should raise_error(ArgumentError)
- lambda { @object.send(:Float, "11-") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "11+") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "11-") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String with a leading _" do
- lambda { @object.send(:Float, "_1") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "_1") }.should raise_error(ArgumentError)
end
it "returns a value for a String with an embedded _" do
@@ -108,31 +108,31 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError for a String with a trailing _" do
- lambda { @object.send(:Float, "10_") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "10_") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String of \\0" do
- lambda { @object.send(:Float, "\0") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "\0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String with a leading \\0" do
- lambda { @object.send(:Float, "\01") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "\01") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String with an embedded \\0" do
- lambda { @object.send(:Float, "1\01") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "1\01") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String with a trailing \\0" do
- lambda { @object.send(:Float, "1\0") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "1\0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String that is just an empty space" do
- lambda { @object.send(:Float, " ") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, " ") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a String that with an embedded space" do
- lambda { @object.send(:Float, "1 2") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "1 2") }.should raise_error(ArgumentError)
end
it "returns a value for a String with a leading space" do
@@ -153,11 +153,11 @@ describe :kernel_float, shared: true do
%w(e E).each do |e|
it "raises an ArgumentError if #{e} is the trailing character" do
- lambda { @object.send(:Float, "2#{e}") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "2#{e}") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if #{e} is the leading character" do
- lambda { @object.send(:Float, "#{e}2") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "#{e}2") }.should raise_error(ArgumentError)
end
it "returns Infinity for '2#{e}1000'" do
@@ -175,18 +175,18 @@ describe :kernel_float, shared: true do
end
it "raises an exception if a space is embedded on either side of the '#{e}'" do
- lambda { @object.send(:Float, "2 0#{e}100") }.should raise_error(ArgumentError)
- lambda { @object.send(:Float, "20#{e}1 00") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "2 0#{e}100") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "20#{e}1 00") }.should raise_error(ArgumentError)
end
it "raises an exception if there's a leading _ on either side of the '#{e}'" do
- lambda { @object.send(:Float, "_20#{e}100") }.should raise_error(ArgumentError)
- lambda { @object.send(:Float, "20#{e}_100") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "_20#{e}100") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "20#{e}_100") }.should raise_error(ArgumentError)
end
it "raises an exception if there's a trailing _ on either side of the '#{e}'" do
- lambda { @object.send(:Float, "20_#{e}100") }.should raise_error(ArgumentError)
- lambda { @object.send(:Float, "20#{e}100_") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "20_#{e}100") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "20#{e}100_") }.should raise_error(ArgumentError)
end
it "allows decimal points on the left side of the '#{e}'" do
@@ -194,7 +194,7 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError if there's a decimal point on the right side of the '#{e}'" do
- lambda { @object.send(:Float, "20#{e}2.0") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "20#{e}2.0") }.should raise_error(ArgumentError)
end
end
@@ -209,11 +209,11 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError if #{p} is the trailing character" do
- lambda { @object.send(:Float, "0x1#{p}") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "0x1#{p}") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if #{p} is the leading character" do
- lambda { @object.send(:Float, "0x#{p}1") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "0x#{p}1") }.should raise_error(ArgumentError)
end
it "returns Infinity for '0x1#{p}10000'" do
@@ -231,18 +231,18 @@ describe :kernel_float, shared: true do
end
it "raises an exception if a space is embedded on either side of the '#{p}'" do
- lambda { @object.send(:Float, "0x1 0#{p}10") }.should raise_error(ArgumentError)
- lambda { @object.send(:Float, "0x10#{p}1 0") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "0x1 0#{p}10") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "0x10#{p}1 0") }.should raise_error(ArgumentError)
end
it "raises an exception if there's a leading _ on either side of the '#{p}'" do
- lambda { @object.send(:Float, "0x_10#{p}10") }.should raise_error(ArgumentError)
- lambda { @object.send(:Float, "0x10#{p}_10") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "0x_10#{p}10") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "0x10#{p}_10") }.should raise_error(ArgumentError)
end
it "raises an exception if there's a trailing _ on either side of the '#{p}'" do
- lambda { @object.send(:Float, "0x10_#{p}10") }.should raise_error(ArgumentError)
- lambda { @object.send(:Float, "0x10#{p}10_") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "0x10_#{p}10") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "0x10#{p}10_") }.should raise_error(ArgumentError)
end
it "allows hexadecimal points on the left side of the '#{p}'" do
@@ -250,7 +250,7 @@ describe :kernel_float, shared: true do
end
it "raises an ArgumentError if there's a decimal point on the right side of the '#{p}'" do
- lambda { @object.send(:Float, "0x1#{p}1.0") }.should raise_error(ArgumentError)
+ -> { @object.send(:Float, "0x1#{p}1.0") }.should raise_error(ArgumentError)
end
end
end
@@ -282,22 +282,22 @@ describe :kernel_float, shared: true do
end
it "raises a TypeError if #to_f is not provided" do
- lambda { @object.send(:Float, mock('x')) }.should raise_error(TypeError)
+ -> { @object.send(:Float, mock('x')) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_f returns a String" do
(obj = mock('ha!')).should_receive(:to_f).once.and_return('ha!')
- lambda { @object.send(:Float, obj) }.should raise_error(TypeError)
+ -> { @object.send(:Float, obj) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_f returns an Integer" do
(obj = mock('123')).should_receive(:to_f).once.and_return(123)
- lambda { @object.send(:Float, obj) }.should raise_error(TypeError)
+ -> { @object.send(:Float, obj) }.should raise_error(TypeError)
end
it "raises a RangeError when passed a Complex argument" do
c = Complex(2, 3)
- lambda { @object.send(:Float, c) }.should raise_error(RangeError)
+ -> { @object.send(:Float, c) }.should raise_error(RangeError)
end
ruby_version_is "2.6" do
diff --git a/spec/ruby/core/kernel/Hash_spec.rb b/spec/ruby/core/kernel/Hash_spec.rb
index 89e97fb11e..cbe098a8ac 100644
--- a/spec/ruby/core/kernel/Hash_spec.rb
+++ b/spec/ruby/core/kernel/Hash_spec.rb
@@ -43,14 +43,14 @@ describe :kernel_Hash, shared: true do
end
it "raises a TypeError if it doesn't respond to #to_hash" do
- lambda { @object.send(@method, mock("")) }.should raise_error(TypeError)
+ -> { @object.send(@method, mock("")) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_hash does not return an Hash" do
obj = mock("Hash() string")
obj.should_receive(:to_hash).and_return("string")
- lambda { @object.send(@method, obj) }.should raise_error(TypeError)
+ -> { @object.send(@method, obj) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/Integer_spec.rb b/spec/ruby/core/kernel/Integer_spec.rb
index b7e05e701b..59b41d37e6 100644
--- a/spec/ruby/core/kernel/Integer_spec.rb
+++ b/spec/ruby/core/kernel/Integer_spec.rb
@@ -24,7 +24,7 @@ describe :kernel_integer, shared: true do
obj = mock("object")
obj.should_receive(:to_int).and_return("1")
obj.should_receive(:to_i).and_return(nil)
- lambda { Integer(obj) }.should raise_error(TypeError)
+ -> { Integer(obj) }.should raise_error(TypeError)
end
it "return a result of to_i when to_int does not return an Integer" do
@@ -36,7 +36,7 @@ describe :kernel_integer, shared: true do
end
it "raises a TypeError when passed nil" do
- lambda { Integer(nil) }.should raise_error(TypeError)
+ -> { Integer(nil) }.should raise_error(TypeError)
end
it "returns a Fixnum or Bignum object" do
@@ -78,26 +78,26 @@ describe :kernel_integer, shared: true do
it "raises a TypeError if to_i returns a value that is not an Integer" do
obj = mock("object")
obj.should_receive(:to_i).and_return("1")
- lambda { Integer(obj) }.should raise_error(TypeError)
+ -> { Integer(obj) }.should raise_error(TypeError)
end
it "raises a TypeError if no to_int or to_i methods exist" do
obj = mock("object")
- lambda { Integer(obj) }.should raise_error(TypeError)
+ -> { Integer(obj) }.should raise_error(TypeError)
end
it "raises a TypeError if to_int returns nil and no to_i exists" do
obj = mock("object")
obj.should_receive(:to_i).and_return(nil)
- lambda { Integer(obj) }.should raise_error(TypeError)
+ -> { Integer(obj) }.should raise_error(TypeError)
end
it "raises a FloatDomainError when passed NaN" do
- lambda { Integer(nan_value) }.should raise_error(FloatDomainError)
+ -> { Integer(nan_value) }.should raise_error(FloatDomainError)
end
it "raises a FloatDomainError when passed Infinity" do
- lambda { Integer(infinity_value) }.should raise_error(FloatDomainError)
+ -> { Integer(infinity_value) }.should raise_error(FloatDomainError)
end
ruby_version_is "2.6" do
@@ -160,19 +160,19 @@ end
describe "Integer() given a String", shared: true do
it "raises an ArgumentError if the String is a null byte" do
- lambda { Integer("\0") }.should raise_error(ArgumentError)
+ -> { Integer("\0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String starts with a null byte" do
- lambda { Integer("\01") }.should raise_error(ArgumentError)
+ -> { Integer("\01") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String ends with a null byte" do
- lambda { Integer("1\0") }.should raise_error(ArgumentError)
+ -> { Integer("1\0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String contains a null byte" do
- lambda { Integer("1\01") }.should raise_error(ArgumentError)
+ -> { Integer("1\01") }.should raise_error(ArgumentError)
end
it "ignores leading whitespace" do
@@ -188,13 +188,13 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if there are leading _s" do
- lambda { Integer("_1") }.should raise_error(ArgumentError)
- lambda { Integer("___1") }.should raise_error(ArgumentError)
+ -> { Integer("_1") }.should raise_error(ArgumentError)
+ -> { Integer("___1") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing _s" do
- lambda { Integer("1_") }.should raise_error(ArgumentError)
- lambda { Integer("1___") }.should raise_error(ArgumentError)
+ -> { Integer("1_") }.should raise_error(ArgumentError)
+ -> { Integer("1___") }.should raise_error(ArgumentError)
end
it "ignores an embedded _" do
@@ -202,8 +202,8 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if there are multiple embedded _s" do
- lambda { Integer("1__1") }.should raise_error(ArgumentError)
- lambda { Integer("1___1") }.should raise_error(ArgumentError)
+ -> { Integer("1__1") }.should raise_error(ArgumentError)
+ -> { Integer("1___1") }.should raise_error(ArgumentError)
end
it "ignores a single leading +" do
@@ -211,17 +211,17 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if there is a space between the + and number" do
- lambda { Integer("+ 1") }.should raise_error(ArgumentError)
+ -> { Integer("+ 1") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are multiple leading +s" do
- lambda { Integer("++1") }.should raise_error(ArgumentError)
- lambda { Integer("+++1") }.should raise_error(ArgumentError)
+ -> { Integer("++1") }.should raise_error(ArgumentError)
+ -> { Integer("+++1") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing +s" do
- lambda { Integer("1+") }.should raise_error(ArgumentError)
- lambda { Integer("1+++") }.should raise_error(ArgumentError)
+ -> { Integer("1+") }.should raise_error(ArgumentError)
+ -> { Integer("1+++") }.should raise_error(ArgumentError)
end
it "makes the number negative if there's a leading -" do
@@ -229,21 +229,21 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if there are multiple leading -s" do
- lambda { Integer("--1") }.should raise_error(ArgumentError)
- lambda { Integer("---1") }.should raise_error(ArgumentError)
+ -> { Integer("--1") }.should raise_error(ArgumentError)
+ -> { Integer("---1") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing -s" do
- lambda { Integer("1-") }.should raise_error(ArgumentError)
- lambda { Integer("1---") }.should raise_error(ArgumentError)
+ -> { Integer("1-") }.should raise_error(ArgumentError)
+ -> { Integer("1---") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there is a period" do
- lambda { Integer("0.0") }.should raise_error(ArgumentError)
+ -> { Integer("0.0") }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for an empty String" do
- lambda { Integer("") }.should raise_error(ArgumentError)
+ -> { Integer("") }.should raise_error(ArgumentError)
end
ruby_version_is "2.6" do
@@ -295,7 +295,7 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as hex" do
- lambda { Integer("0#{x}g") }.should raise_error(ArgumentError)
+ -> { Integer("0#{x}g") }.should raise_error(ArgumentError)
end
end
@@ -316,7 +316,7 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as binary" do
- lambda { Integer("0#{b}2") }.should raise_error(ArgumentError)
+ -> { Integer("0#{b}2") }.should raise_error(ArgumentError)
end
end
@@ -337,7 +337,7 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as octal" do
- lambda { Integer("0#{o}9") }.should raise_error(ArgumentError)
+ -> { Integer("0#{o}9") }.should raise_error(ArgumentError)
end
end
@@ -358,26 +358,26 @@ describe "Integer() given a String", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as decimal" do
- lambda { Integer("0#{d}a") }.should raise_error(ArgumentError)
+ -> { Integer("0#{d}a") }.should raise_error(ArgumentError)
end
end
end
describe "Integer() given a String and base", shared: true do
it "raises an ArgumentError if the String is a null byte" do
- lambda { Integer("\0", 2) }.should raise_error(ArgumentError)
+ -> { Integer("\0", 2) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String starts with a null byte" do
- lambda { Integer("\01", 3) }.should raise_error(ArgumentError)
+ -> { Integer("\01", 3) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String ends with a null byte" do
- lambda { Integer("1\0", 4) }.should raise_error(ArgumentError)
+ -> { Integer("1\0", 4) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the String contains a null byte" do
- lambda { Integer("1\01", 5) }.should raise_error(ArgumentError)
+ -> { Integer("1\01", 5) }.should raise_error(ArgumentError)
end
it "ignores leading whitespace" do
@@ -393,13 +393,13 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if there are leading _s" do
- lambda { Integer("_1", 7) }.should raise_error(ArgumentError)
- lambda { Integer("___1", 7) }.should raise_error(ArgumentError)
+ -> { Integer("_1", 7) }.should raise_error(ArgumentError)
+ -> { Integer("___1", 7) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing _s" do
- lambda { Integer("1_", 12) }.should raise_error(ArgumentError)
- lambda { Integer("1___", 12) }.should raise_error(ArgumentError)
+ -> { Integer("1_", 12) }.should raise_error(ArgumentError)
+ -> { Integer("1___", 12) }.should raise_error(ArgumentError)
end
it "ignores an embedded _" do
@@ -407,8 +407,8 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if there are multiple embedded _s" do
- lambda { Integer("1__1", 4) }.should raise_error(ArgumentError)
- lambda { Integer("1___1", 4) }.should raise_error(ArgumentError)
+ -> { Integer("1__1", 4) }.should raise_error(ArgumentError)
+ -> { Integer("1___1", 4) }.should raise_error(ArgumentError)
end
it "ignores a single leading +" do
@@ -416,17 +416,17 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if there is a space between the + and number" do
- lambda { Integer("+ 1", 3) }.should raise_error(ArgumentError)
+ -> { Integer("+ 1", 3) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are multiple leading +s" do
- lambda { Integer("++1", 3) }.should raise_error(ArgumentError)
- lambda { Integer("+++1", 3) }.should raise_error(ArgumentError)
+ -> { Integer("++1", 3) }.should raise_error(ArgumentError)
+ -> { Integer("+++1", 3) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing +s" do
- lambda { Integer("1+", 3) }.should raise_error(ArgumentError)
- lambda { Integer("1+++", 12) }.should raise_error(ArgumentError)
+ -> { Integer("1+", 3) }.should raise_error(ArgumentError)
+ -> { Integer("1+++", 12) }.should raise_error(ArgumentError)
end
it "makes the number negative if there's a leading -" do
@@ -434,29 +434,29 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if there are multiple leading -s" do
- lambda { Integer("--1", 9) }.should raise_error(ArgumentError)
- lambda { Integer("---1", 9) }.should raise_error(ArgumentError)
+ -> { Integer("--1", 9) }.should raise_error(ArgumentError)
+ -> { Integer("---1", 9) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there are trailing -s" do
- lambda { Integer("1-", 12) }.should raise_error(ArgumentError)
- lambda { Integer("1---", 12) }.should raise_error(ArgumentError)
+ -> { Integer("1-", 12) }.should raise_error(ArgumentError)
+ -> { Integer("1---", 12) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if there is a period" do
- lambda { Integer("0.0", 3) }.should raise_error(ArgumentError)
+ -> { Integer("0.0", 3) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for an empty String" do
- lambda { Integer("", 12) }.should raise_error(ArgumentError)
+ -> { Integer("", 12) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a base of 1" do
- lambda { Integer("1", 1) }.should raise_error(ArgumentError)
+ -> { Integer("1", 1) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError for a base of 37" do
- lambda { Integer("1", 37) }.should raise_error(ArgumentError)
+ -> { Integer("1", 37) }.should raise_error(ArgumentError)
end
it "accepts wholly lowercase alphabetic strings for bases > 10" do
@@ -484,8 +484,8 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError for letters invalid in the given base" do
- lambda { Integer('z',19) }.should raise_error(ArgumentError)
- lambda { Integer('c00o',2) }.should raise_error(ArgumentError)
+ -> { Integer('z',19) }.should raise_error(ArgumentError)
+ -> { Integer('c00o',2) }.should raise_error(ArgumentError)
end
%w(x X).each do |x|
@@ -506,12 +506,12 @@ describe "Integer() given a String and base", shared: true do
2.upto(15) do |base|
it "raises an ArgumentError if the number begins with 0#{x} and the base is #{base}" do
- lambda { Integer("0#{x}1", base) }.should raise_error(ArgumentError)
+ -> { Integer("0#{x}1", base) }.should raise_error(ArgumentError)
end
end
it "raises an ArgumentError if the number cannot be parsed as hex and the base is 16" do
- lambda { Integer("0#{x}g", 16) }.should raise_error(ArgumentError)
+ -> { Integer("0#{x}g", 16) }.should raise_error(ArgumentError)
end
end
@@ -532,7 +532,7 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as binary and the base is 2" do
- lambda { Integer("0#{b}2", 2) }.should raise_error(ArgumentError)
+ -> { Integer("0#{b}2", 2) }.should raise_error(ArgumentError)
end
end
@@ -553,12 +553,12 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as octal and the base is 8" do
- lambda { Integer("0#{o}9", 8) }.should raise_error(ArgumentError)
+ -> { Integer("0#{o}9", 8) }.should raise_error(ArgumentError)
end
2.upto(7) do |base|
it "raises an ArgumentError if the number begins with 0#{o} and the base is #{base}" do
- lambda { Integer("0#{o}1", base) }.should raise_error(ArgumentError)
+ -> { Integer("0#{o}1", base) }.should raise_error(ArgumentError)
end
end
end
@@ -580,17 +580,17 @@ describe "Integer() given a String and base", shared: true do
end
it "raises an ArgumentError if the number cannot be parsed as decimal and the base is 10" do
- lambda { Integer("0#{d}a", 10) }.should raise_error(ArgumentError)
+ -> { Integer("0#{d}a", 10) }.should raise_error(ArgumentError)
end
2.upto(9) do |base|
it "raises an ArgumentError if the number begins with 0#{d} and the base is #{base}" do
- lambda { Integer("0#{d}1", base) }.should raise_error(ArgumentError)
+ -> { Integer("0#{d}1", base) }.should raise_error(ArgumentError)
end
end
it "raises an ArgumentError if a base is given for a non-String value" do
- lambda { Integer(98, 15) }.should raise_error(ArgumentError)
+ -> { Integer(98, 15) }.should raise_error(ArgumentError)
end
end
@@ -616,176 +616,176 @@ end
describe :kernel_Integer, shared: true do
it "raises an ArgumentError when the String contains digits out of range of radix 2" do
str = "23456789abcdefghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 2) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 2) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 3" do
str = "3456789abcdefghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 3) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 3) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 4" do
str = "456789abcdefghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 4) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 4) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 5" do
str = "56789abcdefghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 5) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 5) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 6" do
str = "6789abcdefghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 6) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 6) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 7" do
str = "789abcdefghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 7) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 7) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 8" do
str = "89abcdefghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 8) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 8) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 9" do
str = "9abcdefghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 9) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 9) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 10" do
str = "abcdefghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 10) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 10) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 11" do
str = "bcdefghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 11) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 11) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 12" do
str = "cdefghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 12) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 12) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 13" do
str = "defghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 13) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 13) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 14" do
str = "efghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 14) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 14) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 15" do
str = "fghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 15) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 15) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 16" do
str = "ghijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 16) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 16) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 17" do
str = "hijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 17) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 17) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 18" do
str = "ijklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 18) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 18) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 19" do
str = "jklmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 19) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 19) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 20" do
str = "klmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 20) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 20) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 21" do
str = "lmnopqrstuvwxyz"
- lambda { @object.send(@method, str, 21) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 21) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 22" do
str = "mnopqrstuvwxyz"
- lambda { @object.send(@method, str, 22) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 22) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 23" do
str = "nopqrstuvwxyz"
- lambda { @object.send(@method, str, 23) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 23) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 24" do
str = "opqrstuvwxyz"
- lambda { @object.send(@method, str, 24) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 24) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 25" do
str = "pqrstuvwxyz"
- lambda { @object.send(@method, str, 25) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 25) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 26" do
str = "qrstuvwxyz"
- lambda { @object.send(@method, str, 26) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 26) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 27" do
str = "rstuvwxyz"
- lambda { @object.send(@method, str, 27) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 27) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 28" do
str = "stuvwxyz"
- lambda { @object.send(@method, str, 28) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 28) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 29" do
str = "tuvwxyz"
- lambda { @object.send(@method, str, 29) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 29) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 30" do
str = "uvwxyz"
- lambda { @object.send(@method, str, 30) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 30) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 31" do
str = "vwxyz"
- lambda { @object.send(@method, str, 31) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 31) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 32" do
str = "wxyz"
- lambda { @object.send(@method, str, 32) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 32) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 33" do
str = "xyz"
- lambda { @object.send(@method, str, 33) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 33) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 34" do
str = "yz"
- lambda { @object.send(@method, str, 34) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 34) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 35" do
str = "z"
- lambda { @object.send(@method, str, 35) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, str, 35) }.should raise_error(ArgumentError)
end
it "raises an ArgumentError when the String contains digits out of range of radix 36" do
- lambda { @object.send(@method, "{", 36) }.should raise_error(ArgumentError)
+ -> { @object.send(@method, "{", 36) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/kernel/String_spec.rb b/spec/ruby/core/kernel/String_spec.rb
index 81489875c8..47ee797be5 100644
--- a/spec/ruby/core/kernel/String_spec.rb
+++ b/spec/ruby/core/kernel/String_spec.rb
@@ -32,7 +32,7 @@ describe :kernel_String, shared: true do
undef_method :to_s
end
- lambda { @object.send(@method, obj) }.should raise_error(TypeError)
+ -> { @object.send(@method, obj) }.should raise_error(TypeError)
end
# #5158
@@ -44,7 +44,7 @@ describe :kernel_String, shared: true do
end
end
- lambda { @object.send(@method, obj) }.should raise_error(TypeError)
+ -> { @object.send(@method, obj) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_s is not defined, even though #respond_to?(:to_s) returns true" do
@@ -57,7 +57,7 @@ describe :kernel_String, shared: true do
end
end
- lambda { @object.send(@method, obj) }.should raise_error(TypeError)
+ -> { @object.send(@method, obj) }.should raise_error(TypeError)
end
it "calls #to_s if #respond_to?(:to_s) returns true" do
@@ -74,7 +74,7 @@ describe :kernel_String, shared: true do
it "raises a TypeError if #to_s does not return a String" do
(obj = mock('123')).should_receive(:to_s).and_return(123)
- lambda { @object.send(@method, obj) }.should raise_error(TypeError)
+ -> { @object.send(@method, obj) }.should raise_error(TypeError)
end
it "returns the same object if it is already a String" do
diff --git a/spec/ruby/core/kernel/backtick_spec.rb b/spec/ruby/core/kernel/backtick_spec.rb
index dcba218f61..5ab0fb0eea 100644
--- a/spec/ruby/core/kernel/backtick_spec.rb
+++ b/spec/ruby/core/kernel/backtick_spec.rb
@@ -21,7 +21,7 @@ describe "Kernel#`" do
it "lets the standard error stream pass through to the inherited stderr" do
cmd = ruby_cmd('STDERR.print "error stream"')
- lambda {
+ -> {
`#{cmd}`.should == ""
}.should output_to_fd("error stream", STDERR)
end
@@ -32,7 +32,7 @@ describe "Kernel#`" do
end
it "raises an Errno::ENOENT if the command is not executable" do
- lambda { `nonexistent_command` }.should raise_error(Errno::ENOENT)
+ -> { `nonexistent_command` }.should raise_error(Errno::ENOENT)
end
platform_is_not :windows do
diff --git a/spec/ruby/core/kernel/binding_spec.rb b/spec/ruby/core/kernel/binding_spec.rb
index e9fca6e3ab..f1c9c6ec9f 100644
--- a/spec/ruby/core/kernel/binding_spec.rb
+++ b/spec/ruby/core/kernel/binding_spec.rb
@@ -35,7 +35,7 @@ describe "Kernel#binding" do
end
it "raises a NameError on undefined variable" do
- lambda { eval("a_fake_variable", @b1) }.should raise_error(NameError)
+ -> { eval("a_fake_variable", @b1) }.should raise_error(NameError)
end
it "uses the closure's self as self in the binding" do
diff --git a/spec/ruby/core/kernel/catch_spec.rb b/spec/ruby/core/kernel/catch_spec.rb
index 092fb4968a..4060172429 100644
--- a/spec/ruby/core/kernel/catch_spec.rb
+++ b/spec/ruby/core/kernel/catch_spec.rb
@@ -31,11 +31,11 @@ describe "Kernel.catch" do
end
it "raises an ArgumentError if a Symbol is thrown for a String catch value" do
- lambda { catch("exit") { throw :exit } }.should raise_error(ArgumentError)
+ -> { catch("exit") { throw :exit } }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if a String with different identity is thrown" do
- lambda { catch("exit") { throw "exit" } }.should raise_error(ArgumentError)
+ -> { catch("exit") { throw "exit" } }.should raise_error(ArgumentError)
end
it "catches a Symbol when thrown a matching Symbol" do
@@ -116,7 +116,7 @@ describe "Kernel.catch" do
end
it "raises LocalJumpError if no block is given" do
- lambda { catch :blah }.should raise_error(LocalJumpError)
+ -> { catch :blah }.should raise_error(LocalJumpError)
end
end
diff --git a/spec/ruby/core/kernel/define_singleton_method_spec.rb b/spec/ruby/core/kernel/define_singleton_method_spec.rb
index c2f2da7c79..dc77c3e6f8 100644
--- a/spec/ruby/core/kernel/define_singleton_method_spec.rb
+++ b/spec/ruby/core/kernel/define_singleton_method_spec.rb
@@ -21,7 +21,7 @@ describe "Kernel#define_singleton_method" do
um = KernelSpecs::Parent.method(:parent_class_method).unbind
KernelSpecs::Child.send :define_singleton_method, :child_class_method, um
KernelSpecs::Child.child_class_method.should == :foo
- lambda{KernelSpecs::Parent.child_class_method}.should raise_error(NoMethodError)
+ ->{KernelSpecs::Parent.child_class_method}.should raise_error(NoMethodError)
end
it "will raise when attempting to define an object's singleton method from another object's singleton method" do
@@ -33,7 +33,7 @@ describe "Kernel#define_singleton_method" do
end
end
um = p.method(:singleton_method).unbind
- lambda{ other.send :define_singleton_method, :other_singleton_method, um }.should raise_error(TypeError)
+ ->{ other.send :define_singleton_method, :other_singleton_method, um }.should raise_error(TypeError)
end
end
@@ -41,7 +41,7 @@ describe "Kernel#define_singleton_method" do
it "defines a new method with the given name and the given block as body in self" do
class DefineSingletonMethodSpecClass
define_singleton_method(:block_test1) { self }
- define_singleton_method(:block_test2, &lambda { self })
+ define_singleton_method(:block_test2, &-> { self })
end
o = DefineSingletonMethodSpecClass
@@ -50,11 +50,11 @@ describe "Kernel#define_singleton_method" do
end
it "raises a TypeError when the given method is no Method/Proc" do
- lambda {
+ -> {
Class.new { define_singleton_method(:test, "self") }
}.should raise_error(TypeError)
- lambda {
+ -> {
Class.new { define_singleton_method(:test, 1234) }
}.should raise_error(TypeError)
end
@@ -63,7 +63,7 @@ describe "Kernel#define_singleton_method" do
obj = Object.new
obj.define_singleton_method(:test) { "world!" }
obj.test.should == "world!"
- lambda {
+ -> {
Object.new.test
}.should raise_error(NoMethodError)
end
@@ -81,7 +81,7 @@ describe "Kernel#define_singleton_method" do
it "raises an ArgumentError when no block is given" do
obj = Object.new
- lambda {
+ -> {
obj.define_singleton_method(:test)
}.should raise_error(ArgumentError)
end
@@ -92,7 +92,7 @@ describe "Kernel#define_singleton_method" do
define_singleton_method(name)
end
- lambda {
+ -> {
o.define(:foo) { raise "not used" }
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/kernel/dup_spec.rb b/spec/ruby/core/kernel/dup_spec.rb
index ce81f7018a..fe0a269d69 100644
--- a/spec/ruby/core/kernel/dup_spec.rb
+++ b/spec/ruby/core/kernel/dup_spec.rb
@@ -44,7 +44,7 @@ describe "Kernel#dup" do
it "does not copy singleton methods" do
def @obj.special() :the_one end
dup = @obj.dup
- lambda { dup.special }.should raise_error(NameError)
+ -> { dup.special }.should raise_error(NameError)
end
it "does not copy modules included in the singleton class" do
@@ -53,7 +53,7 @@ describe "Kernel#dup" do
end
dup = @obj.dup
- lambda { dup.repr }.should raise_error(NameError)
+ -> { dup.repr }.should raise_error(NameError)
end
it "does not copy constants defined in the singleton class" do
@@ -62,6 +62,6 @@ describe "Kernel#dup" do
end
dup = @obj.dup
- lambda { class << dup; CLONE; end }.should raise_error(NameError)
+ -> { class << dup; CLONE; end }.should raise_error(NameError)
end
end
diff --git a/spec/ruby/core/kernel/eval_spec.rb b/spec/ruby/core/kernel/eval_spec.rb
index 696c55a3ba..9442725eac 100644
--- a/spec/ruby/core/kernel/eval_spec.rb
+++ b/spec/ruby/core/kernel/eval_spec.rb
@@ -76,12 +76,12 @@ describe "Kernel#eval" do
x = 1
bind = proc {}
- lambda { eval("x", bind) }.should raise_error(TypeError)
+ -> { eval("x", bind) }.should raise_error(TypeError)
end
it "does not make Proc locals visible to evaluated code" do
bind = proc { inner = 4 }
- lambda { eval("inner", bind.binding) }.should raise_error(NameError)
+ -> { eval("inner", bind.binding) }.should raise_error(NameError)
end
# REWRITE ME: This obscures the real behavior of where locals are stored
@@ -134,7 +134,7 @@ describe "Kernel#eval" do
it "includes file and line information in syntax error" do
expected = 'speccing.rb'
- lambda {
+ -> {
eval('if true',TOPLEVEL_BINDING, expected)
}.should raise_error(SyntaxError) { |e|
e.message.should =~ /#{expected}:1:.+/
@@ -143,7 +143,7 @@ describe "Kernel#eval" do
it "evaluates string with given filename and negative linenumber" do
expected_file = 'speccing.rb'
- lambda {
+ -> {
eval('if true',TOPLEVEL_BINDING, expected_file, -100)
}.should raise_error(SyntaxError) { |e|
e.message.should =~ /#{expected_file}:-100:.+/
@@ -195,13 +195,13 @@ describe "Kernel#eval" do
end
it "does not pass the block to the method being eval'ed" do
- lambda {
+ -> {
eval('KernelSpecs::EvalTest.call_yield') { "content" }
}.should raise_error(LocalJumpError)
end
it "returns from the scope calling #eval when evaluating 'return'" do
- lambda { eval("return :eval") }.call.should == :eval
+ -> { eval("return :eval") }.call.should == :eval
end
it "unwinds through a Proc-style closure and returns from a lambda-style closure in the closure chain" do
diff --git a/spec/ruby/core/kernel/extend_spec.rb b/spec/ruby/core/kernel/extend_spec.rb
index f4f9dde098..9f98b3681f 100644
--- a/spec/ruby/core/kernel/extend_spec.rb
+++ b/spec/ruby/core/kernel/extend_spec.rb
@@ -53,13 +53,13 @@ describe "Kernel#extend" do
end
it "raises an ArgumentError when no arguments given" do
- lambda { Object.new.extend }.should raise_error(ArgumentError)
+ -> { Object.new.extend }.should raise_error(ArgumentError)
end
it "raises a TypeError when the argument is not a Module" do
o = mock('o')
klass = Class.new
- lambda { o.extend(klass) }.should raise_error(TypeError)
+ -> { o.extend(klass) }.should raise_error(TypeError)
end
describe "on frozen instance" do
@@ -69,11 +69,11 @@ describe "Kernel#extend" do
end
it "raises an ArgumentError when no arguments given" do
- lambda { @frozen.extend }.should raise_error(ArgumentError)
+ -> { @frozen.extend }.should raise_error(ArgumentError)
end
it "raises a #{frozen_error_class}" do
- lambda { @frozen.extend @module }.should raise_error(frozen_error_class)
+ -> { @frozen.extend @module }.should raise_error(frozen_error_class)
end
end
end
diff --git a/spec/ruby/core/kernel/fail_spec.rb b/spec/ruby/core/kernel/fail_spec.rb
index a5948cefae..fab622037e 100644
--- a/spec/ruby/core/kernel/fail_spec.rb
+++ b/spec/ruby/core/kernel/fail_spec.rb
@@ -7,7 +7,7 @@ describe "Kernel#fail" do
end
it "raises a RuntimeError" do
- lambda { fail }.should raise_error(RuntimeError)
+ -> { fail }.should raise_error(RuntimeError)
end
it "accepts an Object with an exception method returning an Exception" do
@@ -15,16 +15,16 @@ describe "Kernel#fail" do
def obj.exception(msg)
StandardError.new msg
end
- lambda { fail obj, "..." }.should raise_error(StandardError, "...")
+ -> { fail obj, "..." }.should raise_error(StandardError, "...")
end
it "instantiates the specified exception class" do
error_class = Class.new(RuntimeError)
- lambda { fail error_class }.should raise_error(error_class)
+ -> { fail error_class }.should raise_error(error_class)
end
it "uses the specified message" do
- lambda {
+ -> {
begin
fail "the duck is not irish."
rescue => e
diff --git a/spec/ruby/core/kernel/fixtures/classes.rb b/spec/ruby/core/kernel/fixtures/classes.rb
index 1f45bbb083..2909a621a9 100644
--- a/spec/ruby/core/kernel/fixtures/classes.rb
+++ b/spec/ruby/core/kernel/fixtures/classes.rb
@@ -328,7 +328,7 @@ module KernelSpecs
def inner
b = mp { return :good }
- pr = lambda { |x| x.call }
+ pr = -> x { x.call }
pr.call(b)
@@ -424,6 +424,20 @@ module KernelSpecs
def f2_call_lineno; method(:f3).source_location[1] + 1; end
def f3_call_lineno; method(:f4).source_location[1] + 1; end
end
+
+ CustomRangeInteger = Struct.new(:value) do
+ def to_int; value; end
+ def <=>(other); to_int <=> other.to_int; end
+ def -(other); self.class.new(to_int - other.to_int); end
+ def +(other); self.class.new(to_int + other.to_int); end
+ end
+
+ CustomRangeFloat = Struct.new(:value) do
+ def to_f; value; end
+ def <=>(other); to_f <=> other.to_f; end
+ def -(other); to_f - other.to_f; end
+ def +(other); self.class.new(to_f + other.to_f); end
+ end
end
class EvalSpecs
@@ -454,12 +468,3 @@ class EvalSpecs
return f
end
end
-
-# for Kernel#sleep to have Channel in it's specs
-# TODO: switch directly to queue for both Kernel#sleep and Thread specs?
-unless defined? Channel
- require 'thread'
- class Channel < Queue
- alias receive shift
- end
-end
diff --git a/spec/ruby/core/kernel/fixtures/eval_return_with_lambda.rb b/spec/ruby/core/kernel/fixtures/eval_return_with_lambda.rb
index a48b5685f3..9e2d045bf3 100644
--- a/spec/ruby/core/kernel/fixtures/eval_return_with_lambda.rb
+++ b/spec/ruby/core/kernel/fixtures/eval_return_with_lambda.rb
@@ -1,5 +1,5 @@
print "a,"
-x = lambda do
+x = -> do
print "b,"
Proc.new do
print "c,"
diff --git a/spec/ruby/core/kernel/freeze_spec.rb b/spec/ruby/core/kernel/freeze_spec.rb
index 018784a4f5..214b619f9f 100644
--- a/spec/ruby/core/kernel/freeze_spec.rb
+++ b/spec/ruby/core/kernel/freeze_spec.rb
@@ -74,12 +74,12 @@ describe "Kernel#freeze" do
def mutate; @foo = 1; end
end.new
o.freeze
- lambda {o.mutate}.should raise_error(RuntimeError)
+ -> {o.mutate}.should raise_error(RuntimeError)
end
it "causes instance_variable_set to raise RuntimeError" do
o = Object.new
o.freeze
- lambda {o.instance_variable_set(:@foo, 1)}.should raise_error(RuntimeError)
+ -> {o.instance_variable_set(:@foo, 1)}.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/kernel/gsub_spec.rb b/spec/ruby/core/kernel/gsub_spec.rb
index 2bcb29f60e..a0cb9f2a70 100644
--- a/spec/ruby/core/kernel/gsub_spec.rb
+++ b/spec/ruby/core/kernel/gsub_spec.rb
@@ -10,7 +10,7 @@ ruby_version_is ""..."1.9" do
end
it "raises a TypeError if $_ is not a String" do
- lambda {
+ -> {
$_ = 123
gsub(/./, "!")
}.should raise_error(TypeError)
diff --git a/spec/ruby/core/kernel/instance_of_spec.rb b/spec/ruby/core/kernel/instance_of_spec.rb
index 78cddb443f..40e856b0d9 100644
--- a/spec/ruby/core/kernel/instance_of_spec.rb
+++ b/spec/ruby/core/kernel/instance_of_spec.rb
@@ -33,8 +33,8 @@ describe Kernel, "#instance_of?" do
end
it "raises a TypeError if given an object that is not a Class nor a Module" do
- lambda { @o.instance_of?(Object.new) }.should raise_error(TypeError)
- lambda { @o.instance_of?('KernelSpecs::InstanceClass') }.should raise_error(TypeError)
- lambda { @o.instance_of?(1) }.should raise_error(TypeError)
+ -> { @o.instance_of?(Object.new) }.should raise_error(TypeError)
+ -> { @o.instance_of?('KernelSpecs::InstanceClass') }.should raise_error(TypeError)
+ -> { @o.instance_of?(1) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/instance_variable_defined_spec.rb b/spec/ruby/core/kernel/instance_variable_defined_spec.rb
index 99f5e90b4d..2ebb582b43 100644
--- a/spec/ruby/core/kernel/instance_variable_defined_spec.rb
+++ b/spec/ruby/core/kernel/instance_variable_defined_spec.rb
@@ -27,7 +27,7 @@ describe "Kernel#instance_variable_defined?" do
end
it "raises a TypeError if passed an Object not defining #to_str" do
- lambda do
+ -> do
obj = mock("kernel instance_variable_defined?")
@instance.instance_variable_defined? obj
end.should raise_error(TypeError)
diff --git a/spec/ruby/core/kernel/instance_variable_get_spec.rb b/spec/ruby/core/kernel/instance_variable_get_spec.rb
index 918abd8f5c..84d3188f07 100644
--- a/spec/ruby/core/kernel/instance_variable_get_spec.rb
+++ b/spec/ruby/core/kernel/instance_variable_get_spec.rb
@@ -24,25 +24,25 @@ describe "Kernel#instance_variable_get" do
end
it "raises a TypeError when the passed argument does not respond to #to_str" do
- lambda { @obj.instance_variable_get(Object.new) }.should raise_error(TypeError)
+ -> { @obj.instance_variable_get(Object.new) }.should raise_error(TypeError)
end
it "raises a TypeError when the passed argument can't be converted to a String" do
obj = mock("to_str")
obj.stub!(:to_str).and_return(123)
- lambda { @obj.instance_variable_get(obj) }.should raise_error(TypeError)
+ -> { @obj.instance_variable_get(obj) }.should raise_error(TypeError)
end
it "raises a NameError when the conversion result does not start with an '@'" do
obj = mock("to_str")
obj.stub!(:to_str).and_return("test")
- lambda { @obj.instance_variable_get(obj) }.should raise_error(NameError)
+ -> { @obj.instance_variable_get(obj) }.should raise_error(NameError)
end
it "raises a NameError when passed just '@'" do
obj = mock("to_str")
obj.stub!(:to_str).and_return('@')
- lambda { @obj.instance_variable_get(obj) }.should raise_error(NameError)
+ -> { @obj.instance_variable_get(obj) }.should raise_error(NameError)
end
end
@@ -57,15 +57,15 @@ describe "Kernel#instance_variable_get when passed Symbol" do
end
it "raises a NameError when passed :@ as an instance variable name" do
- lambda { @obj.instance_variable_get(:"@") }.should raise_error(NameError)
+ -> { @obj.instance_variable_get(:"@") }.should raise_error(NameError)
end
it "raises a NameError when the passed Symbol does not start with an '@'" do
- lambda { @obj.instance_variable_get(:test) }.should raise_error(NameError)
+ -> { @obj.instance_variable_get(:test) }.should raise_error(NameError)
end
it "raises a NameError when the passed Symbol is an invalid instance variable name" do
- lambda { @obj.instance_variable_get(:"@0") }.should raise_error(NameError)
+ -> { @obj.instance_variable_get(:"@0") }.should raise_error(NameError)
end
end
@@ -80,15 +80,15 @@ describe "Kernel#instance_variable_get when passed String" do
end
it "raises a NameError when the passed String does not start with an '@'" do
- lambda { @obj.instance_variable_get("test") }.should raise_error(NameError)
+ -> { @obj.instance_variable_get("test") }.should raise_error(NameError)
end
it "raises a NameError when the passed String is an invalid instance variable name" do
- lambda { @obj.instance_variable_get("@0") }.should raise_error(NameError)
+ -> { @obj.instance_variable_get("@0") }.should raise_error(NameError)
end
it "raises a NameError when passed '@' as an instance variable name" do
- lambda { @obj.instance_variable_get("@") }.should raise_error(NameError)
+ -> { @obj.instance_variable_get("@") }.should raise_error(NameError)
end
end
@@ -99,7 +99,7 @@ describe "Kernel#instance_variable_get when passed Fixnum" do
end
it "raises a TypeError" do
- lambda { @obj.instance_variable_get(10) }.should raise_error(TypeError)
- lambda { @obj.instance_variable_get(-10) }.should raise_error(TypeError)
+ -> { @obj.instance_variable_get(10) }.should raise_error(TypeError)
+ -> { @obj.instance_variable_get(-10) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/instance_variable_set_spec.rb b/spec/ruby/core/kernel/instance_variable_set_spec.rb
index 6d84015f50..c5a4085530 100644
--- a/spec/ruby/core/kernel/instance_variable_set_spec.rb
+++ b/spec/ruby/core/kernel/instance_variable_set_spec.rb
@@ -18,26 +18,26 @@ describe "Kernel#instance_variable_set" do
it "raises a NameError exception if the argument is not of form '@x'" do
no_dog = Class.new
- lambda { no_dog.new.instance_variable_set(:c, "cat") }.should raise_error(NameError)
+ -> { no_dog.new.instance_variable_set(:c, "cat") }.should raise_error(NameError)
end
it "raises a NameError exception if the argument is an invalid instance variable name" do
digit_dog = Class.new
- lambda { digit_dog.new.instance_variable_set(:"@0", "cat") }.should raise_error(NameError)
+ -> { digit_dog.new.instance_variable_set(:"@0", "cat") }.should raise_error(NameError)
end
it "raises a NameError when the argument is '@'" do
dog_at = Class.new
- lambda { dog_at.new.instance_variable_set(:"@", "cat") }.should raise_error(NameError)
+ -> { dog_at.new.instance_variable_set(:"@", "cat") }.should raise_error(NameError)
end
it "raises a TypeError if the instance variable name is a Fixnum" do
- lambda { "".instance_variable_set(1, 2) }.should raise_error(TypeError)
+ -> { "".instance_variable_set(1, 2) }.should raise_error(TypeError)
end
it "raises a TypeError if the instance variable name is an object that does not respond to to_str" do
class KernelSpecs::A; end
- lambda { "".instance_variable_set(KernelSpecs::A.new, 3) }.should raise_error(TypeError)
+ -> { "".instance_variable_set(KernelSpecs::A.new, 3) }.should raise_error(TypeError)
end
it "raises a NameError if the passed object, when coerced with to_str, does not start with @" do
@@ -46,11 +46,11 @@ describe "Kernel#instance_variable_set" do
":c"
end
end
- lambda { "".instance_variable_set(KernelSpecs::B.new, 4) }.should raise_error(NameError)
+ -> { "".instance_variable_set(KernelSpecs::B.new, 4) }.should raise_error(NameError)
end
it "raises a NameError if pass an object that cannot be a symbol" do
- lambda { "".instance_variable_set(:c, 1) }.should raise_error(NameError)
+ -> { "".instance_variable_set(:c, 1) }.should raise_error(NameError)
end
it "accepts as instance variable name any instance of a class that responds to to_str" do
@@ -78,16 +78,16 @@ describe "Kernel#instance_variable_set" do
end
it "keeps stored object after any exceptions" do
- lambda { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(Exception)
+ -> { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(Exception)
@frozen.ivar.should equal(:origin)
end
it "raises a #{frozen_error_class} when passed replacement is identical to stored object" do
- lambda { @frozen.instance_variable_set(:@ivar, :origin) }.should raise_error(frozen_error_class)
+ -> { @frozen.instance_variable_set(:@ivar, :origin) }.should raise_error(frozen_error_class)
end
it "raises a #{frozen_error_class} when passed replacement is different from stored object" do
- lambda { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(frozen_error_class)
+ -> { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(frozen_error_class)
end
end
end
diff --git a/spec/ruby/core/kernel/instance_variables_spec.rb b/spec/ruby/core/kernel/instance_variables_spec.rb
index bf17b88c2f..b6d6e27772 100644
--- a/spec/ruby/core/kernel/instance_variables_spec.rb
+++ b/spec/ruby/core/kernel/instance_variables_spec.rb
@@ -9,7 +9,7 @@ describe "Kernel#instance_variables" do
it "returns the correct array if an instance variable is added" do
a = 0
- lambda{ a.instance_variable_set("@test", 1) }.should raise_error(RuntimeError)
+ ->{ a.instance_variable_set("@test", 1) }.should raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/kernel/loop_spec.rb b/spec/ruby/core/kernel/loop_spec.rb
index 3386326a13..7c76c7d28e 100644
--- a/spec/ruby/core/kernel/loop_spec.rb
+++ b/spec/ruby/core/kernel/loop_spec.rb
@@ -55,7 +55,7 @@ describe "Kernel.loop" do
end
it "does not rescue other errors" do
- lambda{ loop do raise StandardError end }.should raise_error( StandardError )
+ ->{ loop do raise StandardError end }.should raise_error( StandardError )
end
it "returns StopIteration#result, the result value of a finished iterator" do
diff --git a/spec/ruby/core/kernel/open_spec.rb b/spec/ruby/core/kernel/open_spec.rb
index 3a9f5ea2d5..981b5291b3 100644
--- a/spec/ruby/core/kernel/open_spec.rb
+++ b/spec/ruby/core/kernel/open_spec.rb
@@ -70,7 +70,7 @@ describe "Kernel#open" do
end
it "raises an ArgumentError if not passed one argument" do
- lambda { open }.should raise_error(ArgumentError)
+ -> { open }.should raise_error(ArgumentError)
end
describe "when given an object that responds to to_open" do
@@ -129,9 +129,9 @@ describe "Kernel#open" do
it "raises a TypeError if passed a non-String that does not respond to #to_open" do
obj = mock('non-fileish')
- lambda { open(obj) }.should raise_error(TypeError)
- lambda { open(nil) }.should raise_error(TypeError)
- lambda { open(7) }.should raise_error(TypeError)
+ -> { open(obj) }.should raise_error(TypeError)
+ -> { open(nil) }.should raise_error(TypeError)
+ -> { open(7) }.should raise_error(TypeError)
end
it "accepts nil for mode and permission" do
diff --git a/spec/ruby/core/kernel/p_spec.rb b/spec/ruby/core/kernel/p_spec.rb
index 1221465243..798bd47b34 100644
--- a/spec/ruby/core/kernel/p_spec.rb
+++ b/spec/ruby/core/kernel/p_spec.rb
@@ -42,10 +42,10 @@ describe "Kernel#p" do
o = mock("Inspector Gadget")
o.should_receive(:inspect).any_number_of_times.and_return "Next time, Gadget, NEXT TIME!"
- lambda { p(o) }.should output("Next time, Gadget, NEXT TIME!\n")
- lambda { p(*[o]) }.should output("Next time, Gadget, NEXT TIME!\n")
- lambda { p(*[o, o]) }.should output("Next time, Gadget, NEXT TIME!\nNext time, Gadget, NEXT TIME!\n")
- lambda { p([o])}.should output("[#{o.inspect}]\n")
+ -> { p(o) }.should output("Next time, Gadget, NEXT TIME!\n")
+ -> { p(*[o]) }.should output("Next time, Gadget, NEXT TIME!\n")
+ -> { p(*[o, o]) }.should output("Next time, Gadget, NEXT TIME!\nNext time, Gadget, NEXT TIME!\n")
+ -> { p([o])}.should output("[#{o.inspect}]\n")
end
it "is not affected by setting $\\, $/ or $," do
@@ -55,21 +55,21 @@ describe "Kernel#p" do
suppress_warning {
$, = " *helicopter sound*\n"
}
- lambda { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
+ -> { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
$\ = " *helicopter sound*\n"
- lambda { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
+ -> { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
$/ = " *helicopter sound*\n"
- lambda { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
+ -> { p(o) }.should output_to_fd("Next time, Gadget, NEXT TIME!\n")
end
it "prints nothing if no argument is given" do
- lambda { p }.should output("")
+ -> { p }.should output("")
end
it "prints nothing if called splatting an empty Array" do
- lambda { p(*[]) }.should output("")
+ -> { p(*[]) }.should output("")
end
=begin Not sure how to spec this, but wanted to note the behavior here
diff --git a/spec/ruby/core/kernel/printf_spec.rb b/spec/ruby/core/kernel/printf_spec.rb
index ca88082694..5d68c0a13c 100644
--- a/spec/ruby/core/kernel/printf_spec.rb
+++ b/spec/ruby/core/kernel/printf_spec.rb
@@ -36,7 +36,7 @@ describe "Kernel.printf" do
describe "formatting" do
context "io is specified" do
- it_behaves_like :kernel_sprintf, -> (format, *args) {
+ it_behaves_like :kernel_sprintf, -> format, *args {
io = StringIO.new
printf(io, format, *args)
io.string
@@ -44,7 +44,7 @@ describe "Kernel.printf" do
end
context "io is not specified" do
- it_behaves_like :kernel_sprintf, -> (format, *args) {
+ it_behaves_like :kernel_sprintf, -> format, *args {
stdout = $stdout
begin
diff --git a/spec/ruby/core/kernel/proc_spec.rb b/spec/ruby/core/kernel/proc_spec.rb
index e3acfa8dfd..ded2cec3fd 100644
--- a/spec/ruby/core/kernel/proc_spec.rb
+++ b/spec/ruby/core/kernel/proc_spec.rb
@@ -15,7 +15,7 @@ describe "Kernel.proc" do
end
it "returned the passed Proc if given an existing Proc" do
- some_lambda = lambda {}
+ some_lambda = -> {}
some_lambda.lambda?.should be_true
l = proc(&some_lambda)
l.should equal(some_lambda)
diff --git a/spec/ruby/core/kernel/public_method_spec.rb b/spec/ruby/core/kernel/public_method_spec.rb
index 72d0c62720..c5d54c777e 100644
--- a/spec/ruby/core/kernel/public_method_spec.rb
+++ b/spec/ruby/core/kernel/public_method_spec.rb
@@ -11,21 +11,21 @@ describe "Kernel#public_method" do
it "raises a NameError when called on a private method" do
@obj.send(:private_method).should == :private_method
- lambda do
+ -> do
@obj.public_method(:private_method)
end.should raise_error(NameError)
end
it "raises a NameError when called on a protected method" do
@obj.send(:protected_method).should == :protected_method
- lambda {
+ -> {
@obj.public_method(:protected_method)
}.should raise_error(NameError)
end
it "raises a NameError if we only repond_to_missing? method, true" do
obj = KernelSpecs::RespondViaMissing.new
- lambda do
+ -> do
obj.public_method(:handled_privately)
end.should raise_error(NameError)
end
diff --git a/spec/ruby/core/kernel/public_send_spec.rb b/spec/ruby/core/kernel/public_send_spec.rb
index 984ab41802..6b942a2e4b 100644
--- a/spec/ruby/core/kernel/public_send_spec.rb
+++ b/spec/ruby/core/kernel/public_send_spec.rb
@@ -29,7 +29,7 @@ describe "Kernel#public_send" do
'done'
end
end
- lambda { KernelSpecs::Foo.new.public_send(:bar)}.should raise_error(NoMethodError)
+ -> { KernelSpecs::Foo.new.public_send(:bar)}.should raise_error(NoMethodError)
end
it "raises a NoMethodError if the named method is private" do
@@ -39,7 +39,7 @@ describe "Kernel#public_send" do
'done2'
end
end
- lambda {
+ -> {
KernelSpecs::Foo.new.public_send(:bar)
}.should raise_error(NoMethodError)
end
@@ -70,11 +70,11 @@ describe "Kernel#public_send" do
end
it "raises a NoMethodError if the method is protected" do
- lambda { @receiver.call_protected_method }.should raise_error(NoMethodError)
+ -> { @receiver.call_protected_method }.should raise_error(NoMethodError)
end
it "raises a NoMethodError if the method is private" do
- lambda { @receiver.call_private_method }.should raise_error(NoMethodError)
+ -> { @receiver.call_private_method }.should raise_error(NoMethodError)
end
end
@@ -86,7 +86,7 @@ describe "Kernel#public_send" do
end
alias :aka :bar
end
- lambda {
+ -> {
KernelSpecs::Foo.new.public_send(:aka)
}.should raise_error(NoMethodError)
end
@@ -99,7 +99,7 @@ describe "Kernel#public_send" do
end
alias :aka :bar
end
- lambda {
+ -> {
KernelSpecs::Foo.new.public_send(:aka)
}.should raise_error(NoMethodError)
end
diff --git a/spec/ruby/core/kernel/rand_spec.rb b/spec/ruby/core/kernel/rand_spec.rb
index bdf5842f1a..843b5d10a2 100644
--- a/spec/ruby/core/kernel/rand_spec.rb
+++ b/spec/ruby/core/kernel/rand_spec.rb
@@ -132,6 +132,12 @@ describe "Kernel.rand" do
it "returns the range start/end when Integer range is 0" do
rand(42..42).should eql(42)
end
+
+ it "supports custom object types" do
+ rand(KernelSpecs::CustomRangeInteger.new(1)..KernelSpecs::CustomRangeInteger.new(42)).should be_an_instance_of(KernelSpecs::CustomRangeInteger)
+ rand(KernelSpecs::CustomRangeFloat.new(1.0)..KernelSpecs::CustomRangeFloat.new(42.0)).should be_an_instance_of(KernelSpecs::CustomRangeFloat)
+ rand(Time.now..Time.now).should be_an_instance_of(Time)
+ end
end
describe "Kernel#rand" do
diff --git a/spec/ruby/core/kernel/remove_instance_variable_spec.rb b/spec/ruby/core/kernel/remove_instance_variable_spec.rb
index 5022a70c1d..e90efc8aed 100644
--- a/spec/ruby/core/kernel/remove_instance_variable_spec.rb
+++ b/spec/ruby/core/kernel/remove_instance_variable_spec.rb
@@ -23,19 +23,19 @@ describe "Kernel#remove_instance_variable" do
end
it "raises a NameError if the instance variable is not defined" do
- lambda do
+ -> do
@instance.send :remove_instance_variable, :@unknown
end.should raise_error(NameError)
end
it "raises a NameError if the argument is not a valid instance variable name" do
- lambda do
+ -> do
@instance.send :remove_instance_variable, :"@0"
end.should raise_error(NameError)
end
it "raises a TypeError if passed an Object not defining #to_str" do
- lambda do
+ -> do
obj = mock("kernel remove_instance_variable")
@instance.send :remove_instance_variable, obj
end.should raise_error(TypeError)
diff --git a/spec/ruby/core/kernel/require_relative_spec.rb b/spec/ruby/core/kernel/require_relative_spec.rb
index 6604d30ab1..b292a46c63 100644
--- a/spec/ruby/core/kernel/require_relative_spec.rb
+++ b/spec/ruby/core/kernel/require_relative_spec.rb
@@ -86,18 +86,18 @@ describe "Kernel#require_relative with a relative path" do
end
it "raises a LoadError if the file does not exist" do
- lambda { require_relative("#{@dir}/nonexistent.rb") }.should raise_error(LoadError)
+ -> { require_relative("#{@dir}/nonexistent.rb") }.should raise_error(LoadError)
ScratchPad.recorded.should == []
end
it "raises a LoadError if basepath does not exist" do
- lambda { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError)
+ -> { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError)
end
it "stores the missing path in a LoadError object" do
path = "#{@dir}/nonexistent.rb"
- lambda {
+ -> {
require_relative(path)
}.should(raise_error(LoadError) { |e|
e.path.should == File.expand_path(path, @abs_dir)
@@ -112,9 +112,9 @@ describe "Kernel#require_relative with a relative path" do
end
it "raises a TypeError if argument does not respond to #to_str" do
- lambda { require_relative(nil) }.should raise_error(TypeError)
- lambda { require_relative(42) }.should raise_error(TypeError)
- lambda {
+ -> { require_relative(nil) }.should raise_error(TypeError)
+ -> { require_relative(42) }.should raise_error(TypeError)
+ -> {
require_relative([@path,@path])
}.should raise_error(TypeError)
end
@@ -122,13 +122,13 @@ describe "Kernel#require_relative with a relative path" do
it "raises a TypeError if passed an object that has #to_s but not #to_str" do
name = mock("load_fixture.rb mock")
name.stub!(:to_s).and_return(@path)
- lambda { require_relative(name) }.should raise_error(TypeError)
+ -> { require_relative(name) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_str does not return a String" do
name = mock("#to_str returns nil")
name.should_receive(:to_str).at_least(1).times.and_return(nil)
- lambda { require_relative(name) }.should raise_error(TypeError)
+ -> { require_relative(name) }.should raise_error(TypeError)
end
it "calls #to_path on non-String objects" do
@@ -239,7 +239,7 @@ describe "Kernel#require_relative with a relative path" do
it "does not store the path if the load fails" do
saved_loaded_features = $LOADED_FEATURES.dup
- lambda { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError)
+ -> { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError)
$LOADED_FEATURES.should == saved_loaded_features
end
@@ -288,18 +288,18 @@ describe "Kernel#require_relative with an absolute path" do
end
it "raises a LoadError if the file does not exist" do
- lambda { require_relative("#{@dir}/nonexistent.rb") }.should raise_error(LoadError)
+ -> { require_relative("#{@dir}/nonexistent.rb") }.should raise_error(LoadError)
ScratchPad.recorded.should == []
end
it "raises a LoadError if basepath does not exist" do
- lambda { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError)
+ -> { eval("require_relative('#{@dir}/nonexistent.rb')") }.should raise_error(LoadError)
end
it "stores the missing path in a LoadError object" do
path = "#{@dir}/nonexistent.rb"
- lambda {
+ -> {
require_relative(path)
}.should(raise_error(LoadError) { |e|
e.path.should == File.expand_path(path, @abs_dir)
@@ -314,9 +314,9 @@ describe "Kernel#require_relative with an absolute path" do
end
it "raises a TypeError if argument does not respond to #to_str" do
- lambda { require_relative(nil) }.should raise_error(TypeError)
- lambda { require_relative(42) }.should raise_error(TypeError)
- lambda {
+ -> { require_relative(nil) }.should raise_error(TypeError)
+ -> { require_relative(42) }.should raise_error(TypeError)
+ -> {
require_relative([@path,@path])
}.should raise_error(TypeError)
end
@@ -324,13 +324,13 @@ describe "Kernel#require_relative with an absolute path" do
it "raises a TypeError if passed an object that has #to_s but not #to_str" do
name = mock("load_fixture.rb mock")
name.stub!(:to_s).and_return(@path)
- lambda { require_relative(name) }.should raise_error(TypeError)
+ -> { require_relative(name) }.should raise_error(TypeError)
end
it "raises a TypeError if #to_str does not return a String" do
name = mock("#to_str returns nil")
name.should_receive(:to_str).at_least(1).times.and_return(nil)
- lambda { require_relative(name) }.should raise_error(TypeError)
+ -> { require_relative(name) }.should raise_error(TypeError)
end
it "calls #to_path on non-String objects" do
@@ -401,7 +401,7 @@ describe "Kernel#require_relative with an absolute path" do
it "does not store the path if the load fails" do
saved_loaded_features = $LOADED_FEATURES.dup
- lambda { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError)
+ -> { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError)
$LOADED_FEATURES.should == saved_loaded_features
end
diff --git a/spec/ruby/core/kernel/respond_to_spec.rb b/spec/ruby/core/kernel/respond_to_spec.rb
index 80487421d7..e7efc9f275 100644
--- a/spec/ruby/core/kernel/respond_to_spec.rb
+++ b/spec/ruby/core/kernel/respond_to_spec.rb
@@ -25,7 +25,7 @@ describe "Kernel#respond_to?" do
end
it "throws a type error if argument can't be coerced into a Symbol" do
- lambda { @a.respond_to?(Object.new) }.should raise_error(TypeError)
+ -> { @a.respond_to?(Object.new) }.should raise_error(TypeError)
end
it "returns false if obj responds to the given protected method" do
@@ -61,7 +61,7 @@ describe "Kernel#respond_to?" do
it "does not change method visibility when finding private method" do
KernelSpecs::VisibilityChange.respond_to?(:new, false).should == false
KernelSpecs::VisibilityChange.respond_to?(:new, true).should == true
- lambda { KernelSpecs::VisibilityChange.new }.should raise_error(NoMethodError)
+ -> { KernelSpecs::VisibilityChange.new }.should raise_error(NoMethodError)
end
it "indicates if an object responds to a particular message" do
diff --git a/spec/ruby/core/kernel/shared/dup_clone.rb b/spec/ruby/core/kernel/shared/dup_clone.rb
index 37890f2981..d1ee64bd09 100644
--- a/spec/ruby/core/kernel/shared/dup_clone.rb
+++ b/spec/ruby/core/kernel/shared/dup_clone.rb
@@ -102,12 +102,12 @@ describe :kernel_dup_clone, shared: true do
ruby_version_is ''...'2.5' do
it "raises a TypeError for Complex" do
c = Complex(1.3, 3.1)
- lambda { c.send(@method) }.should raise_error(TypeError)
+ -> { c.send(@method) }.should raise_error(TypeError)
end
it "raises a TypeError for Rational" do
r = Rational(1, 3)
- lambda { r.send(@method) }.should raise_error(TypeError)
+ -> { r.send(@method) }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/shared/kind_of.rb b/spec/ruby/core/kernel/shared/kind_of.rb
index 0614c02214..aef6f1c1d8 100644
--- a/spec/ruby/core/kernel/shared/kind_of.rb
+++ b/spec/ruby/core/kernel/shared/kind_of.rb
@@ -40,10 +40,10 @@ describe :kernel_kind_of, shared: true do
end
it "raises a TypeError if given an object that is not a Class nor a Module" do
- lambda { @o.send(@method, 1) }.should raise_error(TypeError)
- lambda { @o.send(@method, 'KindaClass') }.should raise_error(TypeError)
- lambda { @o.send(@method, :KindaClass) }.should raise_error(TypeError)
- lambda { @o.send(@method, Object.new) }.should raise_error(TypeError)
+ -> { @o.send(@method, 1) }.should raise_error(TypeError)
+ -> { @o.send(@method, 'KindaClass') }.should raise_error(TypeError)
+ -> { @o.send(@method, :KindaClass) }.should raise_error(TypeError)
+ -> { @o.send(@method, Object.new) }.should raise_error(TypeError)
end
it "does not take into account `class` method overriding" do
diff --git a/spec/ruby/core/kernel/shared/lambda.rb b/spec/ruby/core/kernel/shared/lambda.rb
index bebb111c43..c7180e1442 100644
--- a/spec/ruby/core/kernel/shared/lambda.rb
+++ b/spec/ruby/core/kernel/shared/lambda.rb
@@ -4,6 +4,6 @@ describe :kernel_lambda, shared: true do
end
it "raises an ArgumentError when no block is given" do
- lambda { send(@method) }.should raise_error(ArgumentError)
+ -> { send(@method) }.should raise_error(ArgumentError)
end
end
diff --git a/spec/ruby/core/kernel/shared/load.rb b/spec/ruby/core/kernel/shared/load.rb
index b479b29399..14bf5f27da 100644
--- a/spec/ruby/core/kernel/shared/load.rb
+++ b/spec/ruby/core/kernel/shared/load.rb
@@ -81,7 +81,7 @@ describe :kernel_load, shared: true do
it "raises a LoadError if passed a non-extensioned path that does not exist but a .rb extensioned path does exist" do
path = File.expand_path "load_ext_fixture", CODE_LOADING_DIR
- lambda { @object.load(path) }.should raise_error(LoadError)
+ -> { @object.load(path) }.should raise_error(LoadError)
end
describe "when passed true for 'wrap'" do
@@ -115,7 +115,7 @@ describe :kernel_load, shared: true do
end
it "does not pollute the receiver" do
- lambda { @object.send(:top_level_method) }.should raise_error(NameError)
+ -> { @object.send(:top_level_method) }.should raise_error(NameError)
end
end
end
diff --git a/spec/ruby/core/kernel/shared/method.rb b/spec/ruby/core/kernel/shared/method.rb
index 006ebbffb8..3418966b1b 100644
--- a/spec/ruby/core/kernel/shared/method.rb
+++ b/spec/ruby/core/kernel/shared/method.rb
@@ -23,14 +23,14 @@ describe :kernel_method, shared: true do
it "raises a NameError for an invalid method name" do
class KernelSpecs::Foo; def bar; 'done'; end; end
- lambda {
+ -> {
KernelSpecs::Foo.new.send(@method, :invalid_and_silly_method_name)
}.should raise_error(NameError)
end
it "raises a NameError for an invalid singleton method name" do
class KernelSpecs::Foo; def self.bar; 'done'; end; end
- lambda { KernelSpecs::Foo.send(@method, :baz) }.should raise_error(NameError)
+ -> { KernelSpecs::Foo.send(@method, :baz) }.should raise_error(NameError)
end
it "changes the method called for super on a target aliased method" do
diff --git a/spec/ruby/core/kernel/shared/require.rb b/spec/ruby/core/kernel/shared/require.rb
index 56377684fb..af0d50db4f 100644
--- a/spec/ruby/core/kernel/shared/require.rb
+++ b/spec/ruby/core/kernel/shared/require.rb
@@ -21,7 +21,7 @@ describe :kernel_require_basic, shared: true do
it "raises a LoadError if the file does not exist" do
path = File.expand_path "nonexistent.rb", CODE_LOADING_DIR
File.exist?(path).should be_false
- lambda { @object.send(@method, path) }.should raise_error(LoadError)
+ -> { @object.send(@method, path) }.should raise_error(LoadError)
ScratchPad.recorded.should == []
end
@@ -42,7 +42,7 @@ describe :kernel_require_basic, shared: true do
it "raises a LoadError" do
File.exist?(@path).should be_true
- lambda { @object.send(@method, @path) }.should raise_error(LoadError)
+ -> { @object.send(@method, @path) }.should raise_error(LoadError)
end
end
end
@@ -57,19 +57,19 @@ describe :kernel_require_basic, shared: true do
end
it "raises a TypeError if passed nil" do
- lambda { @object.send(@method, nil) }.should raise_error(TypeError)
+ -> { @object.send(@method, nil) }.should raise_error(TypeError)
end
it "raises a TypeError if passed a Fixnum" do
- lambda { @object.send(@method, 42) }.should raise_error(TypeError)
+ -> { @object.send(@method, 42) }.should raise_error(TypeError)
end
it "raises a TypeError if passed an Array" do
- lambda { @object.send(@method, []) }.should raise_error(TypeError)
+ -> { @object.send(@method, []) }.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that does not provide #to_str" do
- lambda { @object.send(@method, mock("not a filename")) }.should raise_error(TypeError)
+ -> { @object.send(@method, mock("not a filename")) }.should raise_error(TypeError)
end
it "raises a TypeError if passed an object that has #to_s but not #to_str" do
@@ -77,14 +77,14 @@ describe :kernel_require_basic, shared: true do
name.stub!(:to_s).and_return("load_fixture.rb")
$LOAD_PATH << "."
Dir.chdir CODE_LOADING_DIR do
- lambda { @object.send(@method, name) }.should raise_error(TypeError)
+ -> { @object.send(@method, name) }.should raise_error(TypeError)
end
end
it "raises a TypeError if #to_str does not return a String" do
name = mock("#to_str returns nil")
name.should_receive(:to_str).at_least(1).times.and_return(nil)
- lambda { @object.send(@method, name) }.should raise_error(TypeError)
+ -> { @object.send(@method, name) }.should raise_error(TypeError)
end
it "calls #to_path on non-String objects" do
@@ -170,7 +170,7 @@ describe :kernel_require_basic, shared: true do
it "does not resolve a ./ relative path against $LOAD_PATH entries" do
$LOAD_PATH << CODE_LOADING_DIR
- lambda do
+ -> do
@object.send(@method, "./load_fixture.rb")
end.should raise_error(LoadError)
ScratchPad.recorded.should == []
@@ -178,7 +178,7 @@ describe :kernel_require_basic, shared: true do
it "does not resolve a ../ relative path against $LOAD_PATH entries" do
$LOAD_PATH << CODE_LOADING_DIR
- lambda do
+ -> do
@object.send(@method, "../code/load_fixture.rb")
end.should raise_error(LoadError)
ScratchPad.recorded.should == []
@@ -208,14 +208,14 @@ describe :kernel_require, shared: true do
# intentional for security reasons.
it "does not load a bare filename unless the current working directory is in $LOAD_PATH" do
Dir.chdir CODE_LOADING_DIR do
- lambda { @object.require("load_fixture.rb") }.should raise_error(LoadError)
+ -> { @object.require("load_fixture.rb") }.should raise_error(LoadError)
ScratchPad.recorded.should == []
end
end
it "does not load a relative path unless the current working directory is in $LOAD_PATH" do
Dir.chdir File.dirname(CODE_LOADING_DIR) do
- lambda do
+ -> do
@object.require("code/load_fixture.rb")
end.should raise_error(LoadError)
ScratchPad.recorded.should == []
@@ -381,7 +381,7 @@ describe :kernel_require, shared: true do
it "does not store the path if the load fails" do
$LOAD_PATH << CODE_LOADING_DIR
saved_loaded_features = $LOADED_FEATURES.dup
- lambda { @object.require("raise_fixture.rb") }.should raise_error(RuntimeError)
+ -> { @object.require("raise_fixture.rb") }.should raise_error(RuntimeError)
$LOADED_FEATURES.should == saved_loaded_features
end
@@ -683,7 +683,7 @@ describe :kernel_require, shared: true do
Thread.current[:wait_for] = t2
Thread.current[:con_raise] = true
- lambda {
+ -> {
@object.require(@path)
}.should raise_error(RuntimeError)
@@ -724,7 +724,7 @@ describe :kernel_require, shared: true do
t1 = Thread.new do
Thread.current[:con_raise] = true
- lambda {
+ -> {
@object.require(@path)
}.should raise_error(RuntimeError)
@@ -764,7 +764,7 @@ describe :kernel_require, shared: true do
it "stores the missing path in a LoadError object" do
path = "abcd1234"
- lambda {
+ -> {
@object.send(@method, path)
}.should raise_error(LoadError) { |e|
e.path.should == path
diff --git a/spec/ruby/core/kernel/shared/sprintf.rb b/spec/ruby/core/kernel/shared/sprintf.rb
index 925c79e82b..9899684284 100644
--- a/spec/ruby/core/kernel/shared/sprintf.rb
+++ b/spec/ruby/core/kernel/shared/sprintf.rb
@@ -31,7 +31,7 @@ describe :kernel_sprintf, shared: true do
end
it "raises TypeError exception if cannot convert to Integer" do
- -> () {
+ -> {
format("%b", Object.new)
}.should raise_error(TypeError)
end
@@ -120,7 +120,7 @@ describe :kernel_sprintf, shared: true do
end
it "raises TypeError exception if cannot convert to Float" do
- -> () {
+ -> {
format("%f", Object.new)
}.should raise_error(TypeError)
end
@@ -296,13 +296,13 @@ describe :kernel_sprintf, shared: true do
end
it "raises ArgumentError if argument is a string of several characters" do
- -> () {
+ -> {
format("%c", "abc")
}.should raise_error(ArgumentError)
end
it "raises ArgumentError if argument is an empty string" do
- -> () {
+ -> {
format("%c", "")
}.should raise_error(ArgumentError)
end
@@ -338,7 +338,7 @@ describe :kernel_sprintf, shared: true do
"abc"
end
- -> () {
+ -> {
format("%s", obj)
}.should raise_error(NoMethodError)
end
@@ -461,7 +461,7 @@ describe :kernel_sprintf, shared: true do
end
it "raises exception if argument number is bigger than actual arguments list" do
- -> () {
+ -> {
format("%4$d", 1, 2, 3)
}.should raise_error(ArgumentError)
end
@@ -472,7 +472,7 @@ describe :kernel_sprintf, shared: true do
end
it "raises ArgumentError exception when absolute and relative argument numbers are mixed" do
- -> () {
+ -> {
format("%1$d %d", 1, 2)
}.should raise_error(ArgumentError)
end
@@ -722,7 +722,7 @@ describe :kernel_sprintf, shared: true do
end
it "raises ArgumentError when is mixed with width" do
- -> () {
+ -> {
format("%*10d", 10, 112)
}.should raise_error(ArgumentError)
end
@@ -821,7 +821,7 @@ describe :kernel_sprintf, shared: true do
end
it "cannot be mixed with unnamed style" do
- -> () {
+ -> {
format("%d %<foo>d", 1, foo: "123")
}.should raise_error(ArgumentError)
end
@@ -841,13 +841,13 @@ describe :kernel_sprintf, shared: true do
end
it "cannot be mixed with unnamed style" do
- -> () {
+ -> {
format("%d %{foo}", 1, foo: "123")
}.should raise_error(ArgumentError)
end
it "raises KeyError when there is no matching key" do
- -> () {
+ -> {
format("%{foo}", {})
}.should raise_error(KeyError)
end
@@ -870,7 +870,7 @@ describe :kernel_sprintf, shared: true do
@base_method = @method
end
- it_behaves_like :key_error, -> (obj, key) {
+ it_behaves_like :key_error, -> obj, key {
@base_method.call("%<#{key}>s", obj)
}, { foooo: 1 }
end
diff --git a/spec/ruby/core/kernel/shared/sprintf_encoding.rb b/spec/ruby/core/kernel/shared/sprintf_encoding.rb
index a92f3c10cd..c3d62bf3bb 100644
--- a/spec/ruby/core/kernel/shared/sprintf_encoding.rb
+++ b/spec/ruby/core/kernel/shared/sprintf_encoding.rb
@@ -21,7 +21,7 @@ describe :kernel_sprintf_encoding, shared: true do
string = "Ä %s".encode('windows-1252')
argument = "Ђ".encode('windows-1251')
- -> () {
+ -> {
format(string, argument)
}.should raise_error(Encoding::CompatibilityError)
end
diff --git a/spec/ruby/core/kernel/singleton_class_spec.rb b/spec/ruby/core/kernel/singleton_class_spec.rb
index b5e0703905..5dbb4f8c05 100644
--- a/spec/ruby/core/kernel/singleton_class_spec.rb
+++ b/spec/ruby/core/kernel/singleton_class_spec.rb
@@ -18,10 +18,10 @@ describe "Kernel#singleton_class" do
end
it "raises TypeError for Fixnum" do
- lambda { 123.singleton_class }.should raise_error(TypeError)
+ -> { 123.singleton_class }.should raise_error(TypeError)
end
it "raises TypeError for Symbol" do
- lambda { :foo.singleton_class }.should raise_error(TypeError)
+ -> { :foo.singleton_class }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/sleep_spec.rb b/spec/ruby/core/kernel/sleep_spec.rb
index a510ae3dc1..387dc4787b 100644
--- a/spec/ruby/core/kernel/sleep_spec.rb
+++ b/spec/ruby/core/kernel/sleep_spec.rb
@@ -23,16 +23,16 @@ describe "Kernel#sleep" do
end
it "raises an ArgumentError when passed a negative duration" do
- lambda { sleep(-0.1) }.should raise_error(ArgumentError)
- lambda { sleep(-1) }.should raise_error(ArgumentError)
+ -> { sleep(-0.1) }.should raise_error(ArgumentError)
+ -> { sleep(-1) }.should raise_error(ArgumentError)
end
it "raises a TypeError when passed nil" do
- lambda { sleep(nil) }.should raise_error(TypeError)
+ -> { sleep(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a String" do
- lambda { sleep('2') }.should raise_error(TypeError)
+ -> { sleep('2') }.should raise_error(TypeError)
end
it "pauses execution indefinitely if not given a duration" do
diff --git a/spec/ruby/core/kernel/spawn_spec.rb b/spec/ruby/core/kernel/spawn_spec.rb
index da3cf39021..ba05b629d5 100644
--- a/spec/ruby/core/kernel/spawn_spec.rb
+++ b/spec/ruby/core/kernel/spawn_spec.rb
@@ -10,7 +10,7 @@ describe "Kernel#spawn" do
end
it "executes the given command" do
- lambda {
+ -> {
Process.wait spawn("echo spawn")
}.should output_to_fd("spawn\n")
end
@@ -18,7 +18,7 @@ end
describe "Kernel.spawn" do
it "executes the given command" do
- lambda {
+ -> {
Process.wait Kernel.spawn("echo spawn")
}.should output_to_fd("spawn\n")
end
diff --git a/spec/ruby/core/kernel/sprintf_spec.rb b/spec/ruby/core/kernel/sprintf_spec.rb
index 4aa8c2351f..7adf71be76 100644
--- a/spec/ruby/core/kernel/sprintf_spec.rb
+++ b/spec/ruby/core/kernel/sprintf_spec.rb
@@ -4,21 +4,21 @@ require_relative 'shared/sprintf'
require_relative 'shared/sprintf_encoding'
describe "Kernel#sprintf" do
- it_behaves_like :kernel_sprintf, -> (format, *args) {
+ it_behaves_like :kernel_sprintf, -> format, *args {
sprintf(format, *args)
}
- it_behaves_like :kernel_sprintf_encoding, -> (format, *args) {
+ it_behaves_like :kernel_sprintf_encoding, -> format, *args {
sprintf(format, *args)
}
end
describe "Kernel.sprintf" do
- it_behaves_like :kernel_sprintf, -> (format, *args) {
+ it_behaves_like :kernel_sprintf, -> format, *args {
Kernel.sprintf(format, *args)
}
- it_behaves_like :kernel_sprintf_encoding, -> (format, *args) {
+ it_behaves_like :kernel_sprintf_encoding, -> format, *args {
Kernel.sprintf(format, *args)
}
end
diff --git a/spec/ruby/core/kernel/srand_spec.rb b/spec/ruby/core/kernel/srand_spec.rb
index 053fb521ef..5454aae8cf 100644
--- a/spec/ruby/core/kernel/srand_spec.rb
+++ b/spec/ruby/core/kernel/srand_spec.rb
@@ -19,7 +19,7 @@ describe "Kernel.srand" do
end
it "defaults number to a random value" do
- lambda { srand }.should_not raise_error
+ -> { srand }.should_not raise_error
srand.should_not == 0
end
@@ -48,11 +48,11 @@ describe "Kernel.srand" do
end
it "raises a TypeError when passed nil" do
- lambda { srand(nil) }.should raise_error(TypeError)
+ -> { srand(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when passed a String" do
- lambda { srand("7") }.should raise_error(TypeError)
+ -> { srand("7") }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/kernel/system_spec.rb b/spec/ruby/core/kernel/system_spec.rb
index 6a4ba6283d..96c0496dd6 100644
--- a/spec/ruby/core/kernel/system_spec.rb
+++ b/spec/ruby/core/kernel/system_spec.rb
@@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
describe :kernel_system, shared: true do
it "executes the specified command in a subprocess" do
- lambda { @object.system("echo a") }.should output_to_fd("a\n")
+ -> { @object.system("echo a") }.should output_to_fd("a\n")
$?.should be_an_instance_of Process::Status
$?.success?.should == true
@@ -27,11 +27,11 @@ describe :kernel_system, shared: true do
ruby_version_is "2.6" do
it "raises RuntimeError when `exception: true` is given and the command exits with a non-zero exit status" do
- lambda { @object.system(ruby_cmd('exit 1'), exception: true) }.should raise_error(RuntimeError)
+ -> { @object.system(ruby_cmd('exit 1'), exception: true) }.should raise_error(RuntimeError)
end
it "raises Errno::ENOENT when `exception: true` is given and the specified command does not exist" do
- lambda { @object.system('feature_14386', exception: true) }.should raise_error(Errno::ENOENT)
+ -> { @object.system('feature_14386', exception: true) }.should raise_error(Errno::ENOENT)
end
end
@@ -44,7 +44,7 @@ describe :kernel_system, shared: true do
end
it "does not write to stderr when command execution fails" do
- lambda { @object.system("sad") }.should output_to_fd("", STDERR)
+ -> { @object.system("sad") }.should output_to_fd("", STDERR)
end
platform_is_not :windows do
@@ -57,12 +57,12 @@ describe :kernel_system, shared: true do
end
it "executes with `sh` if the command contains shell characters" do
- lambda { @object.system("echo $0") }.should output_to_fd("sh\n")
+ -> { @object.system("echo $0") }.should output_to_fd("sh\n")
end
it "ignores SHELL env var and always uses `sh`" do
ENV['SHELL'] = "/bin/fakeshell"
- lambda { @object.system("echo $0") }.should output_to_fd("sh\n")
+ -> { @object.system("echo $0") }.should output_to_fd("sh\n")
end
end
@@ -79,19 +79,19 @@ describe :kernel_system, shared: true do
end
it "expands shell variables when given a single string argument" do
- lambda { @object.system("echo #{@shell_var}") }.should output_to_fd("foo\n")
+ -> { @object.system("echo #{@shell_var}") }.should output_to_fd("foo\n")
end
platform_is_not :windows do
it "does not expand shell variables when given multiples arguments" do
- lambda { @object.system("echo", @shell_var) }.should output_to_fd("#{@shell_var}\n")
+ -> { @object.system("echo", @shell_var) }.should output_to_fd("#{@shell_var}\n")
end
end
platform_is :windows do
it "does expand shell variables when given multiples arguments" do
# See https://bugs.ruby-lang.org/issues/12231
- lambda { @object.system("echo", @shell_var) }.should output_to_fd("foo\n")
+ -> { @object.system("echo", @shell_var) }.should output_to_fd("foo\n")
end
end
diff --git a/spec/ruby/core/kernel/taint_spec.rb b/spec/ruby/core/kernel/taint_spec.rb
index ff1b20f9ca..000295f6d2 100644
--- a/spec/ruby/core/kernel/taint_spec.rb
+++ b/spec/ruby/core/kernel/taint_spec.rb
@@ -15,7 +15,7 @@ describe "Kernel#taint" do
it "raises #{frozen_error_class} on an untainted, frozen object" do
o = Object.new.freeze
- lambda { o.taint }.should raise_error(frozen_error_class)
+ -> { o.taint }.should raise_error(frozen_error_class)
end
it "does not raise an error on a tainted, frozen object" do
@@ -32,13 +32,13 @@ describe "Kernel#taint" do
it "no raises a RuntimeError on symbols" do
v = :sym
- lambda { v.taint }.should_not raise_error(RuntimeError)
+ -> { v.taint }.should_not raise_error(RuntimeError)
v.tainted?.should == false
end
it "no raises error on fixnum values" do
[1].each do |v|
- lambda { v.taint }.should_not raise_error(RuntimeError)
+ -> { v.taint }.should_not raise_error(RuntimeError)
v.tainted?.should == false
end
end
diff --git a/spec/ruby/core/kernel/tap_spec.rb b/spec/ruby/core/kernel/tap_spec.rb
index a7d548847c..f7720a6dc7 100644
--- a/spec/ruby/core/kernel/tap_spec.rb
+++ b/spec/ruby/core/kernel/tap_spec.rb
@@ -8,6 +8,6 @@ describe "Kernel#tap" do
end
it "raises a LocalJumpError when no block given" do
- lambda { 3.tap }.should raise_error(LocalJumpError)
+ -> { 3.tap }.should raise_error(LocalJumpError)
end
end
diff --git a/spec/ruby/core/kernel/throw_spec.rb b/spec/ruby/core/kernel/throw_spec.rb
index 1e56376529..64bfccb413 100644
--- a/spec/ruby/core/kernel/throw_spec.rb
+++ b/spec/ruby/core/kernel/throw_spec.rb
@@ -42,21 +42,21 @@ describe "Kernel.throw" do
end
it "raises an ArgumentError if there is no catch block for the symbol" do
- lambda { throw :blah }.should raise_error(ArgumentError)
+ -> { throw :blah }.should raise_error(ArgumentError)
end
it "raises an UncaughtThrowError if there is no catch block for the symbol" do
- lambda { throw :blah }.should raise_error(UncaughtThrowError)
+ -> { throw :blah }.should raise_error(UncaughtThrowError)
end
it "raises ArgumentError if 3 or more arguments provided" do
- lambda {
+ -> {
catch :blah do
throw :blah, :return_value, 2
end
}.should raise_error(ArgumentError)
- lambda {
+ -> {
catch :blah do
throw :blah, :return_value, 2, 3, 4, 5
end
@@ -64,7 +64,7 @@ describe "Kernel.throw" do
end
it "can throw an object" do
- lambda {
+ -> {
obj = Object.new
catch obj do
throw obj
diff --git a/spec/ruby/core/kernel/trace_var_spec.rb b/spec/ruby/core/kernel/trace_var_spec.rb
index 019902a230..3c84aa5e60 100644
--- a/spec/ruby/core/kernel/trace_var_spec.rb
+++ b/spec/ruby/core/kernel/trace_var_spec.rb
@@ -47,7 +47,7 @@ describe "Kernel#trace_var" do
end
it "raises ArgumentError if no block or proc is provided" do
- lambda do
+ -> do
trace_var :$Kernel_trace_var_global
end.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/kernel/trust_spec.rb b/spec/ruby/core/kernel/trust_spec.rb
index c258c4fce7..d34aa293ec 100644
--- a/spec/ruby/core/kernel/trust_spec.rb
+++ b/spec/ruby/core/kernel/trust_spec.rb
@@ -15,7 +15,7 @@ describe "Kernel#trust" do
it "raises #{frozen_error_class} on an untrusted, frozen object" do
o = Object.new.untrust.freeze
- lambda { o.trust }.should raise_error(frozen_error_class)
+ -> { o.trust }.should raise_error(frozen_error_class)
end
it "does not raise an error on a trusted, frozen object" do
diff --git a/spec/ruby/core/kernel/untaint_spec.rb b/spec/ruby/core/kernel/untaint_spec.rb
index 73f7942124..94e4a8fd44 100644
--- a/spec/ruby/core/kernel/untaint_spec.rb
+++ b/spec/ruby/core/kernel/untaint_spec.rb
@@ -15,7 +15,7 @@ describe "Kernel#untaint" do
it "raises #{frozen_error_class} on a tainted, frozen object" do
o = Object.new.taint.freeze
- lambda { o.untaint }.should raise_error(frozen_error_class)
+ -> { o.untaint }.should raise_error(frozen_error_class)
end
it "does not raise an error on an untainted, frozen object" do
diff --git a/spec/ruby/core/kernel/untrust_spec.rb b/spec/ruby/core/kernel/untrust_spec.rb
index f70e4356ff..2ee3dbb170 100644
--- a/spec/ruby/core/kernel/untrust_spec.rb
+++ b/spec/ruby/core/kernel/untrust_spec.rb
@@ -15,7 +15,7 @@ describe "Kernel#untrust" do
it "raises #{frozen_error_class} on a trusted, frozen object" do
o = Object.new.freeze
- lambda { o.untrust }.should raise_error(frozen_error_class)
+ -> { o.untrust }.should raise_error(frozen_error_class)
end
it "does not raise an error on an untrusted, frozen object" do
diff --git a/spec/ruby/core/kernel/untrusted_spec.rb b/spec/ruby/core/kernel/untrusted_spec.rb
index 55638a5dd3..3f894b0bab 100644
--- a/spec/ruby/core/kernel/untrusted_spec.rb
+++ b/spec/ruby/core/kernel/untrusted_spec.rb
@@ -23,6 +23,6 @@ describe "Kernel#untrusted?" do
it "has effect on immediate values" do
d = 1
- lambda { d.untrust }.should_not raise_error(RuntimeError)
+ -> { d.untrust }.should_not raise_error(RuntimeError)
end
end
diff --git a/spec/ruby/core/kernel/warn_spec.rb b/spec/ruby/core/kernel/warn_spec.rb
index 7e0a57fa9a..d05a37958d 100644
--- a/spec/ruby/core/kernel/warn_spec.rb
+++ b/spec/ruby/core/kernel/warn_spec.rb
@@ -21,56 +21,56 @@ describe "Kernel#warn" do
end
it "does not append line-end if last character is line-end" do
- lambda {
+ -> {
$VERBOSE = true
warn("this is some simple text with line-end\n")
}.should output(nil, "this is some simple text with line-end\n")
end
it "calls #write on $stderr if $VERBOSE is true" do
- lambda {
+ -> {
$VERBOSE = true
warn("this is some simple text")
}.should output(nil, "this is some simple text\n")
end
it "calls #write on $stderr if $VERBOSE is false" do
- lambda {
+ -> {
$VERBOSE = false
warn("this is some simple text")
}.should output(nil, "this is some simple text\n")
end
it "does not call #write on $stderr if $VERBOSE is nil" do
- lambda {
+ -> {
$VERBOSE = nil
warn("this is some simple text")
}.should output(nil, "")
end
it "writes each argument on a line when passed multiple arguments" do
- lambda {
+ -> {
$VERBOSE = true
warn("line 1", "line 2")
}.should output(nil, "line 1\nline 2\n")
end
it "writes each array element on a line when passes an array" do
- lambda {
+ -> {
$VERBOSE = true
warn(["line 1", "line 2"])
}.should output(nil, "line 1\nline 2\n")
end
it "does not write strings when passed no arguments" do
- lambda {
+ -> {
$VERBOSE = true
warn
}.should output("", "")
end
it "writes the default record separator and NOT $/ to $stderr after the warning message" do
- lambda {
+ -> {
$VERBOSE = true
$/ = 'rs'
warn("")
@@ -80,7 +80,7 @@ describe "Kernel#warn" do
it "writes to_s representation if passed a non-string" do
obj = mock("obj")
obj.should_receive(:to_s).and_return("to_s called")
- lambda {
+ -> {
$VERBOSE = true
warn(obj)
}.should output(nil, "to_s called\n")