summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/delete_prefix_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/delete_prefix_spec.rb')
-rw-r--r--spec/ruby/core/string/delete_prefix_spec.rb30
1 files changed, 11 insertions, 19 deletions
diff --git a/spec/ruby/core/string/delete_prefix_spec.rb b/spec/ruby/core/string/delete_prefix_spec.rb
index 238de85f05..fc69adcbad 100644
--- a/spec/ruby/core/string/delete_prefix_spec.rb
+++ b/spec/ruby/core/string/delete_prefix_spec.rb
@@ -1,4 +1,5 @@
# -*- encoding: utf-8 -*-
+# frozen_string_literal: false
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
@@ -11,13 +12,13 @@ describe "String#delete_prefix" do
it "returns a copy of the string, when the prefix isn't found" do
s = 'hello'
r = s.delete_prefix('hello!')
- r.should_not equal s
+ r.should_not.equal? s
r.should == s
r = s.delete_prefix('ell')
- r.should_not equal s
+ r.should_not.equal? s
r.should == s
r = s.delete_prefix('')
- r.should_not equal s
+ r.should_not.equal? s
r.should == s
end
@@ -38,18 +39,9 @@ describe "String#delete_prefix" do
'hello'.delete_prefix(o).should == 'o'
end
- ruby_version_is ''...'3.0' do
- it "returns a subclass instance when called on a subclass instance" do
- s = StringSpecs::MyString.new('hello')
- s.delete_prefix('hell').should be_an_instance_of(StringSpecs::MyString)
- end
- end
-
- ruby_version_is '3.0' do
- it "returns a String instance when called on a subclass instance" do
- s = StringSpecs::MyString.new('hello')
- s.delete_prefix('hell').should be_an_instance_of(String)
- end
+ it "returns a String instance when called on a subclass instance" do
+ s = StringSpecs::MyString.new('hello')
+ s.delete_prefix('hell').should.instance_of?(String)
end
it "returns a String in the same encoding as self" do
@@ -60,7 +52,7 @@ end
describe "String#delete_prefix!" do
it "removes the found prefix" do
s = 'hello'
- s.delete_prefix!('hell').should equal(s)
+ s.delete_prefix!('hell').should.equal?(s)
s.should == 'o'
end
@@ -84,8 +76,8 @@ describe "String#delete_prefix!" do
end
it "raises a FrozenError when self is frozen" do
- -> { 'hello'.freeze.delete_prefix!('hell') }.should raise_error(FrozenError)
- -> { 'hello'.freeze.delete_prefix!('') }.should raise_error(FrozenError)
- -> { ''.freeze.delete_prefix!('') }.should raise_error(FrozenError)
+ -> { 'hello'.freeze.delete_prefix!('hell') }.should.raise(FrozenError)
+ -> { 'hello'.freeze.delete_prefix!('') }.should.raise(FrozenError)
+ -> { ''.freeze.delete_prefix!('') }.should.raise(FrozenError)
end
end