summaryrefslogtreecommitdiff
path: root/spec/ruby/shared/string
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/shared/string')
-rw-r--r--spec/ruby/shared/string/end_with.rb8
-rw-r--r--spec/ruby/shared/string/start_with.rb28
-rw-r--r--spec/ruby/shared/string/times.rb22
3 files changed, 25 insertions, 33 deletions
diff --git a/spec/ruby/shared/string/end_with.rb b/spec/ruby/shared/string/end_with.rb
index 08f43c1bce..8eb9693395 100644
--- a/spec/ruby/shared/string/end_with.rb
+++ b/spec/ruby/shared/string/end_with.rb
@@ -30,9 +30,9 @@ describe :end_with, shared: true do
it "ignores arguments not convertible to string" do
"hello".send(@method).should_not.end_with?()
- -> { "hello".send(@method).end_with?(1) }.should raise_error(TypeError)
- -> { "hello".send(@method).end_with?(["o"]) }.should raise_error(TypeError)
- -> { "hello".send(@method).end_with?(1, nil, "o") }.should raise_error(TypeError)
+ -> { "hello".send(@method).end_with?(1) }.should.raise(TypeError)
+ -> { "hello".send(@method).end_with?(["o"]) }.should.raise(TypeError)
+ -> { "hello".send(@method).end_with?(1, nil, "o") }.should.raise(TypeError)
end
it "uses only the needed arguments" do
@@ -49,7 +49,7 @@ describe :end_with, shared: true do
pat = "ア".encode Encoding::EUC_JP
-> do
"あれ".send(@method).end_with?(pat)
- end.should raise_error(Encoding::CompatibilityError)
+ end.should.raise(Encoding::CompatibilityError)
end
it "checks that we are starting to match at the head of a character" do
diff --git a/spec/ruby/shared/string/start_with.rb b/spec/ruby/shared/string/start_with.rb
index 4b947a3bbf..fe12e28969 100644
--- a/spec/ruby/shared/string/start_with.rb
+++ b/spec/ruby/shared/string/start_with.rb
@@ -26,9 +26,9 @@ describe :start_with, shared: true do
it "ignores arguments not convertible to string" do
"hello".send(@method).should_not.start_with?()
- -> { "hello".send(@method).start_with?(1) }.should raise_error(TypeError)
- -> { "hello".send(@method).start_with?(["h"]) }.should raise_error(TypeError)
- -> { "hello".send(@method).start_with?(1, nil, "h") }.should raise_error(TypeError)
+ -> { "hello".send(@method).start_with?(1) }.should.raise(TypeError)
+ -> { "hello".send(@method).start_with?(["h"]) }.should.raise(TypeError)
+ -> { "hello".send(@method).start_with?(1, nil, "h") }.should.raise(TypeError)
end
it "uses only the needed arguments" do
@@ -60,25 +60,17 @@ describe :start_with, shared: true do
it "sets Regexp.last_match if it returns true" do
regexp = /test-(\d+)/
- "test-1337".send(@method).start_with?(regexp).should be_true
- Regexp.last_match.should_not be_nil
+ "test-1337".send(@method).start_with?(regexp).should == true
+ Regexp.last_match.should_not == nil
Regexp.last_match[1].should == "1337"
$1.should == "1337"
- "test-asdf".send(@method).start_with?(regexp).should be_false
- Regexp.last_match.should be_nil
- $1.should be_nil
+ "test-asdf".send(@method).start_with?(regexp).should == false
+ Regexp.last_match.should == nil
+ $1.should == nil
end
- ruby_version_is ""..."3.3" do
- it "does not check that we are not matching part of a character" do
- "\xC3\xA9".send(@method).should.start_with?("\xC3")
- end
- end
-
- ruby_version_is "3.3" do # #19784
- it "checks that we are not matching part of a character" do
- "\xC3\xA9".send(@method).should_not.start_with?("\xC3")
- end
+ it "checks that we are not matching part of a character" do
+ "\xC3\xA9".send(@method).should_not.start_with?("\xC3")
end
end
diff --git a/spec/ruby/shared/string/times.rb b/spec/ruby/shared/string/times.rb
index 4814f894cf..0a16ba8b82 100644
--- a/spec/ruby/shared/string/times.rb
+++ b/spec/ruby/shared/string/times.rb
@@ -18,14 +18,14 @@ describe :string_times, shared: true do
end
it "raises an ArgumentError when given integer is negative" do
- -> { @object.call("cool", -3) }.should raise_error(ArgumentError)
- -> { @object.call("cool", -3.14) }.should raise_error(ArgumentError)
- -> { @object.call("cool", min_long) }.should raise_error(ArgumentError)
+ -> { @object.call("cool", -3) }.should.raise(ArgumentError)
+ -> { @object.call("cool", -3.14) }.should.raise(ArgumentError)
+ -> { @object.call("cool", min_long) }.should.raise(ArgumentError)
end
it "raises a RangeError when given integer is a Bignum" do
- -> { @object.call("cool", 999999999999999999999) }.should raise_error(RangeError)
- -> { @object.call("", 999999999999999999999) }.should raise_error(RangeError)
+ -> { @object.call("cool", 999999999999999999999) }.should.raise(RangeError)
+ -> { @object.call("", 999999999999999999999) }.should.raise(RangeError)
end
it "works with huge long values when string is empty" do
@@ -33,26 +33,26 @@ describe :string_times, shared: true do
end
it "returns String instances" do
- @object.call(MyString.new("cool"), 0).should be_an_instance_of(String)
- @object.call(MyString.new("cool"), 1).should be_an_instance_of(String)
- @object.call(MyString.new("cool"), 2).should be_an_instance_of(String)
+ @object.call(MyString.new("cool"), 0).should.instance_of?(String)
+ @object.call(MyString.new("cool"), 1).should.instance_of?(String)
+ @object.call(MyString.new("cool"), 2).should.instance_of?(String)
end
it "returns a String in the same encoding as self" do
str = "\xE3\x81\x82".dup.force_encoding Encoding::UTF_8
result = @object.call(str, 2)
- result.encoding.should equal(Encoding::UTF_8)
+ result.encoding.should.equal?(Encoding::UTF_8)
end
platform_is c_long_size: 32 do
it "raises an ArgumentError if the length of the resulting string doesn't fit into a long" do
- -> { @object.call("abc", (2 ** 31) - 1) }.should raise_error(ArgumentError)
+ -> { @object.call("abc", (2 ** 31) - 1) }.should.raise(ArgumentError)
end
end
platform_is c_long_size: 64 do
it "raises an ArgumentError if the length of the resulting string doesn't fit into a long" do
- -> { @object.call("abc", (2 ** 63) - 1) }.should raise_error(ArgumentError)
+ -> { @object.call("abc", (2 ** 63) - 1) }.should.raise(ArgumentError)
end
end
end