summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/upcase_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/upcase_spec.rb')
-rw-r--r--spec/ruby/core/string/upcase_spec.rb43
1 files changed, 20 insertions, 23 deletions
diff --git a/spec/ruby/core/string/upcase_spec.rb b/spec/ruby/core/string/upcase_spec.rb
index 209fe73b6e..a6e1869267 100644
--- a/spec/ruby/core/string/upcase_spec.rb
+++ b/spec/ruby/core/string/upcase_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#upcase" do
"hello".upcase.should == "HELLO"
end
+ it "returns a String in the same encoding as self" do
+ "hello".encode("US-ASCII").upcase.encoding.should == Encoding::US_ASCII
+ end
+
describe "full Unicode case mapping" do
it "works for all of Unicode with no option" do
"äöü".upcase.should == "ÄÖÜ"
@@ -19,7 +24,7 @@ describe "String#upcase" do
upcased.should == "ASSET"
upcased.size.should == 5
upcased.bytesize.should == 5
- upcased.ascii_only?.should be_true
+ upcased.ascii_only?.should == true
end
end
@@ -43,7 +48,7 @@ describe "String#upcase" do
end
it "does not allow any other additional option" do
- -> { "i".upcase(:turkic, :ascii) }.should raise_error(ArgumentError)
+ -> { "i".upcase(:turkic, :ascii) }.should.raise(ArgumentError)
end
end
@@ -57,35 +62,27 @@ describe "String#upcase" do
end
it "does not allow any other additional option" do
- -> { "iß".upcase(:lithuanian, :ascii) }.should raise_error(ArgumentError)
+ -> { "iß".upcase(:lithuanian, :ascii) }.should.raise(ArgumentError)
end
end
it "does not allow the :fold option for upcasing" do
- -> { "abc".upcase(:fold) }.should raise_error(ArgumentError)
+ -> { "abc".upcase(:fold) }.should.raise(ArgumentError)
end
it "does not allow invalid options" do
- -> { "abc".upcase(: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").upcase.should be_an_instance_of(StringSpecs::MyString)
- end
+ -> { "abc".upcase(:invalid_option) }.should.raise(ArgumentError)
end
- ruby_version_is '3.0' do
- it "returns a String instance for subclasses" do
- StringSpecs::MyString.new("fooBAR").upcase.should be_an_instance_of(String)
- end
+ it "returns a String instance for subclasses" do
+ StringSpecs::MyString.new("fooBAR").upcase.should.instance_of?(String)
end
end
describe "String#upcase!" do
it "modifies self in place" do
a = "HeLlO"
- a.upcase!.should equal(a)
+ a.upcase!.should.equal?(a)
a.should == "HELLO"
end
@@ -115,7 +112,7 @@ describe "String#upcase!" do
upcased.should == "ASSET"
upcased.size.should == 5
upcased.bytesize.should == 5
- upcased.ascii_only?.should be_true
+ upcased.ascii_only?.should == true
end
end
@@ -147,7 +144,7 @@ describe "String#upcase!" do
end
it "does not allow any other additional option" do
- -> { a = "i"; a.upcase!(:turkic, :ascii) }.should raise_error(ArgumentError)
+ -> { a = "i"; a.upcase!(:turkic, :ascii) }.should.raise(ArgumentError)
end
end
@@ -165,16 +162,16 @@ describe "String#upcase!" do
end
it "does not allow any other additional option" do
- -> { a = "iß"; a.upcase!(:lithuanian, :ascii) }.should raise_error(ArgumentError)
+ -> { a = "iß"; a.upcase!(:lithuanian, :ascii) }.should.raise(ArgumentError)
end
end
it "does not allow the :fold option for upcasing" do
- -> { a = "abc"; a.upcase!(:fold) }.should raise_error(ArgumentError)
+ -> { a = "abc"; a.upcase!(:fold) }.should.raise(ArgumentError)
end
it "does not allow invalid options" do
- -> { a = "abc"; a.upcase!(:invalid_option) }.should raise_error(ArgumentError)
+ -> { a = "abc"; a.upcase!(:invalid_option) }.should.raise(ArgumentError)
end
it "returns nil if no modifications were made" do
@@ -184,7 +181,7 @@ describe "String#upcase!" do
end
it "raises a FrozenError when self is frozen" do
- -> { "HeLlo".freeze.upcase! }.should raise_error(FrozenError)
- -> { "HELLO".freeze.upcase! }.should raise_error(FrozenError)
+ -> { "HeLlo".freeze.upcase! }.should.raise(FrozenError)
+ -> { "HELLO".freeze.upcase! }.should.raise(FrozenError)
end
end