diff options
Diffstat (limited to 'spec/ruby/core/string/delete_suffix_spec.rb')
-rw-r--r-- | spec/ruby/core/string/delete_suffix_spec.rb | 124 |
1 files changed, 61 insertions, 63 deletions
diff --git a/spec/ruby/core/string/delete_suffix_spec.rb b/spec/ruby/core/string/delete_suffix_spec.rb index 4bc0549c88..d5b6880193 100644 --- a/spec/ruby/core/string/delete_suffix_spec.rb +++ b/spec/ruby/core/string/delete_suffix_spec.rb @@ -2,82 +2,80 @@ require_relative '../../spec_helper' require_relative 'fixtures/classes' -ruby_version_is '2.5' do - describe "String#delete_suffix" do - it "returns a copy of the string, with the given suffix removed" do - 'hello'.delete_suffix('ello').should == 'h' - 'hello'.delete_suffix('hello').should == '' - end +describe "String#delete_suffix" do + it "returns a copy of the string, with the given suffix removed" do + 'hello'.delete_suffix('ello').should == 'h' + 'hello'.delete_suffix('hello').should == '' + end - it "returns a copy of the string, when the suffix isn't found" do - s = 'hello' - r = s.delete_suffix('!hello') - r.should_not equal s - r.should == s - r = s.delete_suffix('ell') - r.should_not equal s - r.should == s - r = s.delete_suffix('') - r.should_not equal s - r.should == s - end + it "returns a copy of the string, when the suffix isn't found" do + s = 'hello' + r = s.delete_suffix('!hello') + r.should_not equal s + r.should == s + r = s.delete_suffix('ell') + r.should_not equal s + r.should == s + r = s.delete_suffix('') + r.should_not equal s + r.should == s + end - ruby_version_is ''...'2.7' do - it "taints resulting strings when other is tainted" do - 'hello'.taint.delete_suffix('ello').tainted?.should == true - 'hello'.taint.delete_suffix('').tainted?.should == true - end + ruby_version_is ''...'2.7' do + it "taints resulting strings when other is tainted" do + 'hello'.taint.delete_suffix('ello').tainted?.should == true + 'hello'.taint.delete_suffix('').tainted?.should == true end + end - it "doesn't set $~" do - $~ = nil + it "doesn't set $~" do + $~ = nil - 'hello'.delete_suffix('ello') - $~.should == nil - end + 'hello'.delete_suffix('ello') + $~.should == nil + end - it "calls to_str on its argument" do - o = mock('x') - o.should_receive(:to_str).and_return 'ello' - 'hello'.delete_suffix(o).should == 'h' - end + it "calls to_str on its argument" do + o = mock('x') + o.should_receive(:to_str).and_return 'ello' + 'hello'.delete_suffix(o).should == 'h' + end - it "returns a subclass instance when called on a subclass instance" do - s = StringSpecs::MyString.new('hello') - s.delete_suffix('ello').should be_an_instance_of(StringSpecs::MyString) - end + it "returns a subclass instance when called on a subclass instance" do + s = StringSpecs::MyString.new('hello') + s.delete_suffix('ello').should be_an_instance_of(StringSpecs::MyString) end +end - describe "String#delete_suffix!" do - it "removes the found prefix" do - s = 'hello' - s.delete_suffix!('ello').should equal(s) - s.should == 'h' - end +describe "String#delete_suffix!" do + it "removes the found prefix" do + s = 'hello' + s.delete_suffix!('ello').should equal(s) + s.should == 'h' + end - it "returns nil if no change is made" do - s = 'hello' - s.delete_suffix!('ell').should == nil - s.delete_suffix!('').should == nil - end + it "returns nil if no change is made" do + s = 'hello' + s.delete_suffix!('ell').should == nil + s.delete_suffix!('').should == nil + end - it "doesn't set $~" do - $~ = nil + it "doesn't set $~" do + $~ = nil - 'hello'.delete_suffix!('ello') - $~.should == nil - end + 'hello'.delete_suffix!('ello') + $~.should == nil + end - it "calls to_str on its argument" do - o = mock('x') - o.should_receive(:to_str).and_return 'ello' - 'hello'.delete_suffix!(o).should == 'h' - end + it "calls to_str on its argument" do + o = mock('x') + o.should_receive(:to_str).and_return 'ello' + 'hello'.delete_suffix!(o).should == 'h' + end - it "raises a FrozenError when self is frozen" do - -> { 'hello'.freeze.delete_suffix!('ello') }.should raise_error(FrozenError) - -> { 'hello'.freeze.delete_suffix!('') }.should raise_error(FrozenError) - -> { ''.freeze.delete_suffix!('') }.should raise_error(FrozenError) - end + it "raises a FrozenError when self is frozen" do + -> { 'hello'.freeze.delete_suffix!('ello') }.should raise_error(FrozenError) + -> { 'hello'.freeze.delete_suffix!('') }.should raise_error(FrozenError) + -> { ''.freeze.delete_suffix!('') }.should raise_error(FrozenError) end end |