diff options
Diffstat (limited to 'spec/ruby/core/string/chop_spec.rb')
| -rw-r--r-- | spec/ruby/core/string/chop_spec.rb | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/spec/ruby/core/string/chop_spec.rb b/spec/ruby/core/string/chop_spec.rb index 9e893c3bea..2113da543b 100644 --- a/spec/ruby/core/string/chop_spec.rb +++ b/spec/ruby/core/string/chop_spec.rb @@ -1,4 +1,5 @@ # -*- encoding: utf-8 -*- +# frozen_string_literal: false require_relative '../../spec_helper' require_relative 'fixtures/classes' @@ -46,23 +47,15 @@ describe "String#chop" do it "returns a new string when applied to an empty string" do s = "" - s.chop.should_not equal(s) + s.chop.should_not.equal?(s) end - ruby_version_is ''...'2.7' do - it "taints result when self is tainted" do - "hello".taint.chop.tainted?.should == true - "".taint.chop.tainted?.should == true - end - - it "untrusts result when self is untrusted" do - "hello".untrust.chop.untrusted?.should == true - "".untrust.chop.untrusted?.should == true - end + it "returns String instances when called on a subclass" do + StringSpecs::MyString.new("hello\n").chop.should.instance_of?(String) end - it "returns subclass instances when called on a subclass" do - StringSpecs::MyString.new("hello\n").chop.should be_an_instance_of(StringSpecs::MyString) + it "returns a String in the same encoding as self" do + "abc\n\n".encode("US-ASCII").chop.encoding.should == Encoding::US_ASCII end end @@ -106,21 +99,21 @@ describe "String#chop!" do it "returns self if modifications were made" do str = "hello" - str.chop!.should equal(str) + str.chop!.should.equal?(str) end it "returns nil when called on an empty string" do - "".chop!.should be_nil + "".chop!.should == nil end - it "raises a #{frozen_error_class} on a frozen instance that is modified" do - -> { "string\n\r".freeze.chop! }.should raise_error(frozen_error_class) + it "raises a FrozenError on a frozen instance that is modified" do + -> { "string\n\r".freeze.chop! }.should.raise(FrozenError) end # see [ruby-core:23666] - it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do + it "raises a FrozenError on a frozen instance that would not be modified" do a = "" a.freeze - -> { a.chop! }.should raise_error(frozen_error_class) + -> { a.chop! }.should.raise(FrozenError) end end |
