summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/shared/concat.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/string/shared/concat.rb')
-rw-r--r--spec/ruby/core/string/shared/concat.rb36
1 files changed, 18 insertions, 18 deletions
diff --git a/spec/ruby/core/string/shared/concat.rb b/spec/ruby/core/string/shared/concat.rb
index dded9a69e7..60cd0e12d4 100644
--- a/spec/ruby/core/string/shared/concat.rb
+++ b/spec/ruby/core/string/shared/concat.rb
@@ -2,7 +2,7 @@
describe :string_concat, shared: true do
it "concatenates the given argument to self and returns self" do
str = 'hello '
- str.send(@method, 'world').should equal(str)
+ str.send(@method, 'world').should.equal?(str)
str.should == "hello world"
end
@@ -10,22 +10,22 @@ describe :string_concat, shared: true do
a = "hello"
a.freeze
- -> { a.send(@method, "") }.should raise_error(FrozenError)
- -> { a.send(@method, "test") }.should raise_error(FrozenError)
+ -> { a.send(@method, "") }.should.raise(FrozenError)
+ -> { a.send(@method, "test") }.should.raise(FrozenError)
end
it "returns a String when given a subclass instance" do
a = "hello"
a.send(@method, StringSpecs::MyString.new(" world"))
a.should == "hello world"
- a.should be_an_instance_of(String)
+ a.should.instance_of?(String)
end
it "returns an instance of same class when called on a subclass" do
str = StringSpecs::MyString.new("hello")
str.send(@method, " world")
str.should == "hello world"
- str.should be_an_instance_of(StringSpecs::MyString)
+ str.should.instance_of?(StringSpecs::MyString)
end
describe "with Integer" do
@@ -50,28 +50,28 @@ describe :string_concat, shared: true do
end
it "raises RangeError if the argument is an invalid codepoint for self's encoding" do
- -> { "".encode(Encoding::US_ASCII).send(@method, 256) }.should raise_error(RangeError)
- -> { "".encode(Encoding::EUC_JP).send(@method, 0x81) }.should raise_error(RangeError)
+ -> { "".encode(Encoding::US_ASCII).send(@method, 256) }.should.raise(RangeError)
+ -> { "".encode(Encoding::EUC_JP).send(@method, 0x81) }.should.raise(RangeError)
end
it "raises RangeError if the argument is negative" do
- -> { "".send(@method, -200) }.should raise_error(RangeError)
- -> { "".send(@method, -bignum_value) }.should raise_error(RangeError)
+ -> { "".send(@method, -200) }.should.raise(RangeError)
+ -> { "".send(@method, -bignum_value) }.should.raise(RangeError)
end
it "doesn't call to_int on its argument" do
x = mock('x')
x.should_not_receive(:to_int)
- -> { "".send(@method, x) }.should raise_error(TypeError)
+ -> { "".send(@method, x) }.should.raise(TypeError)
end
it "raises a FrozenError when self is frozen" do
a = "hello"
a.freeze
- -> { a.send(@method, 0) }.should raise_error(FrozenError)
- -> { a.send(@method, 33) }.should raise_error(FrozenError)
+ -> { a.send(@method, 0) }.should.raise(FrozenError)
+ -> { a.send(@method, 33) }.should.raise(FrozenError)
end
end
end
@@ -91,7 +91,7 @@ describe :string_concat_encoding, shared: true do
end
it "raises Encoding::CompatibilityError if neither are empty" do
- -> { "x".encode("UTF-16LE").send(@method, "y".encode("UTF-8")) }.should raise_error(Encoding::CompatibilityError)
+ -> { "x".encode("UTF-16LE").send(@method, "y".encode("UTF-8")) }.should.raise(Encoding::CompatibilityError)
end
end
@@ -109,7 +109,7 @@ describe :string_concat_encoding, shared: true do
end
it "raises Encoding::CompatibilityError if neither are empty" do
- -> { "x".encode("UTF-8").send(@method, "y".encode("UTF-16LE")) }.should raise_error(Encoding::CompatibilityError)
+ -> { "x".encode("UTF-8").send(@method, "y".encode("UTF-16LE")) }.should.raise(Encoding::CompatibilityError)
end
end
@@ -127,7 +127,7 @@ describe :string_concat_encoding, shared: true do
end
it "raises Encoding::CompatibilityError if neither are ASCII-only" do
- -> { "\u00E9".encode("UTF-8").send(@method, "\u00E9".encode("ISO-8859-1")) }.should raise_error(Encoding::CompatibilityError)
+ -> { "\u00E9".encode("UTF-8").send(@method, "\u00E9".encode("ISO-8859-1")) }.should.raise(Encoding::CompatibilityError)
end
end
@@ -147,13 +147,13 @@ describe :string_concat_type_coercion, shared: true do
end
it "raises a TypeError if the given argument can't be converted to a String" do
- -> { 'hello '.send(@method, []) }.should raise_error(TypeError)
- -> { 'hello '.send(@method, mock('x')) }.should raise_error(TypeError)
+ -> { 'hello '.send(@method, []) }.should.raise(TypeError)
+ -> { 'hello '.send(@method, mock('x')) }.should.raise(TypeError)
end
it "raises a NoMethodError if the given argument raises a NoMethodError during type coercion to a String" do
obj = mock('world!')
obj.should_receive(:to_str).and_raise(NoMethodError)
- -> { 'hello '.send(@method, obj) }.should raise_error(NoMethodError)
+ -> { 'hello '.send(@method, obj) }.should.raise(NoMethodError)
end
end