diff options
Diffstat (limited to 'spec/ruby/core/string/downcase_spec.rb')
| -rw-r--r-- | spec/ruby/core/string/downcase_spec.rb | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/spec/ruby/core/string/downcase_spec.rb b/spec/ruby/core/string/downcase_spec.rb index f0a15f1e25..4f7f44e5d4 100644 --- a/spec/ruby/core/string/downcase_spec.rb +++ b/spec/ruby/core/string/downcase_spec.rb @@ -1,4 +1,5 @@ # -*- encoding: utf-8 -*- +# frozen_string_literal: false require_relative '../../spec_helper' require_relative 'fixtures/classes' @@ -8,6 +9,10 @@ describe "String#downcase" do "hello".downcase.should == "hello" end + it "returns a String in the same encoding as self" do + "hELLO".encode("US-ASCII").downcase.encoding.should == Encoding::US_ASCII + end + describe "full Unicode case mapping" do it "works for all of Unicode with no option" do "ÄÖÜ".downcase.should == "äöü" @@ -19,7 +24,7 @@ describe "String#downcase" do downcased.should == "king" downcased.size.should == 4 downcased.bytesize.should == 4 - downcased.ascii_only?.should be_true + downcased.ascii_only?.should == true end end @@ -43,7 +48,7 @@ describe "String#downcase" do end it "does not allow any other additional option" do - -> { "İ".downcase(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { "İ".downcase(:turkic, :ascii) }.should.raise(ArgumentError) end end @@ -57,7 +62,7 @@ describe "String#downcase" do end it "does not allow any other additional option" do - -> { "İS".downcase(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { "İS".downcase(:lithuanian, :ascii) }.should.raise(ArgumentError) end end @@ -69,26 +74,18 @@ describe "String#downcase" do end it "does not allow invalid options" do - -> { "ABC".downcase(:invalid_option) }.should raise_error(ArgumentError) - end - - ruby_version_is ''...'3.0' do - it "returns a subclass instance for subclasses" do - StringSpecs::MyString.new("FOObar").downcase.should be_an_instance_of(StringSpecs::MyString) - end + -> { "ABC".downcase(:invalid_option) }.should.raise(ArgumentError) end - ruby_version_is '3.0' do - it "returns a String instance for subclasses" do - StringSpecs::MyString.new("FOObar").downcase.should be_an_instance_of(String) - end + it "returns a String instance for subclasses" do + StringSpecs::MyString.new("FOObar").downcase.should.instance_of?(String) end end describe "String#downcase!" do it "modifies self in place" do a = "HeLlO" - a.downcase!.should equal(a) + a.downcase!.should.equal?(a) a.should == "hello" end @@ -112,7 +109,7 @@ describe "String#downcase!" do downcased.should == "king" downcased.size.should == 4 downcased.bytesize.should == 4 - downcased.ascii_only?.should be_true + downcased.ascii_only?.should == true end end @@ -144,7 +141,7 @@ describe "String#downcase!" do end it "does not allow any other additional option" do - -> { a = "İ"; a.downcase!(:turkic, :ascii) }.should raise_error(ArgumentError) + -> { a = "İ"; a.downcase!(:turkic, :ascii) }.should.raise(ArgumentError) end end @@ -162,7 +159,7 @@ describe "String#downcase!" do end it "does not allow any other additional option" do - -> { a = "İS"; a.downcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError) + -> { a = "İS"; a.downcase!(:lithuanian, :ascii) }.should.raise(ArgumentError) end end @@ -178,7 +175,7 @@ describe "String#downcase!" do end it "does not allow invalid options" do - -> { a = "ABC"; a.downcase!(:invalid_option) }.should raise_error(ArgumentError) + -> { a = "ABC"; a.downcase!(:invalid_option) }.should.raise(ArgumentError) end it "returns nil if no modifications were made" do @@ -188,11 +185,11 @@ describe "String#downcase!" do end it "raises a FrozenError when self is frozen" do - -> { "HeLlo".freeze.downcase! }.should raise_error(FrozenError) - -> { "hello".freeze.downcase! }.should raise_error(FrozenError) + -> { "HeLlo".freeze.downcase! }.should.raise(FrozenError) + -> { "hello".freeze.downcase! }.should.raise(FrozenError) end it "sets the result String encoding to the source String encoding" do - "ABC".downcase.encoding.should equal(Encoding::UTF_8) + "ABC".downcase.encoding.should.equal?(Encoding::UTF_8) end end |
