diff options
Diffstat (limited to 'spec/ruby/core/string/setbyte_spec.rb')
| -rw-r--r-- | spec/ruby/core/string/setbyte_spec.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/spec/ruby/core/string/setbyte_spec.rb b/spec/ruby/core/string/setbyte_spec.rb index 03e5bad88b..d9fcc279c0 100644 --- a/spec/ruby/core/string/setbyte_spec.rb +++ b/spec/ruby/core/string/setbyte_spec.rb @@ -1,9 +1,10 @@ # -*- encoding: utf-8 -*- +# frozen_string_literal: false require_relative '../../spec_helper' describe "String#setbyte" do it "returns an Integer" do - "a".setbyte(0,1).should be_kind_of(Integer) + "a".setbyte(0,1).should.is_a?(Integer) end it "modifies the receiver" do @@ -33,9 +34,15 @@ describe "String#setbyte" do it "can invalidate a String's encoding" do str = "glark" - str.valid_encoding?.should be_true + str.valid_encoding?.should == true str.setbyte(2,253) - str.valid_encoding?.should be_false + str.valid_encoding?.should == false + + str = "ABC" + str.setbyte(0, 0x20) # ' ' + str.should.valid_encoding? + str.setbyte(0, 0xE3) + str.should_not.valid_encoding? end it "regards a negative index as counting from the end of the String" do @@ -51,11 +58,11 @@ describe "String#setbyte" do end it "raises an IndexError if the index is greater than the String bytesize" do - -> { "?".setbyte(1, 97) }.should raise_error(IndexError) + -> { "?".setbyte(1, 97) }.should.raise(IndexError) end it "raises an IndexError if the negative index is greater magnitude than the String bytesize" do - -> { "???".setbyte(-5, 97) }.should raise_error(IndexError) + -> { "???".setbyte(-5, 97) }.should.raise(IndexError) end it "sets a byte at an index greater than String size" do @@ -77,12 +84,12 @@ describe "String#setbyte" do it "raises a FrozenError if self is frozen" do str = "cold".freeze - str.frozen?.should be_true - -> { str.setbyte(3,96) }.should raise_error(FrozenError) + str.frozen?.should == true + -> { str.setbyte(3,96) }.should.raise(FrozenError) end it "raises a TypeError unless the second argument is an Integer" do - -> { "a".setbyte(0,'a') }.should raise_error(TypeError) + -> { "a".setbyte(0,'a') }.should.raise(TypeError) end it "calls #to_int to convert the index" do |
