summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/center_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/center_spec.rb')
-rw-r--r--spec/ruby/core/string/center_spec.rb34
1 files changed, 17 insertions, 17 deletions
diff --git a/spec/ruby/core/string/center_spec.rb b/spec/ruby/core/string/center_spec.rb
index 1667b59327..ac5b8a2ff3 100644
--- a/spec/ruby/core/string/center_spec.rb
+++ b/spec/ruby/core/string/center_spec.rb
@@ -57,10 +57,10 @@ describe "String#center with length, padding" do
end
it "raises a TypeError when length can't be converted to an integer" do
- -> { "hello".center("x") }.should raise_error(TypeError)
- -> { "hello".center("x", "y") }.should raise_error(TypeError)
- -> { "hello".center([]) }.should raise_error(TypeError)
- -> { "hello".center(mock('x')) }.should raise_error(TypeError)
+ -> { "hello".center("x") }.should.raise(TypeError)
+ -> { "hello".center("x", "y") }.should.raise(TypeError)
+ -> { "hello".center([]) }.should.raise(TypeError)
+ -> { "hello".center(mock('x')) }.should.raise(TypeError)
end
it "calls #to_str to convert padstr to a String" do
@@ -71,23 +71,23 @@ describe "String#center with length, padding" do
end
it "raises a TypeError when padstr can't be converted to a string" do
- -> { "hello".center(20, 100) }.should raise_error(TypeError)
- -> { "hello".center(20, []) }.should raise_error(TypeError)
- -> { "hello".center(20, mock('x')) }.should raise_error(TypeError)
+ -> { "hello".center(20, 100) }.should.raise(TypeError)
+ -> { "hello".center(20, []) }.should.raise(TypeError)
+ -> { "hello".center(20, mock('x')) }.should.raise(TypeError)
end
it "raises an ArgumentError if padstr is empty" do
- -> { "hello".center(10, "") }.should raise_error(ArgumentError)
- -> { "hello".center(0, "") }.should raise_error(ArgumentError)
+ -> { "hello".center(10, "") }.should.raise(ArgumentError)
+ -> { "hello".center(0, "") }.should.raise(ArgumentError)
end
it "returns String instances when called on subclasses" do
- StringSpecs::MyString.new("").center(10).should be_an_instance_of(String)
- StringSpecs::MyString.new("foo").center(10).should be_an_instance_of(String)
- StringSpecs::MyString.new("foo").center(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String)
+ StringSpecs::MyString.new("").center(10).should.instance_of?(String)
+ StringSpecs::MyString.new("foo").center(10).should.instance_of?(String)
+ StringSpecs::MyString.new("foo").center(10, StringSpecs::MyString.new("x")).should.instance_of?(String)
- "".center(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String)
- "foo".center(10, StringSpecs::MyString.new("x")).should be_an_instance_of(String)
+ "".center(10, StringSpecs::MyString.new("x")).should.instance_of?(String)
+ "foo".center(10, StringSpecs::MyString.new("x")).should.instance_of?(String)
end
describe "with width" do
@@ -95,7 +95,7 @@ describe "String#center with length, padding" do
str = "abc".dup.force_encoding Encoding::IBM437
result = str.center 6
result.should == " abc "
- result.encoding.should equal(Encoding::IBM437)
+ result.encoding.should.equal?(Encoding::IBM437)
end
end
@@ -104,14 +104,14 @@ describe "String#center with length, padding" do
str = "abc".dup.force_encoding Encoding::IBM437
result = str.center 6, "あ"
result.should == "あabcああ"
- result.encoding.should equal(Encoding::UTF_8)
+ result.encoding.should.equal?(Encoding::UTF_8)
end
it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
pat = "ア".encode Encoding::EUC_JP
-> do
"あれ".center 5, pat
- end.should raise_error(Encoding::CompatibilityError)
+ end.should.raise(Encoding::CompatibilityError)
end
end
end