diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-07-27 12:40:09 +0200 |
commit | 5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch) | |
tree | 05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/core/string | |
parent | a06301b103371b0b7da8eaca26ba744961769f99 (diff) |
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/core/string')
70 files changed, 454 insertions, 454 deletions
diff --git a/spec/ruby/core/string/capitalize_spec.rb b/spec/ruby/core/string/capitalize_spec.rb index c7f4aed20c..df64cdaa3b 100644 --- a/spec/ruby/core/string/capitalize_spec.rb +++ b/spec/ruby/core/string/capitalize_spec.rb @@ -52,7 +52,7 @@ describe "String#capitalize" do end it "does not allow any other additional option" do - lambda { "iSa".capitalize(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { "iSa".capitalize(:turkic, :ascii) }.should raise_error(ArgumentError) end end @@ -66,16 +66,16 @@ describe "String#capitalize" do end it "does not allow any other additional option" do - lambda { "iß".capitalize(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { "iß".capitalize(:lithuanian, :ascii) }.should raise_error(ArgumentError) end end it "does not allow the :fold option for upcasing" do - lambda { "abc".capitalize(:fold) }.should raise_error(ArgumentError) + -> { "abc".capitalize(:fold) }.should raise_error(ArgumentError) end it "does not allow invalid options" do - lambda { "abc".capitalize(:invalid_option) }.should raise_error(ArgumentError) + -> { "abc".capitalize(:invalid_option) }.should raise_error(ArgumentError) end it "returns subclass instances when called on a subclass" do @@ -137,7 +137,7 @@ describe "String#capitalize!" do end it "does not allow any other additional option" do - lambda { a = "iSa"; a.capitalize!(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { a = "iSa"; a.capitalize!(:turkic, :ascii) }.should raise_error(ArgumentError) end end @@ -155,16 +155,16 @@ describe "String#capitalize!" do end it "does not allow any other additional option" do - lambda { a = "iß"; a.capitalize!(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { a = "iß"; a.capitalize!(:lithuanian, :ascii) }.should raise_error(ArgumentError) end end it "does not allow the :fold option for upcasing" do - lambda { a = "abc"; a.capitalize!(:fold) }.should raise_error(ArgumentError) + -> { a = "abc"; a.capitalize!(:fold) }.should raise_error(ArgumentError) end it "does not allow invalid options" do - lambda { a = "abc"; a.capitalize!(:invalid_option) }.should raise_error(ArgumentError) + -> { a = "abc"; a.capitalize!(:invalid_option) }.should raise_error(ArgumentError) end it "returns nil when no changes are made" do @@ -179,7 +179,7 @@ describe "String#capitalize!" do it "raises a #{frozen_error_class} when self is frozen" do ["", "Hello", "hello"].each do |a| a.freeze - lambda { a.capitalize! }.should raise_error(frozen_error_class) + -> { a.capitalize! }.should raise_error(frozen_error_class) end end end diff --git a/spec/ruby/core/string/casecmp_spec.rb b/spec/ruby/core/string/casecmp_spec.rb index 35afcc0152..01b22e8f13 100644 --- a/spec/ruby/core/string/casecmp_spec.rb +++ b/spec/ruby/core/string/casecmp_spec.rb @@ -27,7 +27,7 @@ describe "String#casecmp independent of case" do ruby_version_is ""..."2.5" do it "raises a TypeError if other can't be converted to a string" do - lambda { "abc".casecmp(mock('abc')) }.should raise_error(TypeError) + -> { "abc".casecmp(mock('abc')) }.should raise_error(TypeError) end end @@ -198,7 +198,7 @@ describe 'String#casecmp? independent of case' do ruby_version_is "2.4"..."2.5" do it "raises a TypeError if other can't be converted to a string" do - lambda { "abc".casecmp?(mock('abc')) }.should raise_error(TypeError) + -> { "abc".casecmp?(mock('abc')) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/string/center_spec.rb b/spec/ruby/core/string/center_spec.rb index 3a9e689eac..27f8b7387f 100644 --- a/spec/ruby/core/string/center_spec.rb +++ b/spec/ruby/core/string/center_spec.rb @@ -65,10 +65,10 @@ describe "String#center with length, padding" do end it "raises a TypeError when length can't be converted to an integer" do - lambda { "hello".center("x") }.should raise_error(TypeError) - lambda { "hello".center("x", "y") }.should raise_error(TypeError) - lambda { "hello".center([]) }.should raise_error(TypeError) - lambda { "hello".center(mock('x')) }.should raise_error(TypeError) + -> { "hello".center("x") }.should raise_error(TypeError) + -> { "hello".center("x", "y") }.should raise_error(TypeError) + -> { "hello".center([]) }.should raise_error(TypeError) + -> { "hello".center(mock('x')) }.should raise_error(TypeError) end it "calls #to_str to convert padstr to a String" do @@ -79,14 +79,14 @@ describe "String#center with length, padding" do end it "raises a TypeError when padstr can't be converted to a string" do - lambda { "hello".center(20, 100) }.should raise_error(TypeError) - lambda { "hello".center(20, []) }.should raise_error(TypeError) - lambda { "hello".center(20, mock('x')) }.should raise_error(TypeError) + -> { "hello".center(20, 100) }.should raise_error(TypeError) + -> { "hello".center(20, []) }.should raise_error(TypeError) + -> { "hello".center(20, mock('x')) }.should raise_error(TypeError) end it "raises an ArgumentError if padstr is empty" do - lambda { "hello".center(10, "") }.should raise_error(ArgumentError) - lambda { "hello".center(0, "") }.should raise_error(ArgumentError) + -> { "hello".center(10, "") }.should raise_error(ArgumentError) + -> { "hello".center(0, "") }.should raise_error(ArgumentError) end it "returns subclass instances when called on subclasses" do @@ -123,7 +123,7 @@ describe "String#center with length, padding" do it "raises an Encoding::CompatibilityError if the encodings are incompatible" do pat = "ア".encode Encoding::EUC_JP - lambda do + -> do "あれ".center 5, pat end.should raise_error(Encoding::CompatibilityError) end diff --git a/spec/ruby/core/string/chomp_spec.rb b/spec/ruby/core/string/chomp_spec.rb index 7400d71336..9db47d1dc6 100644 --- a/spec/ruby/core/string/chomp_spec.rb +++ b/spec/ruby/core/string/chomp_spec.rb @@ -134,7 +134,7 @@ describe "String#chomp" do it "raises a TypeError if #to_str does not return a String" do arg = mock("string chomp") arg.should_receive(:to_str).and_return(1) - lambda { "abc".chomp(arg) }.should raise_error(TypeError) + -> { "abc".chomp(arg) }.should raise_error(TypeError) end end @@ -288,7 +288,7 @@ describe "String#chomp!" do it "raises a TypeError if #to_str does not return a String" do arg = mock("string chomp") arg.should_receive(:to_str).and_return(1) - lambda { "abc".chomp!(arg) }.should raise_error(TypeError) + -> { "abc".chomp!(arg) }.should raise_error(TypeError) end end @@ -318,15 +318,15 @@ describe "String#chomp!" do a = "string\n\r" a.freeze - lambda { a.chomp! }.should raise_error(frozen_error_class) + -> { a.chomp! }.should raise_error(frozen_error_class) end # see [ruby-core:23666] it "raises a #{frozen_error_class} on a frozen instance when it would not be modified" do a = "string\n\r" a.freeze - lambda { a.chomp!(nil) }.should raise_error(frozen_error_class) - lambda { a.chomp!("x") }.should raise_error(frozen_error_class) + -> { a.chomp!(nil) }.should raise_error(frozen_error_class) + -> { a.chomp!("x") }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/chop_spec.rb b/spec/ruby/core/string/chop_spec.rb index f33da3ecc4..35a5766b2f 100644 --- a/spec/ruby/core/string/chop_spec.rb +++ b/spec/ruby/core/string/chop_spec.rb @@ -112,13 +112,13 @@ describe "String#chop!" do end it "raises a #{frozen_error_class} on a frozen instance that is modified" do - lambda { "string\n\r".freeze.chop! }.should raise_error(frozen_error_class) + -> { "string\n\r".freeze.chop! }.should raise_error(frozen_error_class) end # see [ruby-core:23666] it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do a = "" a.freeze - lambda { a.chop! }.should raise_error(frozen_error_class) + -> { a.chop! }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/clear_spec.rb b/spec/ruby/core/string/clear_spec.rb index 45d452e947..0b5b8e6998 100644 --- a/spec/ruby/core/string/clear_spec.rb +++ b/spec/ruby/core/string/clear_spec.rb @@ -31,7 +31,7 @@ describe "String#clear" do it "raises a #{frozen_error_class} if self is frozen" do @s.freeze - lambda { @s.clear }.should raise_error(frozen_error_class) - lambda { "".freeze.clear }.should raise_error(frozen_error_class) + -> { @s.clear }.should raise_error(frozen_error_class) + -> { "".freeze.clear }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/codepoints_spec.rb b/spec/ruby/core/string/codepoints_spec.rb index e5eeb8b69d..0b6cde82f7 100644 --- a/spec/ruby/core/string/codepoints_spec.rb +++ b/spec/ruby/core/string/codepoints_spec.rb @@ -13,6 +13,6 @@ describe "String#codepoints" do it "raises an ArgumentError when no block is given if self has an invalid encoding" do s = "\xDF".force_encoding(Encoding::UTF_8) s.valid_encoding?.should be_false - lambda { s.codepoints }.should raise_error(ArgumentError) + -> { s.codepoints }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/string/count_spec.rb b/spec/ruby/core/string/count_spec.rb index e82a7c77ca..06ba5a4f0e 100644 --- a/spec/ruby/core/string/count_spec.rb +++ b/spec/ruby/core/string/count_spec.rb @@ -23,7 +23,7 @@ describe "String#count" do end it "raises an ArgumentError when given no arguments" do - lambda { "hell yeah".count }.should raise_error(ArgumentError) + -> { "hell yeah".count }.should raise_error(ArgumentError) end it "negates sets starting with ^" do @@ -76,8 +76,8 @@ describe "String#count" do it "raises if the given sequences are invalid" do s = "hel-[()]-lo012^" - lambda { s.count("h-e") }.should raise_error(ArgumentError) - lambda { s.count("^h-e") }.should raise_error(ArgumentError) + -> { s.count("h-e") }.should raise_error(ArgumentError) + -> { s.count("^h-e") }.should raise_error(ArgumentError) end it 'returns the number of occurrences of a multi-byte character' do @@ -98,8 +98,8 @@ describe "String#count" do end it "raises a TypeError when a set arg can't be converted to a string" do - lambda { "hello world".count(100) }.should raise_error(TypeError) - lambda { "hello world".count([]) }.should raise_error(TypeError) - lambda { "hello world".count(mock('x')) }.should raise_error(TypeError) + -> { "hello world".count(100) }.should raise_error(TypeError) + -> { "hello world".count([]) }.should raise_error(TypeError) + -> { "hello world".count(mock('x')) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/string/crypt_spec.rb b/spec/ruby/core/string/crypt_spec.rb index 66161b280f..7a0f8835f2 100644 --- a/spec/ruby/core/string/crypt_spec.rb +++ b/spec/ruby/core/string/crypt_spec.rb @@ -15,7 +15,7 @@ describe "String#crypt" do end it "raises Errno::EINVAL when the salt is shorter than 29 characters" do - lambda { "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHW") }.should raise_error(Errno::EINVAL) + -> { "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHW") }.should raise_error(Errno::EINVAL) end it "calls #to_str to converts the salt arg to a String" do @@ -73,7 +73,7 @@ describe "String#crypt" do end it "raises an ArgumentError when the string contains NUL character" do - lambda { "poison\0null".crypt("aa") }.should raise_error(ArgumentError) + -> { "poison\0null".crypt("aa") }.should raise_error(ArgumentError) end it "calls #to_str to converts the salt arg to a String" do @@ -103,16 +103,16 @@ describe "String#crypt" do end it "raises an ArgumentError when the salt is shorter than two characters" do - lambda { "hello".crypt("") }.should raise_error(ArgumentError) - lambda { "hello".crypt("f") }.should raise_error(ArgumentError) - lambda { "hello".crypt("\x00\x00") }.should raise_error(ArgumentError) - lambda { "hello".crypt("\x00a") }.should raise_error(ArgumentError) - lambda { "hello".crypt("a\x00") }.should raise_error(ArgumentError) + -> { "hello".crypt("") }.should raise_error(ArgumentError) + -> { "hello".crypt("f") }.should raise_error(ArgumentError) + -> { "hello".crypt("\x00\x00") }.should raise_error(ArgumentError) + -> { "hello".crypt("\x00a") }.should raise_error(ArgumentError) + -> { "hello".crypt("a\x00") }.should raise_error(ArgumentError) end end it "raises a type error when the salt arg can't be converted to a string" do - lambda { "".crypt(5) }.should raise_error(TypeError) - lambda { "".crypt(mock('x')) }.should raise_error(TypeError) + -> { "".crypt(5) }.should raise_error(TypeError) + -> { "".crypt(mock('x')) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/string/delete_prefix_spec.rb b/spec/ruby/core/string/delete_prefix_spec.rb index 4b4858c9c2..b88c503658 100644 --- a/spec/ruby/core/string/delete_prefix_spec.rb +++ b/spec/ruby/core/string/delete_prefix_spec.rb @@ -73,9 +73,9 @@ ruby_version_is '2.5' do end it "raises a #{frozen_error_class} when self is frozen" do - lambda { 'hello'.freeze.delete_prefix!('hell') }.should raise_error(frozen_error_class) - lambda { 'hello'.freeze.delete_prefix!('') }.should raise_error(frozen_error_class) - lambda { ''.freeze.delete_prefix!('') }.should raise_error(frozen_error_class) + -> { 'hello'.freeze.delete_prefix!('hell') }.should raise_error(frozen_error_class) + -> { 'hello'.freeze.delete_prefix!('') }.should raise_error(frozen_error_class) + -> { ''.freeze.delete_prefix!('') }.should raise_error(frozen_error_class) end end end diff --git a/spec/ruby/core/string/delete_spec.rb b/spec/ruby/core/string/delete_spec.rb index 8725b54c3b..6136cd54af 100644 --- a/spec/ruby/core/string/delete_spec.rb +++ b/spec/ruby/core/string/delete_spec.rb @@ -14,7 +14,7 @@ describe "String#delete" do end it "raises an ArgumentError when given no arguments" do - lambda { "hell yeah".delete }.should raise_error(ArgumentError) + -> { "hell yeah".delete }.should raise_error(ArgumentError) end it "negates sets starting with ^" do @@ -62,10 +62,10 @@ describe "String#delete" do not_supported_on :opal do xFF = [0xFF].pack('C') range = "\x00 - #{xFF}".force_encoding('utf-8') - lambda { "hello".delete(range).should == "" }.should raise_error(ArgumentError) + -> { "hello".delete(range).should == "" }.should raise_error(ArgumentError) end - lambda { "hello".delete("h-e") }.should raise_error(ArgumentError) - lambda { "hello".delete("^h-e") }.should raise_error(ArgumentError) + -> { "hello".delete("h-e") }.should raise_error(ArgumentError) + -> { "hello".delete("^h-e") }.should raise_error(ArgumentError) end it "taints result when self is tainted" do @@ -86,9 +86,9 @@ describe "String#delete" do end it "raises a TypeError when one set arg can't be converted to a string" do - lambda { "hello world".delete(100) }.should raise_error(TypeError) - lambda { "hello world".delete([]) }.should raise_error(TypeError) - lambda { "hello world".delete(mock('x')) }.should raise_error(TypeError) + -> { "hello world".delete(100) }.should raise_error(TypeError) + -> { "hello world".delete([]) }.should raise_error(TypeError) + -> { "hello world".delete(mock('x')) }.should raise_error(TypeError) end it "returns subclass instances when called on a subclass" do @@ -113,7 +113,7 @@ describe "String#delete!" do a = "hello" a.freeze - lambda { a.delete!("") }.should raise_error(frozen_error_class) - lambda { a.delete!("aeiou", "^e") }.should raise_error(frozen_error_class) + -> { a.delete!("") }.should raise_error(frozen_error_class) + -> { a.delete!("aeiou", "^e") }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/delete_suffix_spec.rb b/spec/ruby/core/string/delete_suffix_spec.rb index 8541c1d5d2..94909cf71d 100644 --- a/spec/ruby/core/string/delete_suffix_spec.rb +++ b/spec/ruby/core/string/delete_suffix_spec.rb @@ -73,9 +73,9 @@ ruby_version_is '2.5' do end it "raises a #{frozen_error_class} when self is frozen" do - lambda { 'hello'.freeze.delete_suffix!('ello') }.should raise_error(frozen_error_class) - lambda { 'hello'.freeze.delete_suffix!('') }.should raise_error(frozen_error_class) - lambda { ''.freeze.delete_suffix!('') }.should raise_error(frozen_error_class) + -> { 'hello'.freeze.delete_suffix!('ello') }.should raise_error(frozen_error_class) + -> { 'hello'.freeze.delete_suffix!('') }.should raise_error(frozen_error_class) + -> { ''.freeze.delete_suffix!('') }.should raise_error(frozen_error_class) end end end diff --git a/spec/ruby/core/string/downcase_spec.rb b/spec/ruby/core/string/downcase_spec.rb index 9d57ea8e25..31c8f3f446 100644 --- a/spec/ruby/core/string/downcase_spec.rb +++ b/spec/ruby/core/string/downcase_spec.rb @@ -39,7 +39,7 @@ describe "String#downcase" do end it "does not allow any other additional option" do - lambda { "İ".downcase(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { "İ".downcase(:turkic, :ascii) }.should raise_error(ArgumentError) end end @@ -53,7 +53,7 @@ describe "String#downcase" do end it "does not allow any other additional option" do - lambda { "İS".downcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { "İS".downcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) end end @@ -65,7 +65,7 @@ describe "String#downcase" do end it "does not allow invalid options" do - lambda { "ABC".downcase(:invalid_option) }.should raise_error(ArgumentError) + -> { "ABC".downcase(:invalid_option) }.should raise_error(ArgumentError) end it "taints result when self is tainted" do @@ -126,7 +126,7 @@ describe "String#downcase!" do end it "does not allow any other additional option" do - lambda { a = "İ"; a.downcase!(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { a = "İ"; a.downcase!(:turkic, :ascii) }.should raise_error(ArgumentError) end end @@ -144,7 +144,7 @@ describe "String#downcase!" do end it "does not allow any other additional option" do - lambda { a = "İS"; a.downcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { a = "İS"; a.downcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) end end @@ -160,7 +160,7 @@ describe "String#downcase!" do end it "does not allow invalid options" do - lambda { a = "ABC"; a.downcase!(:invalid_option) }.should raise_error(ArgumentError) + -> { a = "ABC"; a.downcase!(:invalid_option) }.should raise_error(ArgumentError) end it "returns nil if no modifications were made" do @@ -170,8 +170,8 @@ describe "String#downcase!" do end it "raises a #{frozen_error_class} when self is frozen" do - lambda { "HeLlo".freeze.downcase! }.should raise_error(frozen_error_class) - lambda { "hello".freeze.downcase! }.should raise_error(frozen_error_class) + -> { "HeLlo".freeze.downcase! }.should raise_error(frozen_error_class) + -> { "hello".freeze.downcase! }.should raise_error(frozen_error_class) end it "sets the result String encoding to the source String encoding" do diff --git a/spec/ruby/core/string/dup_spec.rb b/spec/ruby/core/string/dup_spec.rb index 3c6021b5c2..d650788210 100644 --- a/spec/ruby/core/string/dup_spec.rb +++ b/spec/ruby/core/string/dup_spec.rb @@ -21,7 +21,7 @@ describe "String#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 @@ -30,7 +30,7 @@ describe "String#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 @@ -39,7 +39,7 @@ describe "String#dup" do end dup = @obj.dup - lambda { class << dup; CLONE; end }.should raise_error(NameError) + -> { class << dup; CLONE; end }.should raise_error(NameError) end it "does not modify the original string when changing dupped string" do diff --git a/spec/ruby/core/string/element_set_spec.rb b/spec/ruby/core/string/element_set_spec.rb index 1fdf72ab0f..34e122b055 100644 --- a/spec/ruby/core/string/element_set_spec.rb +++ b/spec/ruby/core/string/element_set_spec.rb @@ -27,13 +27,13 @@ describe "String#[]= with Fixnum index" do it "raises an IndexError without changing self if idx is outside of self" do str = "hello" - lambda { str[20] = "bam" }.should raise_error(IndexError) + -> { str[20] = "bam" }.should raise_error(IndexError) str.should == "hello" - lambda { str[-20] = "bam" }.should raise_error(IndexError) + -> { str[-20] = "bam" }.should raise_error(IndexError) str.should == "hello" - lambda { ""[-1] = "bam" }.should raise_error(IndexError) + -> { ""[-1] = "bam" }.should raise_error(IndexError) end # Behaviour is verified by matz in @@ -46,7 +46,7 @@ describe "String#[]= with Fixnum index" do it "raises IndexError if the string index doesn't match a position in the string" do str = "hello" - lambda { str['y'] = "bam" }.should raise_error(IndexError) + -> { str['y'] = "bam" }.should raise_error(IndexError) str.should == "hello" end @@ -54,7 +54,7 @@ describe "String#[]= with Fixnum index" do a = "hello" a.freeze - lambda { a[0] = "bam" }.should raise_error(frozen_error_class) + -> { a[0] = "bam" }.should raise_error(frozen_error_class) end it "calls to_int on index" do @@ -78,17 +78,17 @@ describe "String#[]= with Fixnum index" do end it "raises a TypeError if other_str can't be converted to a String" do - lambda { "test"[1] = [] }.should raise_error(TypeError) - lambda { "test"[1] = mock('x') }.should raise_error(TypeError) - lambda { "test"[1] = nil }.should raise_error(TypeError) + -> { "test"[1] = [] }.should raise_error(TypeError) + -> { "test"[1] = mock('x') }.should raise_error(TypeError) + -> { "test"[1] = nil }.should raise_error(TypeError) end it "raises a TypeError if passed a Fixnum replacement" do - lambda { "abc"[1] = 65 }.should raise_error(TypeError) + -> { "abc"[1] = 65 }.should raise_error(TypeError) end it "raises an IndexError if the index is greater than character size" do - lambda { "あれ"[4] = "a" }.should raise_error(IndexError) + -> { "あれ"[4] = "a" }.should raise_error(IndexError) end it "calls #to_int to convert the index" do @@ -104,14 +104,14 @@ describe "String#[]= with Fixnum index" do index = mock("string element set") index.should_receive(:to_int).and_return('1') - lambda { "abc"[index] = "d" }.should raise_error(TypeError) + -> { "abc"[index] = "d" }.should raise_error(TypeError) end it "raises an IndexError if #to_int returns a value out of range" do index = mock("string element set") index.should_receive(:to_int).and_return(4) - lambda { "ab"[index] = "c" }.should raise_error(IndexError) + -> { "ab"[index] = "c" }.should raise_error(IndexError) end it "replaces a character with a multibyte character" do @@ -142,7 +142,7 @@ describe "String#[]= with Fixnum index" do it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do str = "あれ" rep = "が".encode Encoding::EUC_JP - lambda { str[0] = rep }.should raise_error(Encoding::CompatibilityError) + -> { str[0] = rep }.should raise_error(Encoding::CompatibilityError) end end @@ -167,7 +167,7 @@ describe "String#[]= with String index" do it "raises an IndexError if the search String is not found" do str = "abcde" - lambda { str["g"] = "h" }.should raise_error(IndexError) + -> { str["g"] = "h" }.should raise_error(IndexError) end it "replaces characters with a multibyte character" do @@ -198,7 +198,7 @@ describe "String#[]= with String index" do it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do str = "あれ" rep = "が".encode Encoding::EUC_JP - lambda { str["れ"] = rep }.should raise_error(Encoding::CompatibilityError) + -> { str["れ"] = rep }.should raise_error(Encoding::CompatibilityError) end end @@ -211,7 +211,7 @@ describe "String#[]= with a Regexp index" do it "raises IndexError if the regexp index doesn't match a position in the string" do str = "hello" - lambda { str[/y/] = "bam" }.should raise_error(IndexError) + -> { str[/y/] = "bam" }.should raise_error(IndexError) str.should == "hello" end @@ -228,7 +228,7 @@ describe "String#[]= with a Regexp index" do rep = mock("string element set regexp") rep.should_not_receive(:to_str) - lambda { "abc"[/def/] = rep }.should raise_error(IndexError) + -> { "abc"[/def/] = rep }.should raise_error(IndexError) end describe "with 3 arguments" do @@ -245,7 +245,7 @@ describe "String#[]= with a Regexp index" do ref = mock("string element set regexp ref") ref.should_receive(:to_int).and_return(nil) - lambda { "abc"[/a(b)/, ref] = "x" }.should raise_error(TypeError) + -> { "abc"[/a(b)/, ref] = "x" }.should raise_error(TypeError) end it "uses the 2nd of 3 arguments as which capture should be replaced" do @@ -264,20 +264,20 @@ describe "String#[]= with a Regexp index" do rep = mock("string element set regexp") rep.should_not_receive(:to_str) - lambda { "abc"[/a(b)/, 2] = rep }.should raise_error(IndexError) + -> { "abc"[/a(b)/, 2] = rep }.should raise_error(IndexError) end it "raises IndexError if the specified capture isn't available" do str = "aaa bbb ccc" - lambda { str[/a (bbb) c/, 2] = "ddd" }.should raise_error(IndexError) - lambda { str[/a (bbb) c/, -2] = "ddd" }.should raise_error(IndexError) + -> { str[/a (bbb) c/, 2] = "ddd" }.should raise_error(IndexError) + -> { str[/a (bbb) c/, -2] = "ddd" }.should raise_error(IndexError) end describe "when the optional capture does not match" do it "raises an IndexError before setting the replacement" do str1 = "a b c" str2 = str1.dup - lambda { str2[/a (b) (Z)?/, 2] = "d" }.should raise_error(IndexError) + -> { str2[/a (b) (Z)?/, 2] = "d" }.should raise_error(IndexError) str2.should == str1 end end @@ -311,7 +311,7 @@ describe "String#[]= with a Regexp index" do it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do str = "あれ" rep = "が".encode Encoding::EUC_JP - lambda { str[/れ/] = rep }.should raise_error(Encoding::CompatibilityError) + -> { str[/れ/] = rep }.should raise_error(Encoding::CompatibilityError) end end @@ -361,11 +361,11 @@ describe "String#[]= with a Range index" do end it "raises a RangeError if negative Range begin is out of range" do - lambda { "abc"[-4..-2] = "x" }.should raise_error(RangeError) + -> { "abc"[-4..-2] = "x" }.should raise_error(RangeError) end it "raises a RangeError if positive Range begin is greater than String size" do - lambda { "abc"[4..2] = "x" }.should raise_error(RangeError) + -> { "abc"[4..2] = "x" }.should raise_error(RangeError) end it "uses the Range end as an index rather than a count" do @@ -432,7 +432,7 @@ describe "String#[]= with a Range index" do it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do str = "あれ" rep = "が".encode Encoding::EUC_JP - lambda { str[0..1] = rep }.should raise_error(Encoding::CompatibilityError) + -> { str[0..1] = rep }.should raise_error(Encoding::CompatibilityError) end end @@ -511,14 +511,14 @@ describe "String#[]= with Fixnum index, count" do index = mock("string element set index") index.should_receive(:to_int).and_return("1") - lambda { "abc"[index, 2] = "xyz" }.should raise_error(TypeError) + -> { "abc"[index, 2] = "xyz" }.should raise_error(TypeError) end it "raises a TypeError if #to_int for count does not return an Integer" do count = mock("string element set count") count.should_receive(:to_int).and_return("1") - lambda { "abc"[1, count] = "xyz" }.should raise_error(TypeError) + -> { "abc"[1, count] = "xyz" }.should raise_error(TypeError) end it "calls #to_str to convert the replacement object" do @@ -534,23 +534,23 @@ describe "String#[]= with Fixnum index, count" do r = mock("string element set replacement") r.should_receive(:to_str).and_return(nil) - lambda { "abc"[1, 1] = r }.should raise_error(TypeError) + -> { "abc"[1, 1] = r }.should raise_error(TypeError) end it "raises an IndexError if |idx| is greater than the length of the string" do - lambda { "hello"[6, 0] = "bob" }.should raise_error(IndexError) - lambda { "hello"[-6, 0] = "bob" }.should raise_error(IndexError) + -> { "hello"[6, 0] = "bob" }.should raise_error(IndexError) + -> { "hello"[-6, 0] = "bob" }.should raise_error(IndexError) end it "raises an IndexError if count < 0" do - lambda { "hello"[0, -1] = "bob" }.should raise_error(IndexError) - lambda { "hello"[1, -1] = "bob" }.should raise_error(IndexError) + -> { "hello"[0, -1] = "bob" }.should raise_error(IndexError) + -> { "hello"[1, -1] = "bob" }.should raise_error(IndexError) end it "raises a TypeError if other_str is a type other than String" do - lambda { "hello"[0, 2] = nil }.should raise_error(TypeError) - lambda { "hello"[0, 2] = [] }.should raise_error(TypeError) - lambda { "hello"[0, 2] = 33 }.should raise_error(TypeError) + -> { "hello"[0, 2] = nil }.should raise_error(TypeError) + -> { "hello"[0, 2] = [] }.should raise_error(TypeError) + -> { "hello"[0, 2] = 33 }.should raise_error(TypeError) end it "replaces characters with a multibyte character" do @@ -584,7 +584,7 @@ describe "String#[]= with Fixnum index, count" do end it "raises an IndexError if the character index is out of range of a multibyte String" do - lambda { "あれ"[3, 0] = "り" }.should raise_error(IndexError) + -> { "あれ"[3, 0] = "り" }.should raise_error(IndexError) end it "encodes the String in an encoding compatible with the replacement" do @@ -597,6 +597,6 @@ describe "String#[]= with Fixnum index, count" do it "raises an Encoding::CompatibilityError if the replacement encoding is incompatible" do str = "あれ" rep = "が".encode Encoding::EUC_JP - lambda { str[0, 1] = rep }.should raise_error(Encoding::CompatibilityError) + -> { str[0, 1] = rep }.should raise_error(Encoding::CompatibilityError) end end diff --git a/spec/ruby/core/string/encode_spec.rb b/spec/ruby/core/string/encode_spec.rb index 67a25aff04..1c0c939358 100644 --- a/spec/ruby/core/string/encode_spec.rb +++ b/spec/ruby/core/string/encode_spec.rb @@ -113,12 +113,12 @@ describe "String#encode!" do it_behaves_like :string_encode, :encode! it "raises a #{frozen_error_class} when called on a frozen String" do - lambda { "foo".freeze.encode!("euc-jp") }.should raise_error(frozen_error_class) + -> { "foo".freeze.encode!("euc-jp") }.should raise_error(frozen_error_class) end # http://redmine.ruby-lang.org/issues/show/1836 it "raises a #{frozen_error_class} when called on a frozen String when it's a no-op" do - lambda { "foo".freeze.encode!("utf-8") }.should raise_error(frozen_error_class) + -> { "foo".freeze.encode!("utf-8") }.should raise_error(frozen_error_class) end describe "when passed no options" do diff --git a/spec/ruby/core/string/end_with_spec.rb b/spec/ruby/core/string/end_with_spec.rb index 429888803c..b7a04fdefe 100644 --- a/spec/ruby/core/string/end_with_spec.rb +++ b/spec/ruby/core/string/end_with_spec.rb @@ -32,9 +32,9 @@ describe "String#end_with?" do it "ignores arguments not convertible to string" do "hello".end_with?().should be_false - lambda { "hello".end_with?(1) }.should raise_error(TypeError) - lambda { "hello".end_with?(["o"]) }.should raise_error(TypeError) - lambda { "hello".end_with?(1, nil, "o") }.should raise_error(TypeError) + -> { "hello".end_with?(1) }.should raise_error(TypeError) + -> { "hello".end_with?(["o"]) }.should raise_error(TypeError) + -> { "hello".end_with?(1, nil, "o") }.should raise_error(TypeError) end it "uses only the needed arguments" do @@ -49,7 +49,7 @@ describe "String#end_with?" do it "raises an Encoding::CompatibilityError if the encodings are incompatible" do pat = "ア".encode Encoding::EUC_JP - lambda do + -> do "あれ".end_with?(pat) end.should raise_error(Encoding::CompatibilityError) end diff --git a/spec/ruby/core/string/force_encoding_spec.rb b/spec/ruby/core/string/force_encoding_spec.rb index 7a5503de56..56d9b1e9bc 100644 --- a/spec/ruby/core/string/force_encoding_spec.rb +++ b/spec/ruby/core/string/force_encoding_spec.rb @@ -40,11 +40,11 @@ describe "String#force_encoding" do obj = mock("force_encoding") obj.should_receive(:to_str).and_return(1) - lambda { "abc".force_encoding(obj) }.should raise_error(TypeError) + -> { "abc".force_encoding(obj) }.should raise_error(TypeError) end it "raises a TypeError if passed nil" do - lambda { "abc".force_encoding(nil) }.should raise_error(TypeError) + -> { "abc".force_encoding(nil) }.should raise_error(TypeError) end it "returns self" do @@ -66,6 +66,6 @@ describe "String#force_encoding" do it "raises a #{frozen_error_class} if self is frozen" do str = "abcd".freeze - lambda { str.force_encoding(str.encoding) }.should raise_error(frozen_error_class) + -> { str.force_encoding(str.encoding) }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/getbyte_spec.rb b/spec/ruby/core/string/getbyte_spec.rb index 84286ada92..27b7d826ea 100644 --- a/spec/ruby/core/string/getbyte_spec.rb +++ b/spec/ruby/core/string/getbyte_spec.rb @@ -59,11 +59,11 @@ describe "String#getbyte" do end it "raises an ArgumentError unless given one argument" do - lambda { "glark".getbyte }.should raise_error(ArgumentError) - lambda { "food".getbyte(0,0) }.should raise_error(ArgumentError) + -> { "glark".getbyte }.should raise_error(ArgumentError) + -> { "food".getbyte(0,0) }.should raise_error(ArgumentError) end it "raises a TypeError unless its argument can be coerced into an Integer" do - lambda { "a".getbyte('a') }.should raise_error(TypeError) + -> { "a".getbyte('a') }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/string/gsub_spec.rb b/spec/ruby/core/string/gsub_spec.rb index 29b65c72a7..cd66a4f875 100644 --- a/spec/ruby/core/string/gsub_spec.rb +++ b/spec/ruby/core/string/gsub_spec.rb @@ -214,9 +214,9 @@ describe "String#gsub with pattern and replacement" do end it "raises a TypeError when pattern can't be converted to a string" do - lambda { "hello".gsub([], "x") }.should raise_error(TypeError) - lambda { "hello".gsub(Object.new, "x") }.should raise_error(TypeError) - lambda { "hello".gsub(nil, "x") }.should raise_error(TypeError) + -> { "hello".gsub([], "x") }.should raise_error(TypeError) + -> { "hello".gsub(Object.new, "x") }.should raise_error(TypeError) + -> { "hello".gsub(nil, "x") }.should raise_error(TypeError) end it "tries to convert replacement to a string using to_str" do @@ -227,9 +227,9 @@ describe "String#gsub with pattern and replacement" do end it "raises a TypeError when replacement can't be converted to a string" do - lambda { "hello".gsub(/[aeiou]/, []) }.should raise_error(TypeError) - lambda { "hello".gsub(/[aeiou]/, Object.new) }.should raise_error(TypeError) - lambda { "hello".gsub(/[aeiou]/, nil) }.should raise_error(TypeError) + -> { "hello".gsub(/[aeiou]/, []) }.should raise_error(TypeError) + -> { "hello".gsub(/[aeiou]/, Object.new) }.should raise_error(TypeError) + -> { "hello".gsub(/[aeiou]/, nil) }.should raise_error(TypeError) end it "returns subclass instances when called on a subclass" do @@ -298,7 +298,7 @@ describe "String#gsub with pattern and Hash" do it "uses the hash's value set from default_proc for missing keys" do hsh = {} - hsh.default_proc = lambda { |k,v| 'lamb' } + hsh.default_proc = -> k, v { 'lamb' } "food!".gsub(/./, hsh).should == "lamblamblamblamblamb" end @@ -387,7 +387,7 @@ describe "String#gsub! with pattern and Hash" do it "uses the hash's value set from default_proc for missing keys" do hsh = {} - hsh.default_proc = lambda { |k,v| 'lamb' } + hsh.default_proc = -> k, v { 'lamb' } "food!".gsub!(/./, hsh).should == "lamblamblamblamblamb" end @@ -536,8 +536,8 @@ describe "String#gsub with pattern and block" do s = "hllëllo" s2 = "hellö" - lambda { s.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) - lambda { s2.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) + -> { s.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) + -> { s2.gsub(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) end it "replaces the incompatible part properly even if the encodings are not compatible" do @@ -549,7 +549,7 @@ describe "String#gsub with pattern and block" do not_supported_on :opal do it "raises an ArgumentError if encoding is not valid" do x92 = [0x92].pack('C').force_encoding('utf-8') - lambda { "a#{x92}b".gsub(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError) + -> { "a#{x92}b".gsub(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError) end end end @@ -607,9 +607,9 @@ describe "String#gsub! with pattern and replacement" do s = "hello" s.freeze - lambda { s.gsub!(/ROAR/, "x") }.should raise_error(frozen_error_class) - lambda { s.gsub!(/e/, "e") }.should raise_error(frozen_error_class) - lambda { s.gsub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class) + -> { s.gsub!(/ROAR/, "x") }.should raise_error(frozen_error_class) + -> { s.gsub!(/e/, "e") }.should raise_error(frozen_error_class) + -> { s.gsub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class) end end @@ -644,9 +644,9 @@ describe "String#gsub! with pattern and block" do s = "hello" s.freeze - lambda { s.gsub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class) - lambda { s.gsub!(/e/) { "e" } }.should raise_error(frozen_error_class) - lambda { s.gsub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class) + -> { s.gsub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class) + -> { s.gsub!(/e/) { "e" } }.should raise_error(frozen_error_class) + -> { s.gsub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class) end it "uses the compatible encoding if they are compatible" do @@ -661,8 +661,8 @@ describe "String#gsub! with pattern and block" do s = "hllëllo" s2 = "hellö" - lambda { s.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) - lambda { s2.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) + -> { s.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) + -> { s2.gsub!(/l/) { |bar| "Русский".force_encoding("iso-8859-5") } }.should raise_error(Encoding::CompatibilityError) end it "replaces the incompatible part properly even if the encodings are not compatible" do @@ -674,7 +674,7 @@ describe "String#gsub! with pattern and block" do not_supported_on :opal do it "raises an ArgumentError if encoding is not valid" do x92 = [0x92].pack('C').force_encoding('utf-8') - lambda { "a#{x92}b".gsub!(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError) + -> { "a#{x92}b".gsub!(/[^\x00-\x7f]/u, '') }.should raise_error(ArgumentError) end end end diff --git a/spec/ruby/core/string/include_spec.rb b/spec/ruby/core/string/include_spec.rb index 03ef3ba802..e32eb17c29 100644 --- a/spec/ruby/core/string/include_spec.rb +++ b/spec/ruby/core/string/include_spec.rb @@ -21,14 +21,14 @@ describe "String#include? with String" do end it "raises a TypeError if other can't be converted to string" do - lambda { "hello".include?([]) }.should raise_error(TypeError) - lambda { "hello".include?('h'.ord) }.should raise_error(TypeError) - lambda { "hello".include?(mock('x')) }.should raise_error(TypeError) + -> { "hello".include?([]) }.should raise_error(TypeError) + -> { "hello".include?('h'.ord) }.should raise_error(TypeError) + -> { "hello".include?(mock('x')) }.should raise_error(TypeError) end it "raises an Encoding::CompatibilityError if the encodings are incompatible" do pat = "ア".encode Encoding::EUC_JP - lambda do + -> do "あれ".include?(pat) end.should raise_error(Encoding::CompatibilityError) end diff --git a/spec/ruby/core/string/index_spec.rb b/spec/ruby/core/string/index_spec.rb index fb5f4e75e7..ca62911db0 100644 --- a/spec/ruby/core/string/index_spec.rb +++ b/spec/ruby/core/string/index_spec.rb @@ -4,15 +4,15 @@ require_relative 'fixtures/classes' describe "String#index" do it "raises a TypeError if passed nil" do - lambda { "abc".index nil }.should raise_error(TypeError) + -> { "abc".index nil }.should raise_error(TypeError) end it "raises a TypeError if passed a boolean" do - lambda { "abc".index true }.should raise_error(TypeError) + -> { "abc".index true }.should raise_error(TypeError) end it "raises a TypeError if passed a Symbol" do - lambda { "abc".index :a }.should raise_error(TypeError) + -> { "abc".index :a }.should raise_error(TypeError) end it "calls #to_str to convert the first argument" do @@ -28,7 +28,7 @@ describe "String#index" do end it "raises a TypeError if passed a Fixnum" do - lambda { "abc".index 97 }.should raise_error(TypeError) + -> { "abc".index 97 }.should raise_error(TypeError) end end @@ -154,7 +154,7 @@ describe "String#index with String" do it "raises an Encoding::CompatibilityError if the encodings are incompatible" do char = "れ".encode Encoding::EUC_JP - lambda do + -> do "あれ".index char end.should raise_error(Encoding::CompatibilityError) end @@ -305,7 +305,7 @@ describe "String#index with Regexp" do it "raises an Encoding::CompatibilityError if the encodings are incompatible" do re = Regexp.new "れ".encode(Encoding::EUC_JP) - lambda do + -> do "あれ".index re end.should raise_error(Encoding::CompatibilityError) end diff --git a/spec/ruby/core/string/insert_spec.rb b/spec/ruby/core/string/insert_spec.rb index d5b9026f3d..588b8ab272 100644 --- a/spec/ruby/core/string/insert_spec.rb +++ b/spec/ruby/core/string/insert_spec.rb @@ -23,8 +23,8 @@ describe "String#insert with index, other" do end it "raises an IndexError if the index is beyond string" do - lambda { "abcd".insert(5, 'X') }.should raise_error(IndexError) - lambda { "abcd".insert(-6, 'X') }.should raise_error(IndexError) + -> { "abcd".insert(5, 'X') }.should raise_error(IndexError) + -> { "abcd".insert(-6, 'X') }.should raise_error(IndexError) end it "converts index to an integer using to_int" do @@ -52,15 +52,15 @@ describe "String#insert with index, other" do end it "raises a TypeError if other can't be converted to string" do - lambda { "abcd".insert(-6, Object.new)}.should raise_error(TypeError) - lambda { "abcd".insert(-6, []) }.should raise_error(TypeError) - lambda { "abcd".insert(-6, mock('x')) }.should raise_error(TypeError) + -> { "abcd".insert(-6, Object.new)}.should raise_error(TypeError) + -> { "abcd".insert(-6, []) }.should raise_error(TypeError) + -> { "abcd".insert(-6, mock('x')) }.should raise_error(TypeError) end it "raises a #{frozen_error_class} if self is frozen" do str = "abcd".freeze - lambda { str.insert(4, '') }.should raise_error(frozen_error_class) - lambda { str.insert(4, 'X') }.should raise_error(frozen_error_class) + -> { str.insert(4, '') }.should raise_error(frozen_error_class) + -> { str.insert(4, 'X') }.should raise_error(frozen_error_class) end it "inserts a character into a multibyte encoded string" do @@ -75,7 +75,7 @@ describe "String#insert with index, other" do it "raises an Encoding::CompatibilityError if the encodings are incompatible" do pat = "ア".encode Encoding::EUC_JP - lambda do + -> do "あれ".insert 0, pat end.should raise_error(Encoding::CompatibilityError) end diff --git a/spec/ruby/core/string/ljust_spec.rb b/spec/ruby/core/string/ljust_spec.rb index a8160c727b..ed4cb86859 100644 --- a/spec/ruby/core/string/ljust_spec.rb +++ b/spec/ruby/core/string/ljust_spec.rb @@ -49,10 +49,10 @@ describe "String#ljust with length, padding" do end it "raises a TypeError when length can't be converted to an integer" do - lambda { "hello".ljust("x") }.should raise_error(TypeError) - lambda { "hello".ljust("x", "y") }.should raise_error(TypeError) - lambda { "hello".ljust([]) }.should raise_error(TypeError) - lambda { "hello".ljust(mock('x')) }.should raise_error(TypeError) + -> { "hello".ljust("x") }.should raise_error(TypeError) + -> { "hello".ljust("x", "y") }.should raise_error(TypeError) + -> { "hello".ljust([]) }.should raise_error(TypeError) + -> { "hello".ljust(mock('x')) }.should raise_error(TypeError) end it "tries to convert padstr to a string using to_str" do @@ -63,13 +63,13 @@ describe "String#ljust with length, padding" do end it "raises a TypeError when padstr can't be converted" do - lambda { "hello".ljust(20, []) }.should raise_error(TypeError) - lambda { "hello".ljust(20, Object.new)}.should raise_error(TypeError) - lambda { "hello".ljust(20, mock('x')) }.should raise_error(TypeError) + -> { "hello".ljust(20, []) }.should raise_error(TypeError) + -> { "hello".ljust(20, Object.new)}.should raise_error(TypeError) + -> { "hello".ljust(20, mock('x')) }.should raise_error(TypeError) end it "raises an ArgumentError when padstr is empty" do - lambda { "hello".ljust(10, '') }.should raise_error(ArgumentError) + -> { "hello".ljust(10, '') }.should raise_error(ArgumentError) end it "returns subclass instances when called on subclasses" do @@ -106,7 +106,7 @@ describe "String#ljust with length, padding" do it "raises an Encoding::CompatibilityError if the encodings are incompatible" do pat = "ア".encode Encoding::EUC_JP - lambda do + -> do "あれ".ljust 5, pat end.should raise_error(Encoding::CompatibilityError) end diff --git a/spec/ruby/core/string/lstrip_spec.rb b/spec/ruby/core/string/lstrip_spec.rb index ecfc89dd6b..7f9363d398 100644 --- a/spec/ruby/core/string/lstrip_spec.rb +++ b/spec/ruby/core/string/lstrip_spec.rb @@ -39,12 +39,12 @@ describe "String#lstrip!" do end it "raises a #{frozen_error_class} on a frozen instance that is modified" do - lambda { " hello ".freeze.lstrip! }.should raise_error(frozen_error_class) + -> { " hello ".freeze.lstrip! }.should raise_error(frozen_error_class) end # see [ruby-core:23657] it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do - lambda { "hello".freeze.lstrip! }.should raise_error(frozen_error_class) - lambda { "".freeze.lstrip! }.should raise_error(frozen_error_class) + -> { "hello".freeze.lstrip! }.should raise_error(frozen_error_class) + -> { "".freeze.lstrip! }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/match_spec.rb b/spec/ruby/core/string/match_spec.rb index c5505fd382..78b94baa44 100644 --- a/spec/ruby/core/string/match_spec.rb +++ b/spec/ruby/core/string/match_spec.rb @@ -19,8 +19,8 @@ describe "String#=~" do end it "raises a TypeError if a obj is a string" do - lambda { "some string" =~ "another string" }.should raise_error(TypeError) - lambda { "a" =~ StringSpecs::MyString.new("b") }.should raise_error(TypeError) + -> { "some string" =~ "another string" }.should raise_error(TypeError) + -> { "a" =~ StringSpecs::MyString.new("b") }.should raise_error(TypeError) end it "invokes obj.=~ with self if obj is neither a string nor regexp" do @@ -107,9 +107,9 @@ describe "String#match" do end it "raises a TypeError if pattern is not a regexp or a string" do - lambda { 'hello'.match(10) }.should raise_error(TypeError) + -> { 'hello'.match(10) }.should raise_error(TypeError) not_supported_on :opal do - lambda { 'hello'.match(:ell) }.should raise_error(TypeError) + -> { 'hello'.match(:ell) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/string/modulo_spec.rb b/spec/ruby/core/string/modulo_spec.rb index fc4972b9d7..0ac0963403 100644 --- a/spec/ruby/core/string/modulo_spec.rb +++ b/spec/ruby/core/string/modulo_spec.rb @@ -4,7 +4,7 @@ require_relative '../../shared/hash/key_error' describe "String#%" do context "when key is missing from passed-in hash" do - it_behaves_like :key_error, -> (obj, key) { "%{#{key}}" % obj }, { a: 5 } + it_behaves_like :key_error, -> obj, key { "%{#{key}}" % obj }, { a: 5 } end it "formats multiple expressions" do @@ -32,7 +32,7 @@ describe "String#%" do end it "raises if a compatible encoding can't be found" do - lambda { "hello %s".encode("utf-8") % "world".encode("UTF-16LE") }.should raise_error(Encoding::CompatibilityError) + -> { "hello %s".encode("utf-8") % "world".encode("UTF-16LE") }.should raise_error(Encoding::CompatibilityError) end end @@ -45,8 +45,8 @@ describe "String#%" do ruby_version_is "2.5" do it "raises an error if single % appears at the end" do - lambda { ("%" % []) }.should raise_error(ArgumentError) - lambda { ("foo%" % [])}.should raise_error(ArgumentError) + -> { ("%" % []) }.should raise_error(ArgumentError) + -> { ("foo%" % [])}.should raise_error(ArgumentError) end end @@ -63,18 +63,18 @@ describe "String#%" do end it "raises an error if single % appears anywhere else" do - lambda { (" % " % []) }.should raise_error(ArgumentError) - lambda { ("foo%quux" % []) }.should raise_error(ArgumentError) + -> { (" % " % []) }.should raise_error(ArgumentError) + -> { ("foo%quux" % []) }.should raise_error(ArgumentError) end it "raises an error if NULL or \\n appear anywhere else in the format string" do begin old_debug, $DEBUG = $DEBUG, false - lambda { "%.\n3f" % 1.2 }.should raise_error(ArgumentError) - lambda { "%.3\nf" % 1.2 }.should raise_error(ArgumentError) - lambda { "%.\03f" % 1.2 }.should raise_error(ArgumentError) - lambda { "%.3\0f" % 1.2 }.should raise_error(ArgumentError) + -> { "%.\n3f" % 1.2 }.should raise_error(ArgumentError) + -> { "%.3\nf" % 1.2 }.should raise_error(ArgumentError) + -> { "%.\03f" % 1.2 }.should raise_error(ArgumentError) + -> { "%.3\0f" % 1.2 }.should raise_error(ArgumentError) ensure $DEBUG = old_debug end @@ -99,8 +99,8 @@ describe "String#%" do s = $stderr $stderr = IOStub.new - lambda { "" % [1, 2, 3] }.should raise_error(ArgumentError) - lambda { "%s" % [1, 2, 3] }.should raise_error(ArgumentError) + -> { "" % [1, 2, 3] }.should raise_error(ArgumentError) + -> { "%s" % [1, 2, 3] }.should raise_error(ArgumentError) ensure $DEBUG = old_debug $stderr = s @@ -125,21 +125,21 @@ describe "String#%" do end it "raises an ArgumentError when given invalid argument specifiers" do - lambda { "%1" % [] }.should raise_error(ArgumentError) - lambda { "%+" % [] }.should raise_error(ArgumentError) - lambda { "%-" % [] }.should raise_error(ArgumentError) - lambda { "%#" % [] }.should raise_error(ArgumentError) - lambda { "%0" % [] }.should raise_error(ArgumentError) - lambda { "%*" % [] }.should raise_error(ArgumentError) - lambda { "%." % [] }.should raise_error(ArgumentError) - lambda { "%_" % [] }.should raise_error(ArgumentError) - lambda { "%0$s" % "x" }.should raise_error(ArgumentError) - lambda { "%*0$s" % [5, "x"] }.should raise_error(ArgumentError) - lambda { "%*1$.*0$1$s" % [1, 2, 3] }.should raise_error(ArgumentError) + -> { "%1" % [] }.should raise_error(ArgumentError) + -> { "%+" % [] }.should raise_error(ArgumentError) + -> { "%-" % [] }.should raise_error(ArgumentError) + -> { "%#" % [] }.should raise_error(ArgumentError) + -> { "%0" % [] }.should raise_error(ArgumentError) + -> { "%*" % [] }.should raise_error(ArgumentError) + -> { "%." % [] }.should raise_error(ArgumentError) + -> { "%_" % [] }.should raise_error(ArgumentError) + -> { "%0$s" % "x" }.should raise_error(ArgumentError) + -> { "%*0$s" % [5, "x"] }.should raise_error(ArgumentError) + -> { "%*1$.*0$1$s" % [1, 2, 3] }.should raise_error(ArgumentError) end it "raises an ArgumentError when multiple positional argument tokens are given for one format specifier" do - lambda { "%1$1$s" % "foo" }.should raise_error(ArgumentError) + -> { "%1$1$s" % "foo" }.should raise_error(ArgumentError) end it "respects positional arguments and precision tokens given for one format specifier" do @@ -155,36 +155,36 @@ describe "String#%" do end it "raises an ArgumentError when multiple width star tokens are given for one format specifier" do - lambda { "%**s" % [5, 5, 5] }.should raise_error(ArgumentError) + -> { "%**s" % [5, 5, 5] }.should raise_error(ArgumentError) end it "raises an ArgumentError when a width star token is seen after a width token" do - lambda { "%5*s" % [5, 5] }.should raise_error(ArgumentError) + -> { "%5*s" % [5, 5] }.should raise_error(ArgumentError) end it "raises an ArgumentError when multiple precision tokens are given" do - lambda { "%.5.5s" % 5 }.should raise_error(ArgumentError) - lambda { "%.5.*s" % [5, 5] }.should raise_error(ArgumentError) - lambda { "%.*.5s" % [5, 5] }.should raise_error(ArgumentError) + -> { "%.5.5s" % 5 }.should raise_error(ArgumentError) + -> { "%.5.*s" % [5, 5] }.should raise_error(ArgumentError) + -> { "%.*.5s" % [5, 5] }.should raise_error(ArgumentError) end it "raises an ArgumentError when there are less arguments than format specifiers" do ("foo" % []).should == "foo" - lambda { "%s" % [] }.should raise_error(ArgumentError) - lambda { "%s %s" % [1] }.should raise_error(ArgumentError) + -> { "%s" % [] }.should raise_error(ArgumentError) + -> { "%s %s" % [1] }.should raise_error(ArgumentError) end it "raises an ArgumentError when absolute and relative argument numbers are mixed" do - lambda { "%s %1$s" % "foo" }.should raise_error(ArgumentError) - lambda { "%1$s %s" % "foo" }.should raise_error(ArgumentError) + -> { "%s %1$s" % "foo" }.should raise_error(ArgumentError) + -> { "%1$s %s" % "foo" }.should raise_error(ArgumentError) - lambda { "%s %2$s" % ["foo", "bar"] }.should raise_error(ArgumentError) - lambda { "%2$s %s" % ["foo", "bar"] }.should raise_error(ArgumentError) + -> { "%s %2$s" % ["foo", "bar"] }.should raise_error(ArgumentError) + -> { "%2$s %s" % ["foo", "bar"] }.should raise_error(ArgumentError) - lambda { "%*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) - lambda { "%*.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) - lambda { "%*2$.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) - lambda { "%*.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) + -> { "%*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) + -> { "%*.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) + -> { "%*2$.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) + -> { "%*.*2$s" % [5, 5, 5] }.should raise_error(ArgumentError) end it "allows reuse of the one argument multiple via absolute argument numbers" do @@ -193,13 +193,13 @@ describe "String#%" do end it "always interprets an array argument as a list of argument parameters" do - lambda { "%p" % [] }.should raise_error(ArgumentError) + -> { "%p" % [] }.should raise_error(ArgumentError) ("%p" % [1]).should == "1" ("%p %p" % [1, 2]).should == "1 2" end it "always interprets an array subclass argument as a list of argument parameters" do - lambda { "%p" % StringSpecs::MyArray[] }.should raise_error(ArgumentError) + -> { "%p" % StringSpecs::MyArray[] }.should raise_error(ArgumentError) ("%p" % StringSpecs::MyArray[1]).should == "1" ("%p %p" % StringSpecs::MyArray[1, 2]).should == "1 2" end @@ -270,7 +270,7 @@ describe "String#%" do x = mock("string modulo to_ary") x.should_receive(:to_ary).and_return("x") - lambda { "%s" % x }.should raise_error(TypeError) + -> { "%s" % x }.should raise_error(TypeError) end it "tries to convert the argument to Array by calling #to_ary" do @@ -377,7 +377,7 @@ describe "String#%" do ("%*c" % [10, 3]).should == " \003" ("%c" % 42).should == "*" - lambda { "%c" % Object }.should raise_error(TypeError) + -> { "%c" % Object }.should raise_error(TypeError) end it "supports single character strings as argument for %c" do @@ -385,7 +385,7 @@ describe "String#%" do end it "raises an exception for multiple character strings as argument for %c" do - lambda { "%c" % 'AA' }.should raise_error(ArgumentError) + -> { "%c" % 'AA' }.should raise_error(ArgumentError) end it "calls to_str on argument for %c formats" do @@ -619,7 +619,7 @@ describe "String#%" do # MRI crashes on this one. # See http://groups.google.com/group/ruby-core-google/t/c285c18cd94c216d it "raises an ArgumentError for huge precisions for %s" do - block = lambda { "%.25555555555555555555555555555555555555s" % "hello world" } + block = -> { "%.25555555555555555555555555555555555555s" % "hello world" } block.should raise_error(ArgumentError) end @@ -712,19 +712,19 @@ describe "String#%" do (format % "0b1101").should == (format % Kernel.Integer("0b1101")) (format % "0b1101_0000").should == (format % Kernel.Integer("0b1101_0000")) (format % "0777").should == (format % Kernel.Integer("0777")) - lambda { + -> { # see [ruby-core:14139] for more details (format % "0777").should == (format % Kernel.Integer("0777")) }.should_not raise_error(ArgumentError) - lambda { format % "0__7_7_7" }.should raise_error(ArgumentError) + -> { format % "0__7_7_7" }.should raise_error(ArgumentError) - lambda { format % "" }.should raise_error(ArgumentError) - lambda { format % "x" }.should raise_error(ArgumentError) - lambda { format % "5x" }.should raise_error(ArgumentError) - lambda { format % "08" }.should raise_error(ArgumentError) - lambda { format % "0b2" }.should raise_error(ArgumentError) - lambda { format % "123__456" }.should raise_error(ArgumentError) + -> { format % "" }.should raise_error(ArgumentError) + -> { format % "x" }.should raise_error(ArgumentError) + -> { format % "5x" }.should raise_error(ArgumentError) + -> { format % "08" }.should raise_error(ArgumentError) + -> { format % "0b2" }.should raise_error(ArgumentError) + -> { format % "123__456" }.should raise_error(ArgumentError) obj = mock('5') obj.should_receive(:to_i).and_return(5) @@ -757,15 +757,15 @@ describe "String#%" do (format % "0777").should == (format % 777) - lambda { format % "" }.should raise_error(ArgumentError) - lambda { format % "x" }.should raise_error(ArgumentError) - lambda { format % "." }.should raise_error(ArgumentError) - lambda { format % "10." }.should raise_error(ArgumentError) - lambda { format % "5x" }.should raise_error(ArgumentError) - lambda { format % "0b1" }.should raise_error(ArgumentError) - lambda { format % "10e10.5" }.should raise_error(ArgumentError) - lambda { format % "10__10" }.should raise_error(ArgumentError) - lambda { format % "10.10__10" }.should raise_error(ArgumentError) + -> { format % "" }.should raise_error(ArgumentError) + -> { format % "x" }.should raise_error(ArgumentError) + -> { format % "." }.should raise_error(ArgumentError) + -> { format % "10." }.should raise_error(ArgumentError) + -> { format % "5x" }.should raise_error(ArgumentError) + -> { format % "0b1" }.should raise_error(ArgumentError) + -> { format % "10e10.5" }.should raise_error(ArgumentError) + -> { format % "10__10" }.should raise_error(ArgumentError) + -> { format % "10.10__10" }.should raise_error(ArgumentError) obj = mock('5.0') obj.should_receive(:to_f).and_return(5.0) @@ -787,7 +787,7 @@ describe "String#%" do end it "should raise ArgumentError if no hash given" do - lambda {"%{foo}" % []}.should raise_error(ArgumentError) + -> {"%{foo}" % []}.should raise_error(ArgumentError) end end @@ -797,11 +797,11 @@ describe "String#%" do end it "raises KeyError if key is missing from passed-in hash" do - lambda {"%<foo>d" % {}}.should raise_error(KeyError) + -> {"%<foo>d" % {}}.should raise_error(KeyError) end it "should raise ArgumentError if no hash given" do - lambda {"%<foo>" % []}.should raise_error(ArgumentError) + -> {"%<foo>" % []}.should raise_error(ArgumentError) end end end diff --git a/spec/ruby/core/string/multiply_spec.rb b/spec/ruby/core/string/multiply_spec.rb index 7d887fd93a..c15f670c46 100644 --- a/spec/ruby/core/string/multiply_spec.rb +++ b/spec/ruby/core/string/multiply_spec.rb @@ -3,5 +3,5 @@ require_relative 'fixtures/classes' require_relative '../../shared/string/times' describe "String#*" do - it_behaves_like :string_times, :*, ->(str, times) { str * times } + it_behaves_like :string_times, :*, -> str, times { str * times } end diff --git a/spec/ruby/core/string/new_spec.rb b/spec/ruby/core/string/new_spec.rb index f65daf2dd2..ca678f5323 100644 --- a/spec/ruby/core/string/new_spec.rb +++ b/spec/ruby/core/string/new_spec.rb @@ -51,8 +51,8 @@ describe "String.new" do end it "raises TypeError on inconvertible object" do - lambda { String.new 5 }.should raise_error(TypeError) - lambda { String.new nil }.should raise_error(TypeError) + -> { String.new 5 }.should raise_error(TypeError) + -> { String.new nil }.should raise_error(TypeError) end it "returns a binary String" do diff --git a/spec/ruby/core/string/ord_spec.rb b/spec/ruby/core/string/ord_spec.rb index 63f9815ea9..0f5a3f6a37 100644 --- a/spec/ruby/core/string/ord_spec.rb +++ b/spec/ruby/core/string/ord_spec.rb @@ -23,6 +23,6 @@ describe "String#ord" do end it "raises an ArgumentError if called on an empty String" do - lambda { ''.ord }.should raise_error(ArgumentError) + -> { ''.ord }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/string/partition_spec.rb b/spec/ruby/core/string/partition_spec.rb index f7ab5f85aa..996368d6a4 100644 --- a/spec/ruby/core/string/partition_spec.rb +++ b/spec/ruby/core/string/partition_spec.rb @@ -28,8 +28,8 @@ describe "String#partition with String" do end it "raises an error if not convertible to string" do - lambda{ "hello".partition(5) }.should raise_error(TypeError) - lambda{ "hello".partition(nil) }.should raise_error(TypeError) + ->{ "hello".partition(5) }.should raise_error(TypeError) + ->{ "hello".partition(nil) }.should raise_error(TypeError) end it "takes precedence over a given block" do diff --git a/spec/ruby/core/string/percent_spec.rb b/spec/ruby/core/string/percent_spec.rb index e701def344..e3460522b1 100644 --- a/spec/ruby/core/string/percent_spec.rb +++ b/spec/ruby/core/string/percent_spec.rb @@ -3,11 +3,11 @@ require_relative '../kernel/shared/sprintf' require_relative '../kernel/shared/sprintf_encoding' describe "String#%" do - it_behaves_like :kernel_sprintf, -> (format, *args) { + it_behaves_like :kernel_sprintf, -> format, *args { format % args } - it_behaves_like :kernel_sprintf_encoding, -> (format, *args) { + it_behaves_like :kernel_sprintf_encoding, -> format, *args { format % args } end diff --git a/spec/ruby/core/string/plus_spec.rb b/spec/ruby/core/string/plus_spec.rb index a9f287a82b..b8e3bf0a4b 100644 --- a/spec/ruby/core/string/plus_spec.rb +++ b/spec/ruby/core/string/plus_spec.rb @@ -18,8 +18,8 @@ describe "String#+" do end it "raises a TypeError when given any object that fails #to_str" do - lambda { "" + Object.new }.should raise_error(TypeError) - lambda { "" + 65 }.should raise_error(TypeError) + -> { "" + Object.new }.should raise_error(TypeError) + -> { "" + 65 }.should raise_error(TypeError) end it "doesn't return subclass instances" do diff --git a/spec/ruby/core/string/prepend_spec.rb b/spec/ruby/core/string/prepend_spec.rb index e2c29de836..485c578e2d 100644 --- a/spec/ruby/core/string/prepend_spec.rb +++ b/spec/ruby/core/string/prepend_spec.rb @@ -16,16 +16,16 @@ describe "String#prepend" do end it "raises a TypeError if the given argument can't be converted to a String" do - lambda { "hello ".prepend [] }.should raise_error(TypeError) - lambda { 'hello '.prepend mock('x') }.should raise_error(TypeError) + -> { "hello ".prepend [] }.should raise_error(TypeError) + -> { 'hello '.prepend mock('x') }.should raise_error(TypeError) end it "raises a #{frozen_error_class} when self is frozen" do a = "hello" a.freeze - lambda { a.prepend "" }.should raise_error(frozen_error_class) - lambda { a.prepend "test" }.should raise_error(frozen_error_class) + -> { a.prepend "" }.should raise_error(frozen_error_class) + -> { a.prepend "test" }.should raise_error(frozen_error_class) end it "works when given a subclass instance" do diff --git a/spec/ruby/core/string/reverse_spec.rb b/spec/ruby/core/string/reverse_spec.rb index f2a8b64d47..3941ea0521 100644 --- a/spec/ruby/core/string/reverse_spec.rb +++ b/spec/ruby/core/string/reverse_spec.rb @@ -31,13 +31,13 @@ describe "String#reverse!" do end it "raises a #{frozen_error_class} on a frozen instance that is modified" do - lambda { "anna".freeze.reverse! }.should raise_error(frozen_error_class) - lambda { "hello".freeze.reverse! }.should raise_error(frozen_error_class) + -> { "anna".freeze.reverse! }.should raise_error(frozen_error_class) + -> { "hello".freeze.reverse! }.should raise_error(frozen_error_class) end # see [ruby-core:23666] it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do - lambda { "".freeze.reverse! }.should raise_error(frozen_error_class) + -> { "".freeze.reverse! }.should raise_error(frozen_error_class) end it "reverses a string with multi byte characters" do diff --git a/spec/ruby/core/string/rindex_spec.rb b/spec/ruby/core/string/rindex_spec.rb index f74c0115cc..e021486bc2 100644 --- a/spec/ruby/core/string/rindex_spec.rb +++ b/spec/ruby/core/string/rindex_spec.rb @@ -6,15 +6,15 @@ require_relative 'fixtures/utf-8-encoding' describe "String#rindex with object" do it "raises a TypeError if obj isn't a String, Fixnum or Regexp" do not_supported_on :opal do - lambda { "hello".rindex(:sym) }.should raise_error(TypeError) + -> { "hello".rindex(:sym) }.should raise_error(TypeError) end - lambda { "hello".rindex(mock('x')) }.should raise_error(TypeError) + -> { "hello".rindex(mock('x')) }.should raise_error(TypeError) end it "doesn't try to convert obj to an integer via to_int" do obj = mock('x') obj.should_not_receive(:to_int) - lambda { "hello".rindex(obj) }.should raise_error(TypeError) + -> { "hello".rindex(obj) }.should raise_error(TypeError) end it "tries to convert obj to a string via to_str" do @@ -190,7 +190,7 @@ describe "String#rindex with String" do end it "raises a TypeError when given offset is nil" do - lambda { "str".rindex("st", nil) }.should raise_error(TypeError) + -> { "str".rindex("st", nil) }.should raise_error(TypeError) end end @@ -344,7 +344,7 @@ describe "String#rindex with Regexp" do end it "raises a TypeError when given offset is nil" do - lambda { "str".rindex(/../, nil) }.should raise_error(TypeError) + -> { "str".rindex(/../, nil) }.should raise_error(TypeError) end it "returns the reverse character index of a multibyte character" do @@ -359,7 +359,7 @@ describe "String#rindex with Regexp" do it "raises an Encoding::CompatibilityError if the encodings are incompatible" do re = Regexp.new "れ".encode(Encoding::EUC_JP) - lambda do + -> do "あれ".rindex re end.should raise_error(Encoding::CompatibilityError) end diff --git a/spec/ruby/core/string/rjust_spec.rb b/spec/ruby/core/string/rjust_spec.rb index 2821b018e8..1ba298e8f3 100644 --- a/spec/ruby/core/string/rjust_spec.rb +++ b/spec/ruby/core/string/rjust_spec.rb @@ -49,10 +49,10 @@ describe "String#rjust with length, padding" do end it "raises a TypeError when length can't be converted to an integer" do - lambda { "hello".rjust("x") }.should raise_error(TypeError) - lambda { "hello".rjust("x", "y") }.should raise_error(TypeError) - lambda { "hello".rjust([]) }.should raise_error(TypeError) - lambda { "hello".rjust(mock('x')) }.should raise_error(TypeError) + -> { "hello".rjust("x") }.should raise_error(TypeError) + -> { "hello".rjust("x", "y") }.should raise_error(TypeError) + -> { "hello".rjust([]) }.should raise_error(TypeError) + -> { "hello".rjust(mock('x')) }.should raise_error(TypeError) end it "tries to convert padstr to a string using to_str" do @@ -63,13 +63,13 @@ describe "String#rjust with length, padding" do end it "raises a TypeError when padstr can't be converted" do - lambda { "hello".rjust(20, []) }.should raise_error(TypeError) - lambda { "hello".rjust(20, Object.new)}.should raise_error(TypeError) - lambda { "hello".rjust(20, mock('x')) }.should raise_error(TypeError) + -> { "hello".rjust(20, []) }.should raise_error(TypeError) + -> { "hello".rjust(20, Object.new)}.should raise_error(TypeError) + -> { "hello".rjust(20, mock('x')) }.should raise_error(TypeError) end it "raises an ArgumentError when padstr is empty" do - lambda { "hello".rjust(10, '') }.should raise_error(ArgumentError) + -> { "hello".rjust(10, '') }.should raise_error(ArgumentError) end it "returns subclass instances when called on subclasses" do @@ -106,7 +106,7 @@ describe "String#rjust with length, padding" do it "raises an Encoding::CompatibilityError if the encodings are incompatible" do pat = "ア".encode Encoding::EUC_JP - lambda do + -> do "あれ".rjust 5, pat end.should raise_error(Encoding::CompatibilityError) end diff --git a/spec/ruby/core/string/rpartition_spec.rb b/spec/ruby/core/string/rpartition_spec.rb index a5222e0a2a..c6428636f6 100644 --- a/spec/ruby/core/string/rpartition_spec.rb +++ b/spec/ruby/core/string/rpartition_spec.rb @@ -27,7 +27,7 @@ describe "String#rpartition with String" do end it "raises an error if not convertible to string" do - lambda{ "hello".rpartition(5) }.should raise_error(TypeError) - lambda{ "hello".rpartition(nil) }.should raise_error(TypeError) + ->{ "hello".rpartition(5) }.should raise_error(TypeError) + ->{ "hello".rpartition(nil) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/string/rstrip_spec.rb b/spec/ruby/core/string/rstrip_spec.rb index 6376e5df33..2f32836e54 100644 --- a/spec/ruby/core/string/rstrip_spec.rb +++ b/spec/ruby/core/string/rstrip_spec.rb @@ -41,12 +41,12 @@ describe "String#rstrip!" do end it "raises a #{frozen_error_class} on a frozen instance that is modified" do - lambda { " hello ".freeze.rstrip! }.should raise_error(frozen_error_class) + -> { " hello ".freeze.rstrip! }.should raise_error(frozen_error_class) end # see [ruby-core:23666] it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do - lambda { "hello".freeze.rstrip! }.should raise_error(frozen_error_class) - lambda { "".freeze.rstrip! }.should raise_error(frozen_error_class) + -> { "hello".freeze.rstrip! }.should raise_error(frozen_error_class) + -> { "".freeze.rstrip! }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/scan_spec.rb b/spec/ruby/core/string/scan_spec.rb index ac82f5e236..06400fc745 100644 --- a/spec/ruby/core/string/scan_spec.rb +++ b/spec/ruby/core/string/scan_spec.rb @@ -58,11 +58,11 @@ describe "String#scan" do end it "raises a TypeError if pattern isn't a Regexp and can't be converted to a String" do - lambda { "cruel world".scan(5) }.should raise_error(TypeError) + -> { "cruel world".scan(5) }.should raise_error(TypeError) not_supported_on :opal do - lambda { "cruel world".scan(:test) }.should raise_error(TypeError) + -> { "cruel world".scan(:test) }.should raise_error(TypeError) end - lambda { "cruel world".scan(mock('x')) }.should raise_error(TypeError) + -> { "cruel world".scan(mock('x')) }.should raise_error(TypeError) end it "taints the results if the String argument is tainted" do diff --git a/spec/ruby/core/string/scrub_spec.rb b/spec/ruby/core/string/scrub_spec.rb index 92e7641f0b..390035ef30 100644 --- a/spec/ruby/core/string/scrub_spec.rb +++ b/spec/ruby/core/string/scrub_spec.rb @@ -47,14 +47,14 @@ describe "String#scrub with a custom replacement" do it "raises ArgumentError for replacements with an invalid encoding" do x81 = [0x81].pack('C').force_encoding('utf-8') xE4 = [0xE4].pack('C').force_encoding('utf-8') - block = lambda { "foo#{x81}".scrub(xE4) } + block = -> { "foo#{x81}".scrub(xE4) } block.should raise_error(ArgumentError) end it "raises TypeError when a non String replacement is given" do x81 = [0x81].pack('C').force_encoding('utf-8') - block = lambda { "foo#{x81}".scrub(1) } + block = -> { "foo#{x81}".scrub(1) } block.should raise_error(TypeError) end diff --git a/spec/ruby/core/string/setbyte_spec.rb b/spec/ruby/core/string/setbyte_spec.rb index 3f2e03f8a8..6912b1b66f 100644 --- a/spec/ruby/core/string/setbyte_spec.rb +++ b/spec/ruby/core/string/setbyte_spec.rb @@ -51,11 +51,11 @@ describe "String#setbyte" do end it "raises an IndexError if the index is greater than the String bytesize" do - lambda { "?".setbyte(1, 97) }.should raise_error(IndexError) + -> { "?".setbyte(1, 97) }.should raise_error(IndexError) end it "raises an IndexError if the negative index is greater magnitude than the String bytesize" do - lambda { "???".setbyte(-5, 97) }.should raise_error(IndexError) + -> { "???".setbyte(-5, 97) }.should raise_error(IndexError) end it "sets a byte at an index greater than String size" do @@ -78,11 +78,11 @@ describe "String#setbyte" do it "raises a #{frozen_error_class} if self is frozen" do str = "cold".freeze str.frozen?.should be_true - lambda { str.setbyte(3,96) }.should raise_error(frozen_error_class) + -> { str.setbyte(3,96) }.should raise_error(frozen_error_class) end it "raises a TypeError unless the second argument is an Integer" do - lambda { "a".setbyte(0,'a') }.should raise_error(TypeError) + -> { "a".setbyte(0,'a') }.should raise_error(TypeError) end it "calls #to_int to convert the index" do diff --git a/spec/ruby/core/string/shared/codepoints.rb b/spec/ruby/core/string/shared/codepoints.rb index 84a0e3ae39..e94a57f48e 100644 --- a/spec/ruby/core/string/shared/codepoints.rb +++ b/spec/ruby/core/string/shared/codepoints.rb @@ -9,7 +9,7 @@ describe :string_codepoints, shared: true do it "raises an ArgumentError when self has an invalid encoding and a method is called on the returned Enumerator" do s = "\xDF".force_encoding(Encoding::UTF_8) s.valid_encoding?.should be_false - lambda { s.send(@method).to_a }.should raise_error(ArgumentError) + -> { s.send(@method).to_a }.should raise_error(ArgumentError) end it "yields each codepoint to the block if one is given" do @@ -23,7 +23,7 @@ describe :string_codepoints, shared: true do it "raises an ArgumentError if self's encoding is invalid and a block is given" do s = "\xDF".force_encoding(Encoding::UTF_8) s.valid_encoding?.should be_false - lambda { s.send(@method) { } }.should raise_error(ArgumentError) + -> { s.send(@method) { } }.should raise_error(ArgumentError) end it "yields codepoints as Fixnums" do diff --git a/spec/ruby/core/string/shared/concat.rb b/spec/ruby/core/string/shared/concat.rb index 0a87410f2f..53a8bc23fb 100644 --- a/spec/ruby/core/string/shared/concat.rb +++ b/spec/ruby/core/string/shared/concat.rb @@ -13,16 +13,16 @@ describe :string_concat, shared: true do end it "raises a TypeError if the given argument can't be converted to a String" do - lambda { 'hello '.send(@method, []) }.should raise_error(TypeError) - lambda { 'hello '.send(@method, mock('x')) }.should raise_error(TypeError) + -> { 'hello '.send(@method, []) }.should raise_error(TypeError) + -> { 'hello '.send(@method, mock('x')) }.should raise_error(TypeError) end it "raises a #{frozen_error_class} when self is frozen" do a = "hello" a.freeze - lambda { a.send(@method, "") }.should raise_error(frozen_error_class) - lambda { a.send(@method, "test") }.should raise_error(frozen_error_class) + -> { a.send(@method, "") }.should raise_error(frozen_error_class) + -> { a.send(@method, "test") }.should raise_error(frozen_error_class) end it "returns a String when given a subclass instance" do @@ -71,28 +71,28 @@ describe :string_concat, shared: true do end it "raises RangeError if the argument is an invalid codepoint for self's encoding" do - lambda { "".encode(Encoding::US_ASCII).send(@method, 256) }.should raise_error(RangeError) - lambda { "".encode(Encoding::EUC_JP).send(@method, 0x81) }.should raise_error(RangeError) + -> { "".encode(Encoding::US_ASCII).send(@method, 256) }.should raise_error(RangeError) + -> { "".encode(Encoding::EUC_JP).send(@method, 0x81) }.should raise_error(RangeError) end it "raises RangeError if the argument is negative" do - lambda { "".send(@method, -200) }.should raise_error(RangeError) - lambda { "".send(@method, -bignum_value) }.should raise_error(RangeError) + -> { "".send(@method, -200) }.should raise_error(RangeError) + -> { "".send(@method, -bignum_value) }.should raise_error(RangeError) end it "doesn't call to_int on its argument" do x = mock('x') x.should_not_receive(:to_int) - lambda { "".send(@method, x) }.should raise_error(TypeError) + -> { "".send(@method, x) }.should raise_error(TypeError) end it "raises a #{frozen_error_class} when self is frozen" do a = "hello" a.freeze - lambda { a.send(@method, 0) }.should raise_error(frozen_error_class) - lambda { a.send(@method, 33) }.should raise_error(frozen_error_class) + -> { a.send(@method, 0) }.should raise_error(frozen_error_class) + -> { a.send(@method, 33) }.should raise_error(frozen_error_class) end end end @@ -112,7 +112,7 @@ describe :string_concat_encoding, shared: true do end it "raises Encoding::CompatibilityError if neither are empty" do - lambda { "x".encode("UTF-16LE").send(@method, "y".encode("UTF-8")) }.should raise_error(Encoding::CompatibilityError) + -> { "x".encode("UTF-16LE").send(@method, "y".encode("UTF-8")) }.should raise_error(Encoding::CompatibilityError) end end @@ -130,7 +130,7 @@ describe :string_concat_encoding, shared: true do end it "raises Encoding::CompatibilityError if neither are empty" do - lambda { "x".encode("UTF-8").send(@method, "y".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError) + -> { "x".encode("UTF-8").send(@method, "y".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError) end end @@ -148,7 +148,7 @@ describe :string_concat_encoding, shared: true do end it "raises Encoding::CompatibilityError if neither are ASCII-only" do - lambda { "\u00E9".encode("UTF-8").send(@method, "\u00E9".encode("ISO-8859-1")) }.should raise_error(Encoding::CompatibilityError) + -> { "\u00E9".encode("UTF-8").send(@method, "\u00E9".encode("ISO-8859-1")) }.should raise_error(Encoding::CompatibilityError) end end diff --git a/spec/ruby/core/string/shared/each_line.rb b/spec/ruby/core/string/shared/each_line.rb index 86c966e50b..241a90eee3 100644 --- a/spec/ruby/core/string/shared/each_line.rb +++ b/spec/ruby/core/string/shared/each_line.rb @@ -133,8 +133,8 @@ describe :string_each_line, shared: true do end it "raises a TypeError when the separator can't be converted to a string" do - lambda { "hello world".send(@method, false) {} }.should raise_error(TypeError) - lambda { "hello world".send(@method, mock('x')) {} }.should raise_error(TypeError) + -> { "hello world".send(@method, false) {} }.should raise_error(TypeError) + -> { "hello world".send(@method, mock('x')) {} }.should raise_error(TypeError) end it "accepts a string separator" do @@ -142,7 +142,7 @@ describe :string_each_line, shared: true do end it "raises a TypeError when the separator is a symbol" do - lambda { "hello world".send(@method, :o).to_a }.should raise_error(TypeError) + -> { "hello world".send(@method, :o).to_a }.should raise_error(TypeError) end context "when `chomp` keyword argument is passed" do diff --git a/spec/ruby/core/string/shared/encode.rb b/spec/ruby/core/string/shared/encode.rb index d13db1945e..b5a8bf9b72 100644 --- a/spec/ruby/core/string/shared/encode.rb +++ b/spec/ruby/core/string/shared/encode.rb @@ -8,7 +8,7 @@ describe :string_encode, shared: true do end it "transcodes a 7-bit String despite no generic converting being available" do - lambda do + -> do Encoding::Converter.new Encoding::Emacs_Mule, Encoding::BINARY end.should raise_error(Encoding::ConverterNotFoundError) @@ -21,7 +21,7 @@ describe :string_encode, shared: true do it "raises an Encoding::ConverterNotFoundError when no conversion is possible" do Encoding.default_internal = Encoding::Emacs_Mule str = [0x80].pack('C').force_encoding Encoding::BINARY - lambda { str.send(@method) }.should raise_error(Encoding::ConverterNotFoundError) + -> { str.send(@method) }.should raise_error(Encoding::ConverterNotFoundError) end end @@ -51,7 +51,7 @@ describe :string_encode, shared: true do end it "transcodes a 7-bit String despite no generic converting being available" do - lambda do + -> do Encoding::Converter.new Encoding::Emacs_Mule, Encoding::BINARY end.should raise_error(Encoding::ConverterNotFoundError) @@ -61,13 +61,13 @@ describe :string_encode, shared: true do it "raises an Encoding::ConverterNotFoundError when no conversion is possible" do str = [0x80].pack('C').force_encoding Encoding::BINARY - lambda do + -> do str.send(@method, Encoding::Emacs_Mule) end.should raise_error(Encoding::ConverterNotFoundError) end it "raises an Encoding::ConverterNotFoundError for an invalid encoding" do - lambda do + -> do "abc".send(@method, "xyz") end.should raise_error(Encoding::ConverterNotFoundError) end @@ -96,7 +96,7 @@ describe :string_encode, shared: true do it "raises an Encoding::ConverterNotFoundError when no conversion is possible despite 'invalid: :replace, undef: :replace'" do Encoding.default_internal = Encoding::Emacs_Mule str = [0x80].pack('C').force_encoding Encoding::BINARY - lambda do + -> do str.send(@method, invalid: :replace, undef: :replace) end.should raise_error(Encoding::ConverterNotFoundError) end @@ -242,6 +242,6 @@ describe :string_encode, shared: true do end it "raises ArgumentError if the value of the :xml option is not :text or :attr" do - lambda { ''.send(@method, "UTF-8", xml: :other) }.should raise_error(ArgumentError) + -> { ''.send(@method, "UTF-8", xml: :other) }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/string/shared/replace.rb b/spec/ruby/core/string/shared/replace.rb index a583b88b5a..f13afb3f95 100644 --- a/spec/ruby/core/string/shared/replace.rb +++ b/spec/ruby/core/string/shared/replace.rb @@ -57,19 +57,19 @@ describe :string_replace, shared: true do end it "raises a TypeError if other can't be converted to string" do - lambda { "hello".send(@method, 123) }.should raise_error(TypeError) - lambda { "hello".send(@method, []) }.should raise_error(TypeError) - lambda { "hello".send(@method, mock('x')) }.should raise_error(TypeError) + -> { "hello".send(@method, 123) }.should raise_error(TypeError) + -> { "hello".send(@method, []) }.should raise_error(TypeError) + -> { "hello".send(@method, mock('x')) }.should raise_error(TypeError) end it "raises a #{frozen_error_class} on a frozen instance that is modified" do a = "hello".freeze - lambda { a.send(@method, "world") }.should raise_error(frozen_error_class) + -> { a.send(@method, "world") }.should raise_error(frozen_error_class) end # see [ruby-core:23666] it "raises a #{frozen_error_class} on a frozen instance when self-replacing" do a = "hello".freeze - lambda { a.send(@method, a) }.should raise_error(frozen_error_class) + -> { a.send(@method, a) }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/shared/slice.rb b/spec/ruby/core/string/shared/slice.rb index 697fa2e530..ef7a8787ce 100644 --- a/spec/ruby/core/string/shared/slice.rb +++ b/spec/ruby/core/string/shared/slice.rb @@ -21,17 +21,17 @@ describe :string_slice, shared: true do end it "raises a TypeError if the given index is nil" do - lambda { "hello".send(@method, nil) }.should raise_error(TypeError) + -> { "hello".send(@method, nil) }.should raise_error(TypeError) end it "raises a TypeError if the given index can't be converted to an Integer" do - lambda { "hello".send(@method, mock('x')) }.should raise_error(TypeError) - lambda { "hello".send(@method, {}) }.should raise_error(TypeError) - lambda { "hello".send(@method, []) }.should raise_error(TypeError) + -> { "hello".send(@method, mock('x')) }.should raise_error(TypeError) + -> { "hello".send(@method, {}) }.should raise_error(TypeError) + -> { "hello".send(@method, []) }.should raise_error(TypeError) end it "raises a RangeError if the index is too big" do - lambda { "hello".send(@method, bignum_value) }.should raise_error(RangeError) + -> { "hello".send(@method, bignum_value) }.should raise_error(RangeError) end end @@ -140,23 +140,23 @@ describe :string_slice_index_length, shared: true do end it "raises a TypeError when idx or length can't be converted to an integer" do - lambda { "hello".send(@method, mock('x'), 0) }.should raise_error(TypeError) - lambda { "hello".send(@method, 0, mock('x')) }.should raise_error(TypeError) + -> { "hello".send(@method, mock('x'), 0) }.should raise_error(TypeError) + -> { "hello".send(@method, 0, mock('x')) }.should raise_error(TypeError) # I'm deliberately including this here. # It means that str.send(@method, other, idx) isn't supported. - lambda { "hello".send(@method, "", 0) }.should raise_error(TypeError) + -> { "hello".send(@method, "", 0) }.should raise_error(TypeError) end it "raises a TypeError when the given index or the given length is nil" do - lambda { "hello".send(@method, 1, nil) }.should raise_error(TypeError) - lambda { "hello".send(@method, nil, 1) }.should raise_error(TypeError) - lambda { "hello".send(@method, nil, nil) }.should raise_error(TypeError) + -> { "hello".send(@method, 1, nil) }.should raise_error(TypeError) + -> { "hello".send(@method, nil, 1) }.should raise_error(TypeError) + -> { "hello".send(@method, nil, nil) }.should raise_error(TypeError) end it "raises a RangeError if the index or length is too big" do - lambda { "hello".send(@method, bignum_value, 1) }.should raise_error(RangeError) - lambda { "hello".send(@method, 0, bignum_value) }.should raise_error(RangeError) + -> { "hello".send(@method, bignum_value, 1) }.should raise_error(RangeError) + -> { "hello".send(@method, 0, bignum_value) }.should raise_error(RangeError) end it "returns subclass instances" do @@ -399,13 +399,13 @@ describe :string_slice_regexp_index, shared: true do end it "raises a TypeError when the given index can't be converted to Integer" do - lambda { "hello".send(@method, /(.)(.)(.)/, mock('x')) }.should raise_error(TypeError) - lambda { "hello".send(@method, /(.)(.)(.)/, {}) }.should raise_error(TypeError) - lambda { "hello".send(@method, /(.)(.)(.)/, []) }.should raise_error(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, mock('x')) }.should raise_error(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, {}) }.should raise_error(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, []) }.should raise_error(TypeError) end it "raises a TypeError when the given index is nil" do - lambda { "hello".send(@method, /(.)(.)(.)/, nil) }.should raise_error(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, nil) }.should raise_error(TypeError) end it "returns subclass instances" do @@ -460,7 +460,7 @@ describe :string_slice_string, shared: true do o = mock('x') o.should_not_receive(:to_str) - lambda { "hello".send(@method, o) }.should raise_error(TypeError) + -> { "hello".send(@method, o) }.should raise_error(TypeError) end it "returns a subclass instance when given a subclass instance" do @@ -520,19 +520,19 @@ describe :string_slice_regexp_group, shared: true do end it "raises an IndexError if there is no capture for the given name" do - lambda do + -> do "hello there".send(@method, /[aeiou](.)\1/, 'non') end.should raise_error(IndexError) end it "raises a TypeError when the given name is not a String" do - lambda { "hello".send(@method, /(?<q>.)/, mock('x')) }.should raise_error(TypeError) - lambda { "hello".send(@method, /(?<q>.)/, {}) }.should raise_error(TypeError) - lambda { "hello".send(@method, /(?<q>.)/, []) }.should raise_error(TypeError) + -> { "hello".send(@method, /(?<q>.)/, mock('x')) }.should raise_error(TypeError) + -> { "hello".send(@method, /(?<q>.)/, {}) }.should raise_error(TypeError) + -> { "hello".send(@method, /(?<q>.)/, []) }.should raise_error(TypeError) end it "raises an IndexError when given the empty String as a group name" do - lambda { "hello".send(@method, /(?<q>)/, '') }.should raise_error(IndexError) + -> { "hello".send(@method, /(?<q>)/, '') }.should raise_error(IndexError) end it "returns subclass instances" do @@ -552,6 +552,6 @@ end describe :string_slice_symbol, shared: true do it "raises TypeError" do - lambda { 'hello'.send(@method, :hello) }.should raise_error(TypeError) + -> { 'hello'.send(@method, :hello) }.should raise_error(TypeError) end end diff --git a/spec/ruby/core/string/shared/succ.rb b/spec/ruby/core/string/shared/succ.rb index 0ab659864d..31b4a8b5dd 100644 --- a/spec/ruby/core/string/shared/succ.rb +++ b/spec/ruby/core/string/shared/succ.rb @@ -82,7 +82,7 @@ describe :string_succ_bang, shared: true do end it "raises a #{frozen_error_class} if self is frozen" do - lambda { "".freeze.send(@method) }.should raise_error(frozen_error_class) - lambda { "abcd".freeze.send(@method) }.should raise_error(frozen_error_class) + -> { "".freeze.send(@method) }.should raise_error(frozen_error_class) + -> { "abcd".freeze.send(@method) }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/slice_spec.rb b/spec/ruby/core/string/slice_spec.rb index e969f85937..2af663117c 100644 --- a/spec/ruby/core/string/slice_spec.rb +++ b/spec/ruby/core/string/slice_spec.rb @@ -54,9 +54,9 @@ describe "String#slice! with index" do end it "raises a #{frozen_error_class} if self is frozen" do - lambda { "hello".freeze.slice!(1) }.should raise_error(frozen_error_class) - lambda { "hello".freeze.slice!(10) }.should raise_error(frozen_error_class) - lambda { "".freeze.slice!(0) }.should raise_error(frozen_error_class) + -> { "hello".freeze.slice!(1) }.should raise_error(frozen_error_class) + -> { "hello".freeze.slice!(10) }.should raise_error(frozen_error_class) + -> { "".freeze.slice!(0) }.should raise_error(frozen_error_class) end it "calls to_int on index" do @@ -118,13 +118,13 @@ describe "String#slice! with index, length" do end it "raises a #{frozen_error_class} if self is frozen" do - lambda { "hello".freeze.slice!(1, 2) }.should raise_error(frozen_error_class) - lambda { "hello".freeze.slice!(10, 3) }.should raise_error(frozen_error_class) - lambda { "hello".freeze.slice!(-10, 3)}.should raise_error(frozen_error_class) - lambda { "hello".freeze.slice!(4, -3) }.should raise_error(frozen_error_class) - lambda { "hello".freeze.slice!(10, 3) }.should raise_error(frozen_error_class) - lambda { "hello".freeze.slice!(-10, 3)}.should raise_error(frozen_error_class) - lambda { "hello".freeze.slice!(4, -3) }.should raise_error(frozen_error_class) + -> { "hello".freeze.slice!(1, 2) }.should raise_error(frozen_error_class) + -> { "hello".freeze.slice!(10, 3) }.should raise_error(frozen_error_class) + -> { "hello".freeze.slice!(-10, 3)}.should raise_error(frozen_error_class) + -> { "hello".freeze.slice!(4, -3) }.should raise_error(frozen_error_class) + -> { "hello".freeze.slice!(10, 3) }.should raise_error(frozen_error_class) + -> { "hello".freeze.slice!(-10, 3)}.should raise_error(frozen_error_class) + -> { "hello".freeze.slice!(4, -3) }.should raise_error(frozen_error_class) end it "calls to_int on idx and length" do @@ -245,12 +245,12 @@ describe "String#slice! Range" do it "raises a #{frozen_error_class} on a frozen instance that is modified" do - lambda { "hello".freeze.slice!(1..3) }.should raise_error(frozen_error_class) + -> { "hello".freeze.slice!(1..3) }.should raise_error(frozen_error_class) end # see redmine #1551 it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do - lambda { "hello".freeze.slice!(10..20)}.should raise_error(frozen_error_class) + -> { "hello".freeze.slice!(10..20)}.should raise_error(frozen_error_class) end end @@ -313,11 +313,11 @@ describe "String#slice! with Regexp" do end it "raises a #{frozen_error_class} on a frozen instance that is modified" do - lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(frozen_error_class) + -> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(frozen_error_class) end it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do - lambda { "this is a string".freeze.slice!(/zzz/) }.should raise_error(frozen_error_class) + -> { "this is a string".freeze.slice!(/zzz/) }.should raise_error(frozen_error_class) end end @@ -403,9 +403,9 @@ describe "String#slice! with Regexp, index" do end it "raises a #{frozen_error_class} if self is frozen" do - lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(frozen_error_class) - lambda { "this is a string".freeze.slice!(/zzz/, 0)}.should raise_error(frozen_error_class) - lambda { "this is a string".freeze.slice!(/(.)/, 2)}.should raise_error(frozen_error_class) + -> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(frozen_error_class) + -> { "this is a string".freeze.slice!(/zzz/, 0)}.should raise_error(frozen_error_class) + -> { "this is a string".freeze.slice!(/(.)/, 2)}.should raise_error(frozen_error_class) end end @@ -448,7 +448,7 @@ describe "String#slice! with String" do o = mock('x') o.should_not_receive(:to_str) - lambda { "hello".slice!(o) }.should raise_error(TypeError) + -> { "hello".slice!(o) }.should raise_error(TypeError) end it "returns a subclass instance when given a subclass instance" do @@ -459,8 +459,8 @@ describe "String#slice! with String" do end it "raises a #{frozen_error_class} if self is frozen" do - lambda { "hello hello".freeze.slice!('llo') }.should raise_error(frozen_error_class) - lambda { "this is a string".freeze.slice!('zzz')}.should raise_error(frozen_error_class) - lambda { "this is a string".freeze.slice!('zzz')}.should raise_error(frozen_error_class) + -> { "hello hello".freeze.slice!('llo') }.should raise_error(frozen_error_class) + -> { "this is a string".freeze.slice!('zzz')}.should raise_error(frozen_error_class) + -> { "this is a string".freeze.slice!('zzz')}.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/split_spec.rb b/spec/ruby/core/string/split_spec.rb index 6c666deb6c..655f0dae76 100644 --- a/spec/ruby/core/string/split_spec.rb +++ b/spec/ruby/core/string/split_spec.rb @@ -9,7 +9,7 @@ describe "String#split with String" do broken_str.force_encoding('binary') broken_str.chop! broken_str.force_encoding('utf-8') - lambda { str.split(broken_str) }.should raise_error(ArgumentError) + -> { str.split(broken_str) }.should raise_error(ArgumentError) end it "splits on multibyte characters" do @@ -316,8 +316,8 @@ describe "String#split with Regexp" do end it "returns a type error if limit can't be converted to an integer" do - lambda {"1.2.3.4".split(".", "three")}.should raise_error(TypeError) - lambda {"1.2.3.4".split(".", nil) }.should raise_error(TypeError) + -> {"1.2.3.4".split(".", "three")}.should raise_error(TypeError) + -> {"1.2.3.4".split(".", nil) }.should raise_error(TypeError) end it "doesn't set $~" do @@ -400,7 +400,7 @@ describe "String#split with Regexp" do broken_str.force_encoding('binary') broken_str.chop! broken_str.force_encoding('utf-8') - lambda{ broken_str.split(/\r\n|\r|\n/) }.should raise_error(ArgumentError) + ->{ broken_str.split(/\r\n|\r|\n/) }.should raise_error(ArgumentError) end ruby_version_is "2.6" do diff --git a/spec/ruby/core/string/squeeze_spec.rb b/spec/ruby/core/string/squeeze_spec.rb index 391b356227..bcc320bb5b 100644 --- a/spec/ruby/core/string/squeeze_spec.rb +++ b/spec/ruby/core/string/squeeze_spec.rb @@ -50,8 +50,8 @@ describe "String#squeeze" do it "raises an ArgumentError when the parameter is out of sequence" do s = "--subbookkeeper--" - lambda { s.squeeze("e-b") }.should raise_error(ArgumentError) - lambda { s.squeeze("^e-b") }.should raise_error(ArgumentError) + -> { s.squeeze("e-b") }.should raise_error(ArgumentError) + -> { s.squeeze("^e-b") }.should raise_error(ArgumentError) end it "taints the result when self is tainted" do @@ -73,9 +73,9 @@ describe "String#squeeze" do end it "raises a TypeError when one set arg can't be converted to a string" do - lambda { "hello world".squeeze([]) }.should raise_error(TypeError) - lambda { "hello world".squeeze(Object.new)}.should raise_error(TypeError) - lambda { "hello world".squeeze(mock('x')) }.should raise_error(TypeError) + -> { "hello world".squeeze([]) }.should raise_error(TypeError) + -> { "hello world".squeeze(Object.new)}.should raise_error(TypeError) + -> { "hello world".squeeze(mock('x')) }.should raise_error(TypeError) end it "returns subclass instances when called on a subclass" do @@ -99,15 +99,15 @@ describe "String#squeeze!" do it "raises an ArgumentError when the parameter is out of sequence" do s = "--subbookkeeper--" - lambda { s.squeeze!("e-b") }.should raise_error(ArgumentError) - lambda { s.squeeze!("^e-b") }.should raise_error(ArgumentError) + -> { s.squeeze!("e-b") }.should raise_error(ArgumentError) + -> { s.squeeze!("^e-b") }.should raise_error(ArgumentError) end it "raises a #{frozen_error_class} when self is frozen" do a = "yellow moon" a.freeze - lambda { a.squeeze!("") }.should raise_error(frozen_error_class) - lambda { a.squeeze! }.should raise_error(frozen_error_class) + -> { a.squeeze!("") }.should raise_error(frozen_error_class) + -> { a.squeeze! }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/start_with_spec.rb b/spec/ruby/core/string/start_with_spec.rb index 4e12c1a445..f66ec55266 100644 --- a/spec/ruby/core/string/start_with_spec.rb +++ b/spec/ruby/core/string/start_with_spec.rb @@ -28,9 +28,9 @@ describe "String#start_with?" do it "ignores arguments not convertible to string" do "hello".start_with?().should be_false - lambda { "hello".start_with?(1) }.should raise_error(TypeError) - lambda { "hello".start_with?(["h"]) }.should raise_error(TypeError) - lambda { "hello".start_with?(1, nil, "h") }.should raise_error(TypeError) + -> { "hello".start_with?(1) }.should raise_error(TypeError) + -> { "hello".start_with?(["h"]) }.should raise_error(TypeError) + -> { "hello".start_with?(1, nil, "h") }.should raise_error(TypeError) end it "uses only the needed arguments" do diff --git a/spec/ruby/core/string/strip_spec.rb b/spec/ruby/core/string/strip_spec.rb index 54dec794fa..c205746483 100644 --- a/spec/ruby/core/string/strip_spec.rb +++ b/spec/ruby/core/string/strip_spec.rb @@ -49,12 +49,12 @@ describe "String#strip!" do end it "raises a #{frozen_error_class} on a frozen instance that is modified" do - lambda { " hello ".freeze.strip! }.should raise_error(frozen_error_class) + -> { " hello ".freeze.strip! }.should raise_error(frozen_error_class) end # see #1552 it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do - lambda {"hello".freeze.strip! }.should raise_error(frozen_error_class) - lambda {"".freeze.strip! }.should raise_error(frozen_error_class) + -> {"hello".freeze.strip! }.should raise_error(frozen_error_class) + -> {"".freeze.strip! }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/sub_spec.rb b/spec/ruby/core/string/sub_spec.rb index 901d1596c5..630f0d6b70 100644 --- a/spec/ruby/core/string/sub_spec.rb +++ b/spec/ruby/core/string/sub_spec.rb @@ -166,16 +166,16 @@ describe "String#sub with pattern, replacement" do not_supported_on :opal do it "raises a TypeError when pattern is a Symbol" do - lambda { "hello".sub(:woot, "x") }.should raise_error(TypeError) + -> { "hello".sub(:woot, "x") }.should raise_error(TypeError) end end it "raises a TypeError when pattern is an Array" do - lambda { "hello".sub([], "x") }.should raise_error(TypeError) + -> { "hello".sub([], "x") }.should raise_error(TypeError) end it "raises a TypeError when pattern can't be converted to a string" do - lambda { "hello".sub(Object.new, nil) }.should raise_error(TypeError) + -> { "hello".sub(Object.new, nil) }.should raise_error(TypeError) end it "tries to convert replacement to a string using to_str" do @@ -186,8 +186,8 @@ describe "String#sub with pattern, replacement" do end it "raises a TypeError when replacement can't be converted to a string" do - lambda { "hello".sub(/[aeiou]/, []) }.should raise_error(TypeError) - lambda { "hello".sub(/[aeiou]/, 99) }.should raise_error(TypeError) + -> { "hello".sub(/[aeiou]/, []) }.should raise_error(TypeError) + -> { "hello".sub(/[aeiou]/, 99) }.should raise_error(TypeError) end it "returns subclass instances when called on a subclass" do @@ -330,9 +330,9 @@ describe "String#sub! with pattern, replacement" do s = "hello" s.freeze - lambda { s.sub!(/ROAR/, "x") }.should raise_error(frozen_error_class) - lambda { s.sub!(/e/, "e") }.should raise_error(frozen_error_class) - lambda { s.sub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class) + -> { s.sub!(/ROAR/, "x") }.should raise_error(frozen_error_class) + -> { s.sub!(/e/, "e") }.should raise_error(frozen_error_class) + -> { s.sub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class) end end @@ -376,16 +376,16 @@ describe "String#sub! with pattern and block" do it "raises a RuntimeError if the string is modified while substituting" do str = "hello" - lambda { str.sub!(//) { str << 'x' } }.should raise_error(RuntimeError) + -> { str.sub!(//) { str << 'x' } }.should raise_error(RuntimeError) end it "raises a #{frozen_error_class} when self is frozen" do s = "hello" s.freeze - lambda { s.sub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class) - lambda { s.sub!(/e/) { "e" } }.should raise_error(frozen_error_class) - lambda { s.sub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class) + -> { s.sub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class) + -> { s.sub!(/e/) { "e" } }.should raise_error(frozen_error_class) + -> { s.sub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class) end end @@ -428,7 +428,7 @@ describe "String#sub with pattern and Hash" do it "uses the hash's value set from default_proc for missing keys" do hsh = {} - hsh.default_proc = lambda { |k,v| 'lamb' } + hsh.default_proc = -> k, v { 'lamb' } "food!".sub(/./, hsh).should == "lambood!" end @@ -513,7 +513,7 @@ describe "String#sub! with pattern and Hash" do it "uses the hash's value set from default_proc for missing keys" do hsh = {} - hsh.default_proc = lambda { |k,v| 'lamb' } + hsh.default_proc = -> k, v { 'lamb' } "food!".sub!(/./, hsh).should == "lambood!" end @@ -560,12 +560,12 @@ end describe "String#sub with pattern and without replacement and block" do it "raises a ArgumentError" do - lambda { "abca".sub(/a/) }.should raise_error(ArgumentError) + -> { "abca".sub(/a/) }.should raise_error(ArgumentError) end end describe "String#sub! with pattern and without replacement and block" do it "raises a ArgumentError" do - lambda { "abca".sub!(/a/) }.should raise_error(ArgumentError) + -> { "abca".sub!(/a/) }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/string/swapcase_spec.rb b/spec/ruby/core/string/swapcase_spec.rb index c35751859e..95edcec7d1 100644 --- a/spec/ruby/core/string/swapcase_spec.rb +++ b/spec/ruby/core/string/swapcase_spec.rb @@ -45,7 +45,7 @@ describe "String#swapcase" do end it "does not allow any other additional option" do - lambda { "aiS".swapcase(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { "aiS".swapcase(:turkic, :ascii) }.should raise_error(ArgumentError) end end @@ -59,16 +59,16 @@ describe "String#swapcase" do end it "does not allow any other additional option" do - lambda { "aiS".swapcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { "aiS".swapcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) end end it "does not allow the :fold option for upcasing" do - lambda { "abc".swapcase(:fold) }.should raise_error(ArgumentError) + -> { "abc".swapcase(:fold) }.should raise_error(ArgumentError) end it "does not allow invalid options" do - lambda { "abc".swapcase(:invalid_option) }.should raise_error(ArgumentError) + -> { "abc".swapcase(:invalid_option) }.should raise_error(ArgumentError) end it "returns subclass instances when called on a subclass" do @@ -124,7 +124,7 @@ describe "String#swapcase!" do end it "does not allow any other additional option" do - lambda { a = "aiS"; a.swapcase!(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { a = "aiS"; a.swapcase!(:turkic, :ascii) }.should raise_error(ArgumentError) end end @@ -142,16 +142,16 @@ describe "String#swapcase!" do end it "does not allow any other additional option" do - lambda { a = "aiS"; a.swapcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { a = "aiS"; a.swapcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) end end it "does not allow the :fold option for upcasing" do - lambda { a = "abc"; a.swapcase!(:fold) }.should raise_error(ArgumentError) + -> { a = "abc"; a.swapcase!(:fold) }.should raise_error(ArgumentError) end it "does not allow invalid options" do - lambda { a = "abc"; a.swapcase!(:invalid_option) }.should raise_error(ArgumentError) + -> { a = "abc"; a.swapcase!(:invalid_option) }.should raise_error(ArgumentError) end it "returns nil if no modifications were made" do @@ -165,7 +165,7 @@ describe "String#swapcase!" do it "raises a #{frozen_error_class} when self is frozen" do ["", "hello"].each do |a| a.freeze - lambda { a.swapcase! }.should raise_error(frozen_error_class) + -> { a.swapcase! }.should raise_error(frozen_error_class) end end end diff --git a/spec/ruby/core/string/to_i_spec.rb b/spec/ruby/core/string/to_i_spec.rb index f86d3a43a7..a37be47778 100644 --- a/spec/ruby/core/string/to_i_spec.rb +++ b/spec/ruby/core/string/to_i_spec.rb @@ -126,9 +126,9 @@ describe "String#to_i" do end it "raises an ArgumentError for illegal bases (1, < 0 or > 36)" do - lambda { "".to_i(1) }.should raise_error(ArgumentError) - lambda { "".to_i(-1) }.should raise_error(ArgumentError) - lambda { "".to_i(37) }.should raise_error(ArgumentError) + -> { "".to_i(1) }.should raise_error(ArgumentError) + -> { "".to_i(-1) }.should raise_error(ArgumentError) + -> { "".to_i(37) }.should raise_error(ArgumentError) end it "returns a Fixnum for long strings with trailing spaces" do diff --git a/spec/ruby/core/string/tr_s_spec.rb b/spec/ruby/core/string/tr_s_spec.rb index b05211abc4..4380f2d548 100644 --- a/spec/ruby/core/string/tr_s_spec.rb +++ b/spec/ruby/core/string/tr_s_spec.rb @@ -127,8 +127,8 @@ describe "String#tr_s!" do it "raises a #{frozen_error_class} if self is frozen" do s = "hello".freeze - lambda { s.tr_s!("el", "ar") }.should raise_error(frozen_error_class) - lambda { s.tr_s!("l", "r") }.should raise_error(frozen_error_class) - lambda { s.tr_s!("", "") }.should raise_error(frozen_error_class) + -> { s.tr_s!("el", "ar") }.should raise_error(frozen_error_class) + -> { s.tr_s!("l", "r") }.should raise_error(frozen_error_class) + -> { s.tr_s!("", "") }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/tr_spec.rb b/spec/ruby/core/string/tr_spec.rb index 8a33dd24f5..721ebab51c 100644 --- a/spec/ruby/core/string/tr_spec.rb +++ b/spec/ruby/core/string/tr_spec.rb @@ -22,11 +22,11 @@ describe "String#tr" do end it "raises an ArgumentError a descending range in the replacement as containing just the start character" do - lambda { "hello".tr("a-y", "z-b") }.should raise_error(ArgumentError) + -> { "hello".tr("a-y", "z-b") }.should raise_error(ArgumentError) end it "raises an ArgumentError a descending range in the source as empty" do - lambda { "hello".tr("l-a", "z") }.should raise_error(ArgumentError) + -> { "hello".tr("l-a", "z") }.should raise_error(ArgumentError) end it "translates chars not in from_string when it starts with a ^" do @@ -122,8 +122,8 @@ describe "String#tr!" do it "raises a #{frozen_error_class} if self is frozen" do s = "abcdefghijklmnopqR".freeze - lambda { s.tr!("cdefg", "12") }.should raise_error(frozen_error_class) - lambda { s.tr!("R", "S") }.should raise_error(frozen_error_class) - lambda { s.tr!("", "") }.should raise_error(frozen_error_class) + -> { s.tr!("cdefg", "12") }.should raise_error(frozen_error_class) + -> { s.tr!("R", "S") }.should raise_error(frozen_error_class) + -> { s.tr!("", "") }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/try_convert_spec.rb b/spec/ruby/core/string/try_convert_spec.rb index 629817110e..84415c4a75 100644 --- a/spec/ruby/core/string/try_convert_spec.rb +++ b/spec/ruby/core/string/try_convert_spec.rb @@ -39,12 +39,12 @@ describe "String.try_convert" do it "sends #to_str to the argument and raises TypeError if it's not a kind of String" do obj = mock("to_str") obj.should_receive(:to_str).and_return(Object.new) - lambda { String.try_convert obj }.should raise_error(TypeError) + -> { String.try_convert obj }.should raise_error(TypeError) end it "does not rescue exceptions raised by #to_str" do obj = mock("to_str") obj.should_receive(:to_str).and_raise(RuntimeError) - lambda { String.try_convert obj }.should raise_error(RuntimeError) + -> { String.try_convert obj }.should raise_error(RuntimeError) end end diff --git a/spec/ruby/core/string/unicode_normalize_spec.rb b/spec/ruby/core/string/unicode_normalize_spec.rb index 7a4662e0b8..6de7533fc7 100644 --- a/spec/ruby/core/string/unicode_normalize_spec.rb +++ b/spec/ruby/core/string/unicode_normalize_spec.rb @@ -48,13 +48,13 @@ describe "String#unicode_normalize" do end it "raises an Encoding::CompatibilityError if string is not in an unicode encoding" do - lambda do + -> do [0xE0].pack('C').force_encoding("ISO-8859-1").unicode_normalize(:nfd) end.should raise_error(Encoding::CompatibilityError) end it "raises an ArgumentError if the specified form is invalid" do - lambda { + -> { @angstrom.unicode_normalize(:invalid_form) }.should raise_error(ArgumentError) end @@ -101,14 +101,14 @@ describe "String#unicode_normalize!" do end it "raises an Encoding::CompatibilityError if the string is not in an unicode encoding" do - lambda { + -> { [0xE0].pack('C').force_encoding("ISO-8859-1").unicode_normalize! }.should raise_error(Encoding::CompatibilityError) end it "raises an ArgumentError if the specified form is invalid" do ohm = "\u2126" - lambda { + -> { ohm.unicode_normalize!(:invalid_form) }.should raise_error(ArgumentError) end diff --git a/spec/ruby/core/string/unicode_normalized_spec.rb b/spec/ruby/core/string/unicode_normalized_spec.rb index d383c0a91e..25c810a98f 100644 --- a/spec/ruby/core/string/unicode_normalized_spec.rb +++ b/spec/ruby/core/string/unicode_normalized_spec.rb @@ -37,11 +37,11 @@ describe "String#unicode_normalized?" do end it "raises an Encoding::CompatibilityError if the string is not in an unicode encoding" do - lambda { @nfc_normalized_str.force_encoding("ISO-8859-1").unicode_normalized? }.should raise_error(Encoding::CompatibilityError) + -> { @nfc_normalized_str.force_encoding("ISO-8859-1").unicode_normalized? }.should raise_error(Encoding::CompatibilityError) end it "raises an ArgumentError if the specified form is invalid" do - lambda { @nfc_normalized_str.unicode_normalized?(:invalid_form) }.should raise_error(ArgumentError) + -> { @nfc_normalized_str.unicode_normalized?(:invalid_form) }.should raise_error(ArgumentError) end it "returns true if str is in Unicode normalization form (nfc)" do diff --git a/spec/ruby/core/string/unpack/at_spec.rb b/spec/ruby/core/string/unpack/at_spec.rb index d8e55a1020..70b2389d69 100644 --- a/spec/ruby/core/string/unpack/at_spec.rb +++ b/spec/ruby/core/string/unpack/at_spec.rb @@ -24,6 +24,6 @@ describe "String#unpack with format '@'" do end it "raises an ArgumentError if the count exceeds the size of the String" do - lambda { "\x01\x02\x03\x04".unpack("C2@5C") }.should raise_error(ArgumentError) + -> { "\x01\x02\x03\x04".unpack("C2@5C") }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/string/unpack/p_spec.rb b/spec/ruby/core/string/unpack/p_spec.rb index 136e32adfd..a544bc29c1 100644 --- a/spec/ruby/core/string/unpack/p_spec.rb +++ b/spec/ruby/core/string/unpack/p_spec.rb @@ -15,7 +15,7 @@ describe "String#unpack with format 'P'" do packed = ["hello"].pack("P") packed.unpack("P5").should == ["hello"] packed.dup.unpack("P5").should == ["hello"] - lambda { packed.to_sym.to_s.unpack("P5") }.should raise_error(ArgumentError, /no associated pointer/) + -> { packed.to_sym.to_s.unpack("P5") }.should raise_error(ArgumentError, /no associated pointer/) end it "taints the unpacked string" do @@ -43,7 +43,7 @@ describe "String#unpack with format 'p'" do packed = ["hello"].pack("p") packed.unpack("p").should == ["hello"] packed.dup.unpack("p").should == ["hello"] - lambda { packed.to_sym.to_s.unpack("p") }.should raise_error(ArgumentError, /no associated pointer/) + -> { packed.to_sym.to_s.unpack("p") }.should raise_error(ArgumentError, /no associated pointer/) end it "taints the unpacked string" do diff --git a/spec/ruby/core/string/unpack/percent_spec.rb b/spec/ruby/core/string/unpack/percent_spec.rb index f0684d4cbc..0e27663195 100644 --- a/spec/ruby/core/string/unpack/percent_spec.rb +++ b/spec/ruby/core/string/unpack/percent_spec.rb @@ -2,6 +2,6 @@ require_relative '../../../spec_helper' describe "String#unpack with format '%'" do it "raises an Argument Error" do - lambda { "abc".unpack("%") }.should raise_error(ArgumentError) + -> { "abc".unpack("%") }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/string/unpack/shared/basic.rb b/spec/ruby/core/string/unpack/shared/basic.rb index 0ecbf615af..332e39d8d1 100644 --- a/spec/ruby/core/string/unpack/shared/basic.rb +++ b/spec/ruby/core/string/unpack/shared/basic.rb @@ -10,20 +10,20 @@ describe :string_unpack_basic, shared: true do end it "raises a TypeError when passed nil" do - lambda { "abc".unpack(nil) }.should raise_error(TypeError) + -> { "abc".unpack(nil) }.should raise_error(TypeError) end it "raises a TypeError when passed an Integer" do - lambda { "abc".unpack(1) }.should raise_error(TypeError) + -> { "abc".unpack(1) }.should raise_error(TypeError) end end describe :string_unpack_no_platform, shared: true do it "raises an ArgumentError when the format modifier is '_'" do - lambda { "abcdefgh".unpack(unpack_format("_")) }.should raise_error(ArgumentError) + -> { "abcdefgh".unpack(unpack_format("_")) }.should raise_error(ArgumentError) end it "raises an ArgumentError when the format modifier is '!'" do - lambda { "abcdefgh".unpack(unpack_format("!")) }.should raise_error(ArgumentError) + -> { "abcdefgh".unpack(unpack_format("!")) }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/string/unpack/u_spec.rb b/spec/ruby/core/string/unpack/u_spec.rb index 8db6de1ab3..7845e6d5f2 100644 --- a/spec/ruby/core/string/unpack/u_spec.rb +++ b/spec/ruby/core/string/unpack/u_spec.rb @@ -12,11 +12,11 @@ describe "String#unpack with format 'U'" do it_behaves_like :string_unpack_taint, 'U' it "raises ArgumentError on a malformed byte sequence" do - lambda { "\xE3".unpack('U') }.should raise_error(ArgumentError) + -> { "\xE3".unpack('U') }.should raise_error(ArgumentError) end it "raises ArgumentError on a malformed byte sequence and doesn't continue when used with the * modifier" do - lambda { "\xE3".unpack('U*') }.should raise_error(ArgumentError) + -> { "\xE3".unpack('U*') }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/string/unpack/x_spec.rb b/spec/ruby/core/string/unpack/x_spec.rb index 5adcb720d1..5e248de77e 100644 --- a/spec/ruby/core/string/unpack/x_spec.rb +++ b/spec/ruby/core/string/unpack/x_spec.rb @@ -24,11 +24,11 @@ describe "String#unpack with format 'X'" do end it "raises an ArgumentError when passed the '*' modifier if the remaining bytes exceed the bytes from the index to the start of the String" do - lambda { "abcd".unpack("CX*C") }.should raise_error(ArgumentError) + -> { "abcd".unpack("CX*C") }.should raise_error(ArgumentError) end it "raises an ArgumentError if the count exceeds the bytes from current index to the start of the String" do - lambda { "\x01\x02\x03\x04".unpack("C3X4C") }.should raise_error(ArgumentError) + -> { "\x01\x02\x03\x04".unpack("C3X4C") }.should raise_error(ArgumentError) end end @@ -57,6 +57,6 @@ describe "String#unpack with format 'x'" do end it "raises an ArgumentError if the count exceeds the size of the String" do - lambda { "\x01\x02\x03\x04".unpack("C2x3C") }.should raise_error(ArgumentError) + -> { "\x01\x02\x03\x04".unpack("C2x3C") }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/core/string/upcase_spec.rb b/spec/ruby/core/string/upcase_spec.rb index eb736ebfa1..72aacd88a9 100644 --- a/spec/ruby/core/string/upcase_spec.rb +++ b/spec/ruby/core/string/upcase_spec.rb @@ -39,7 +39,7 @@ describe "String#upcase" do end it "does not allow any other additional option" do - lambda { "i".upcase(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { "i".upcase(:turkic, :ascii) }.should raise_error(ArgumentError) end end @@ -53,16 +53,16 @@ describe "String#upcase" do end it "does not allow any other additional option" do - lambda { "iß".upcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { "iß".upcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) end end it "does not allow the :fold option for upcasing" do - lambda { "abc".upcase(:fold) }.should raise_error(ArgumentError) + -> { "abc".upcase(:fold) }.should raise_error(ArgumentError) end it "does not allow invalid options" do - lambda { "abc".upcase(:invalid_option) }.should raise_error(ArgumentError) + -> { "abc".upcase(:invalid_option) }.should raise_error(ArgumentError) end it "taints result when self is tainted" do @@ -123,7 +123,7 @@ describe "String#upcase!" do end it "does not allow any other additional option" do - lambda { a = "i"; a.upcase!(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { a = "i"; a.upcase!(:turkic, :ascii) }.should raise_error(ArgumentError) end end @@ -141,16 +141,16 @@ describe "String#upcase!" do end it "does not allow any other additional option" do - lambda { a = "iß"; a.upcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { a = "iß"; a.upcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) end end it "does not allow the :fold option for upcasing" do - lambda { a = "abc"; a.upcase!(:fold) }.should raise_error(ArgumentError) + -> { a = "abc"; a.upcase!(:fold) }.should raise_error(ArgumentError) end it "does not allow invalid options" do - lambda { a = "abc"; a.upcase!(:invalid_option) }.should raise_error(ArgumentError) + -> { a = "abc"; a.upcase!(:invalid_option) }.should raise_error(ArgumentError) end it "returns nil if no modifications were made" do @@ -160,7 +160,7 @@ describe "String#upcase!" do end it "raises a #{frozen_error_class} when self is frozen" do - lambda { "HeLlo".freeze.upcase! }.should raise_error(frozen_error_class) - lambda { "HELLO".freeze.upcase! }.should raise_error(frozen_error_class) + -> { "HeLlo".freeze.upcase! }.should raise_error(frozen_error_class) + -> { "HELLO".freeze.upcase! }.should raise_error(frozen_error_class) end end diff --git a/spec/ruby/core/string/upto_spec.rb b/spec/ruby/core/string/upto_spec.rb index 3748a6fdeb..b988613a80 100644 --- a/spec/ruby/core/string/upto_spec.rb +++ b/spec/ruby/core/string/upto_spec.rb @@ -53,13 +53,13 @@ describe "String#upto" do end it "raises a TypeError if other can't be converted to a string" do - lambda { "abc".upto(123) { } }.should raise_error(TypeError) - lambda { "abc".upto(mock('x')){ } }.should raise_error(TypeError) + -> { "abc".upto(123) { } }.should raise_error(TypeError) + -> { "abc".upto(mock('x')){ } }.should raise_error(TypeError) end it "does not work with symbols" do - lambda { "a".upto(:c).to_a }.should raise_error(TypeError) + -> { "a".upto(:c).to_a }.should raise_error(TypeError) end it "returns non-alphabetic characters in the ASCII range for single letters" do |