diff options
Diffstat (limited to 'spec/ruby/core/string/slice_spec.rb')
| -rw-r--r-- | spec/ruby/core/string/slice_spec.rb | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/spec/ruby/core/string/slice_spec.rb b/spec/ruby/core/string/slice_spec.rb index 87c5a7ac37..14e2251b3f 100644 --- a/spec/ruby/core/string/slice_spec.rb +++ b/spec/ruby/core/string/slice_spec.rb @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- - +# frozen_string_literal: false require_relative '../../spec_helper' require_relative 'fixtures/classes' require_relative 'shared/slice' @@ -54,9 +54,9 @@ describe "String#slice! with index" do end it "raises a FrozenError if self is frozen" do - -> { "hello".freeze.slice!(1) }.should raise_error(FrozenError) - -> { "hello".freeze.slice!(10) }.should raise_error(FrozenError) - -> { "".freeze.slice!(0) }.should raise_error(FrozenError) + -> { "hello".freeze.slice!(1) }.should.raise(FrozenError) + -> { "hello".freeze.slice!(10) }.should.raise(FrozenError) + -> { "".freeze.slice!(0) }.should.raise(FrozenError) end it "calls to_int on index" do @@ -110,13 +110,13 @@ describe "String#slice! with index, length" do end it "raises a FrozenError if self is frozen" do - -> { "hello".freeze.slice!(1, 2) }.should raise_error(FrozenError) - -> { "hello".freeze.slice!(10, 3) }.should raise_error(FrozenError) - -> { "hello".freeze.slice!(-10, 3)}.should raise_error(FrozenError) - -> { "hello".freeze.slice!(4, -3) }.should raise_error(FrozenError) - -> { "hello".freeze.slice!(10, 3) }.should raise_error(FrozenError) - -> { "hello".freeze.slice!(-10, 3)}.should raise_error(FrozenError) - -> { "hello".freeze.slice!(4, -3) }.should raise_error(FrozenError) + -> { "hello".freeze.slice!(1, 2) }.should.raise(FrozenError) + -> { "hello".freeze.slice!(10, 3) }.should.raise(FrozenError) + -> { "hello".freeze.slice!(-10, 3)}.should.raise(FrozenError) + -> { "hello".freeze.slice!(4, -3) }.should.raise(FrozenError) + -> { "hello".freeze.slice!(10, 3) }.should.raise(FrozenError) + -> { "hello".freeze.slice!(-10, 3)}.should.raise(FrozenError) + -> { "hello".freeze.slice!(4, -3) }.should.raise(FrozenError) end it "calls to_int on idx and length" do @@ -134,8 +134,8 @@ describe "String#slice! with index, length" do it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.slice!(0, 0).should be_an_instance_of(String) - s.slice!(0, 4).should be_an_instance_of(String) + s.slice!(0, 0).should.instance_of?(String) + s.slice!(0, 4).should.instance_of?(String) end it "returns the substring given by the character offsets" do @@ -177,8 +177,8 @@ describe "String#slice! Range" do it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.slice!(0...0).should be_an_instance_of(String) - s.slice!(0..4).should be_an_instance_of(String) + s.slice!(0...0).should.instance_of?(String) + s.slice!(0..4).should.instance_of?(String) end it "calls to_int on range arguments" do @@ -228,12 +228,12 @@ describe "String#slice! Range" do it "raises a FrozenError on a frozen instance that is modified" do - -> { "hello".freeze.slice!(1..3) }.should raise_error(FrozenError) + -> { "hello".freeze.slice!(1..3) }.should.raise(FrozenError) end # see redmine #1551 it "raises a FrozenError on a frozen instance that would not be modified" do - -> { "hello".freeze.slice!(10..20)}.should raise_error(FrozenError) + -> { "hello".freeze.slice!(10..20)}.should.raise(FrozenError) end end @@ -256,8 +256,8 @@ describe "String#slice! with Regexp" do it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.slice!(//).should be_an_instance_of(String) - s.slice!(/../).should be_an_instance_of(String) + s.slice!(//).should.instance_of?(String) + s.slice!(/../).should.instance_of?(String) end it "returns the matching portion of self with a multi byte character" do @@ -274,11 +274,11 @@ describe "String#slice! with Regexp" do end it "raises a FrozenError on a frozen instance that is modified" do - -> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(FrozenError) + -> { "this is a string".freeze.slice!(/s.*t/) }.should.raise(FrozenError) end it "raises a FrozenError on a frozen instance that would not be modified" do - -> { "this is a string".freeze.slice!(/zzz/) }.should raise_error(FrozenError) + -> { "this is a string".freeze.slice!(/zzz/) }.should.raise(FrozenError) end end @@ -316,8 +316,8 @@ describe "String#slice! with Regexp, index" do it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.slice!(/(.)(.)/, 0).should be_an_instance_of(String) - s.slice!(/(.)(.)/, 1).should be_an_instance_of(String) + s.slice!(/(.)(.)/, 0).should.instance_of?(String) + s.slice!(/(.)(.)/, 1).should.instance_of?(String) end it "returns the encoding aware capture for the given index" do @@ -342,9 +342,9 @@ describe "String#slice! with Regexp, index" do end it "raises a FrozenError if self is frozen" do - -> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(FrozenError) - -> { "this is a string".freeze.slice!(/zzz/, 0)}.should raise_error(FrozenError) - -> { "this is a string".freeze.slice!(/(.)/, 2)}.should raise_error(FrozenError) + -> { "this is a string".freeze.slice!(/s.*t/) }.should.raise(FrozenError) + -> { "this is a string".freeze.slice!(/zzz/, 0)}.should.raise(FrozenError) + -> { "this is a string".freeze.slice!(/(.)/, 2)}.should.raise(FrozenError) end end @@ -372,19 +372,19 @@ describe "String#slice! with String" do o = mock('x') o.should_not_receive(:to_str) - -> { "hello".slice!(o) }.should raise_error(TypeError) + -> { "hello".slice!(o) }.should.raise(TypeError) end it "returns a subclass instance when given a subclass instance" do s = StringSpecs::MyString.new("el") r = "hello".slice!(s) r.should == "el" - r.should be_an_instance_of(String) + r.should.instance_of?(String) end it "raises a FrozenError if self is frozen" do - -> { "hello hello".freeze.slice!('llo') }.should raise_error(FrozenError) - -> { "this is a string".freeze.slice!('zzz')}.should raise_error(FrozenError) - -> { "this is a string".freeze.slice!('zzz')}.should raise_error(FrozenError) + -> { "hello hello".freeze.slice!('llo') }.should.raise(FrozenError) + -> { "this is a string".freeze.slice!('zzz')}.should.raise(FrozenError) + -> { "this is a string".freeze.slice!('zzz')}.should.raise(FrozenError) end end |
