summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/gsub_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/gsub_spec.rb')
-rw-r--r--spec/ruby/core/string/gsub_spec.rb40
1 files changed, 20 insertions, 20 deletions
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