diff options
Diffstat (limited to 'spec/ruby/core/string/center_spec.rb')
-rw-r--r-- | spec/ruby/core/string/center_spec.rb | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/spec/ruby/core/string/center_spec.rb b/spec/ruby/core/string/center_spec.rb index 145db01b70..3a9e689eac 100644 --- a/spec/ruby/core/string/center_spec.rb +++ b/spec/ruby/core/string/center_spec.rb @@ -104,30 +104,28 @@ describe "String#center with length, padding" do "hello".center(6, 'X'.taint).tainted?.should be_true end - with_feature :encoding do - describe "with width" do - it "returns a String in the same encoding as the original" do - str = "abc".force_encoding Encoding::IBM437 - result = str.center 6 - result.should == " abc " - result.encoding.should equal(Encoding::IBM437) - end + describe "with width" do + it "returns a String in the same encoding as the original" do + str = "abc".force_encoding Encoding::IBM437 + result = str.center 6 + result.should == " abc " + result.encoding.should equal(Encoding::IBM437) + end + end + + describe "with width, pattern" do + it "returns a String in the compatible encoding" do + str = "abc".force_encoding Encoding::IBM437 + result = str.center 6, "あ" + result.should == "あabcああ" + result.encoding.should equal(Encoding::UTF_8) end - describe "with width, pattern" do - it "returns a String in the compatible encoding" do - str = "abc".force_encoding Encoding::IBM437 - result = str.center 6, "あ" - result.should == "あabcああ" - result.encoding.should equal(Encoding::UTF_8) - end - - it "raises an Encoding::CompatibilityError if the encodings are incompatible" do - pat = "ア".encode Encoding::EUC_JP - lambda do - "あれ".center 5, pat - end.should raise_error(Encoding::CompatibilityError) - end + it "raises an Encoding::CompatibilityError if the encodings are incompatible" do + pat = "ア".encode Encoding::EUC_JP + lambda do + "あれ".center 5, pat + end.should raise_error(Encoding::CompatibilityError) end end end |