summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/shared/succ.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/shared/succ.rb')
-rw-r--r--spec/ruby/core/string/shared/succ.rb35
1 files changed, 11 insertions, 24 deletions
diff --git a/spec/ruby/core/string/shared/succ.rb b/spec/ruby/core/string/shared/succ.rb
index 25602103b6..8f1d327741 100644
--- a/spec/ruby/core/string/shared/succ.rb
+++ b/spec/ruby/core/string/shared/succ.rb
@@ -1,4 +1,4 @@
-# -*- encoding: binary -*-
+# encoding: binary
describe :string_succ, shared: true do
it "returns an empty string for empty strings" do
"".send(@method).should == ""
@@ -59,42 +59,29 @@ describe :string_succ, shared: true do
"\xFF\xFF".send(@method).should == "\x01\x00\x00"
end
- ruby_version_is ''...'3.0' do
- it "returns subclass instances when called on a subclass" do
- StringSpecs::MyString.new("").send(@method).should be_an_instance_of(StringSpecs::MyString)
- StringSpecs::MyString.new("a").send(@method).should be_an_instance_of(StringSpecs::MyString)
- StringSpecs::MyString.new("z").send(@method).should be_an_instance_of(StringSpecs::MyString)
- end
+ it "returns String instances when called on a subclass" do
+ StringSpecs::MyString.new("").send(@method).should.instance_of?(String)
+ StringSpecs::MyString.new("a").send(@method).should.instance_of?(String)
+ StringSpecs::MyString.new("z").send(@method).should.instance_of?(String)
end
- ruby_version_is '3.0' do
- it "returns String instances when called on a subclass" do
- StringSpecs::MyString.new("").send(@method).should be_an_instance_of(String)
- StringSpecs::MyString.new("a").send(@method).should be_an_instance_of(String)
- StringSpecs::MyString.new("z").send(@method).should be_an_instance_of(String)
- end
- end
-
- ruby_version_is ''...'2.7' do
- it "taints the result if self is tainted" do
- ["", "a", "z", "Z", "9", "\xFF", "\xFF\xFF"].each do |s|
- s.taint.send(@method).should.tainted?
- end
- end
+ it "returns a String in the same encoding as self" do
+ "z".encode("US-ASCII").send(@method).encoding.should == Encoding::US_ASCII
end
end
describe :string_succ_bang, shared: true do
it "is equivalent to succ, but modifies self in place (still returns self)" do
["", "abcd", "THX1138"].each do |s|
+ s = +s
r = s.dup.send(@method)
- s.send(@method).should equal(s)
+ s.send(@method).should.equal?(s)
s.should == r
end
end
it "raises a FrozenError if self is frozen" do
- -> { "".freeze.send(@method) }.should raise_error(FrozenError)
- -> { "abcd".freeze.send(@method) }.should raise_error(FrozenError)
+ -> { "".freeze.send(@method) }.should.raise(FrozenError)
+ -> { "abcd".freeze.send(@method) }.should.raise(FrozenError)
end
end