diff options
Diffstat (limited to 'spec/ruby/core/string/rstrip_spec.rb')
| -rw-r--r-- | spec/ruby/core/string/rstrip_spec.rb | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/spec/ruby/core/string/rstrip_spec.rb b/spec/ruby/core/string/rstrip_spec.rb index 4332b33b20..1638ea375d 100644 --- a/spec/ruby/core/string/rstrip_spec.rb +++ b/spec/ruby/core/string/rstrip_spec.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require_relative '../../spec_helper' require_relative 'fixtures/classes' require_relative 'shared/strip' @@ -29,7 +30,7 @@ end describe "String#rstrip!" do it "modifies self in place and returns self" do a = " hello " - a.rstrip!.should equal(a) + a.rstrip!.should.equal?(a) a.should == " hello" end @@ -51,31 +52,29 @@ describe "String#rstrip!" do " ".rstrip.should == "" end - ruby_version_is '3.0' do - it "removes trailing NULL bytes and whitespace" do - a = "\000 goodbye \000" - a.rstrip! - a.should == "\000 goodbye" - end + it "removes trailing NULL bytes and whitespace" do + a = "\000 goodbye \000" + a.rstrip! + a.should == "\000 goodbye" end it "raises a FrozenError on a frozen instance that is modified" do - -> { " hello ".freeze.rstrip! }.should raise_error(FrozenError) + -> { " hello ".freeze.rstrip! }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError on a frozen instance that would not be modified" do - -> { "hello".freeze.rstrip! }.should raise_error(FrozenError) - -> { "".freeze.rstrip! }.should raise_error(FrozenError) + -> { "hello".freeze.rstrip! }.should.raise(FrozenError) + -> { "".freeze.rstrip! }.should.raise(FrozenError) end - it "raises an ArgumentError if the last non-space codepoint is invalid" do + it "raises an Encoding::CompatibilityError if the last non-space codepoint is invalid" do s = "abc\xDF".force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - -> { s.rstrip! }.should raise_error(ArgumentError) + s.valid_encoding?.should == false + -> { s.rstrip! }.should.raise(Encoding::CompatibilityError) s = "abc\xDF ".force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - -> { s.rstrip! }.should raise_error(ArgumentError) + s.valid_encoding?.should == false + -> { s.rstrip! }.should.raise(Encoding::CompatibilityError) end end |
