diff options
Diffstat (limited to 'spec/ruby/core/string/chop_spec.rb')
| -rw-r--r-- | spec/ruby/core/string/chop_spec.rb | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/spec/ruby/core/string/chop_spec.rb b/spec/ruby/core/string/chop_spec.rb index 266d973f67..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,19 +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 ''...'3.0' do - it "returns subclass instances when called on a subclass" do - StringSpecs::MyString.new("hello\n").chop.should be_an_instance_of(StringSpecs::MyString) - end + it "returns String instances when called on a subclass" do + StringSpecs::MyString.new("hello\n").chop.should.instance_of?(String) end - ruby_version_is '3.0' do - it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("hello\n").chop.should be_an_instance_of(String) - end + 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 @@ -102,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 FrozenError on a frozen instance that is modified" do - -> { "string\n\r".freeze.chop! }.should raise_error(FrozenError) + -> { "string\n\r".freeze.chop! }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError on a frozen instance that would not be modified" do a = "" a.freeze - -> { a.chop! }.should raise_error(FrozenError) + -> { a.chop! }.should.raise(FrozenError) end end |
