diff options
Diffstat (limited to 'spec/ruby/core/string/shared')
20 files changed, 240 insertions, 176 deletions
diff --git a/spec/ruby/core/string/shared/byte_index_common.rb b/spec/ruby/core/string/shared/byte_index_common.rb index 3de1453f4f..bae6cff49f 100644 --- a/spec/ruby/core/string/shared/byte_index_common.rb +++ b/spec/ruby/core/string/shared/byte_index_common.rb @@ -4,43 +4,43 @@ require_relative '../../../spec_helper' describe :byte_index_common, shared: true do describe "raises on type errors" do it "raises a TypeError if passed nil" do - -> { "abc".send(@method, nil) }.should raise_error(TypeError, "no implicit conversion of nil into String") + -> { "abc".send(@method, nil) }.should.raise(TypeError, "no implicit conversion of nil into String") end it "raises a TypeError if passed a boolean" do - -> { "abc".send(@method, true) }.should raise_error(TypeError, "no implicit conversion of true into String") + -> { "abc".send(@method, true) }.should.raise(TypeError, "no implicit conversion of true into String") end it "raises a TypeError if passed a Symbol" do not_supported_on :opal do - -> { "abc".send(@method, :a) }.should raise_error(TypeError, "no implicit conversion of Symbol into String") + -> { "abc".send(@method, :a) }.should.raise(TypeError, "no implicit conversion of Symbol into String") end end it "raises a TypeError if passed a Symbol" do obj = mock('x') obj.should_not_receive(:to_int) - -> { "hello".send(@method, obj) }.should raise_error(TypeError, "no implicit conversion of MockObject into String") + -> { "hello".send(@method, obj) }.should.raise(TypeError, "no implicit conversion of MockObject into String") end it "raises a TypeError if passed an Integer" do - -> { "abc".send(@method, 97) }.should raise_error(TypeError, "no implicit conversion of Integer into String") + -> { "abc".send(@method, 97) }.should.raise(TypeError, "no implicit conversion of Integer into String") end end describe "with multibyte codepoints" do it "raises an IndexError when byte offset lands in the middle of a multibyte character" do - -> { "わ".send(@method, "", 1) }.should raise_error(IndexError, "offset 1 does not land on character boundary") - -> { "わ".send(@method, "", 2) }.should raise_error(IndexError, "offset 2 does not land on character boundary") - -> { "わ".send(@method, "", -1) }.should raise_error(IndexError, "offset 2 does not land on character boundary") - -> { "わ".send(@method, "", -2) }.should raise_error(IndexError, "offset 1 does not land on character boundary") + -> { "わ".send(@method, "", 1) }.should.raise(IndexError, "offset 1 does not land on character boundary") + -> { "わ".send(@method, "", 2) }.should.raise(IndexError, "offset 2 does not land on character boundary") + -> { "わ".send(@method, "", -1) }.should.raise(IndexError, "offset 2 does not land on character boundary") + -> { "わ".send(@method, "", -2) }.should.raise(IndexError, "offset 1 does not land on character boundary") end it "raises an Encoding::CompatibilityError if the encodings are incompatible" do re = Regexp.new "れ".encode(Encoding::EUC_JP) -> do "あれ".send(@method, re) - end.should raise_error(Encoding::CompatibilityError, "incompatible encoding regexp match (EUC-JP regexp with UTF-8 string)") + end.should.raise(Encoding::CompatibilityError, "incompatible encoding regexp match (EUC-JP regexp with UTF-8 string)") end end diff --git a/spec/ruby/core/string/shared/chars.rb b/spec/ruby/core/string/shared/chars.rb index c730643cf4..826d403589 100644 --- a/spec/ruby/core/string/shared/chars.rb +++ b/spec/ruby/core/string/shared/chars.rb @@ -11,10 +11,9 @@ describe :string_chars, shared: true do it "returns self" do s = StringSpecs::MyString.new "hello" - s.send(@method){}.should equal(s) + s.send(@method){}.should.equal?(s) end - it "is unicode aware" do "\303\207\342\210\202\303\251\306\222g".send(@method).to_a.should == ["\303\207", "\342\210\202", "\303\251", "\306\222", "g"] @@ -34,7 +33,7 @@ describe :string_chars, shared: true do it "works if the String's contents is invalid for its encoding" do xA4 = [0xA4].pack('C') xA4.force_encoding('UTF-8') - xA4.valid_encoding?.should be_false + xA4.valid_encoding?.should == false xA4.send(@method).to_a.should == [xA4.force_encoding("UTF-8")] end @@ -63,4 +62,25 @@ describe :string_chars, shared: true do [0xA2].pack('C').force_encoding('SJIS') ] end + + it "returns individual chars for dummy encodings" do + "ab".dup.force_encoding(Encoding::UTF_7).send(@method).to_a.should == [ + "\x61".dup.force_encoding(Encoding::UTF_7), + "\x62".dup.force_encoding(Encoding::UTF_7) + ] + + "abcd".dup.force_encoding(Encoding::UTF_16).send(@method).to_a.should == [ + "\x61".dup.force_encoding(Encoding::UTF_16), + "\x62".dup.force_encoding(Encoding::UTF_16), + "\x63".dup.force_encoding(Encoding::UTF_16), + "\x64".dup.force_encoding(Encoding::UTF_16) + ] + + "abcd".dup.force_encoding(Encoding::UTF_32).send(@method).to_a.should == [ + "\x61".dup.force_encoding(Encoding::UTF_32), + "\x62".dup.force_encoding(Encoding::UTF_32), + "\x63".dup.force_encoding(Encoding::UTF_32), + "\x64".dup.force_encoding(Encoding::UTF_32) + ] + end end diff --git a/spec/ruby/core/string/shared/codepoints.rb b/spec/ruby/core/string/shared/codepoints.rb index f71263054a..b6abf6a3ff 100644 --- a/spec/ruby/core/string/shared/codepoints.rb +++ b/spec/ruby/core/string/shared/codepoints.rb @@ -1,15 +1,15 @@ -# -*- encoding: binary -*- +# encoding: binary describe :string_codepoints, shared: true do it "returns self" do s = "foo" result = s.send(@method) {} - result.should equal s + result.should.equal? s end it "raises an ArgumentError when self has an invalid encoding and a method is called on the returned Enumerator" do s = "\xDF".dup.force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - -> { s.send(@method).to_a }.should raise_error(ArgumentError) + s.valid_encoding?.should == false + -> { s.send(@method).to_a }.should.raise(ArgumentError) end it "yields each codepoint to the block if one is given" do @@ -22,13 +22,13 @@ describe :string_codepoints, shared: true do it "raises an ArgumentError if self's encoding is invalid and a block is given" do s = "\xDF".dup.force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - -> { s.send(@method) { } }.should raise_error(ArgumentError) + s.valid_encoding?.should == false + -> { s.send(@method) { } }.should.raise(ArgumentError) end it "yields codepoints as Integers" do "glark\u{20}".send(@method).to_a.each do |codepoint| - codepoint.should be_an_instance_of(Integer) + codepoint.should.instance_of?(Integer) end end @@ -56,7 +56,12 @@ describe :string_codepoints, shared: true do it "is synonymous with #bytes for Strings which are single-byte optimizable" do s = "(){}".encode('ascii') - s.ascii_only?.should be_true + s.ascii_only?.should == true s.send(@method).to_a.should == s.bytes.to_a end + + it "returns individual bytes for dummy encodings UTF-16 and UTF-32" do + "abcd".dup.force_encoding(Encoding::UTF_16).send(@method).to_a.should == [97, 98, 99, 100] + "abcd".dup.force_encoding(Encoding::UTF_32).send(@method).to_a.should == [97, 98, 99, 100] + end end 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 diff --git a/spec/ruby/core/string/shared/dedup.rb b/spec/ruby/core/string/shared/dedup.rb index 1ffd6aa0fd..59506c2901 100644 --- a/spec/ruby/core/string/shared/dedup.rb +++ b/spec/ruby/core/string/shared/dedup.rb @@ -4,7 +4,7 @@ describe :string_dedup, shared: true do input = 'foo'.freeze output = input.send(@method) - output.should equal(input) + output.should.equal?(input) output.should.frozen? end @@ -13,7 +13,7 @@ describe :string_dedup, shared: true do output = input.send(@method) output.should.frozen? - output.should_not equal(input) + output.should_not.equal?(input) output.should == 'foo' end @@ -21,22 +21,22 @@ describe :string_dedup, shared: true do origin = "this is a string" dynamic = %w(this is a string).join(' ') - origin.should_not equal(dynamic) - origin.send(@method).should equal(dynamic.send(@method)) + origin.should_not.equal?(dynamic) + origin.send(@method).should.equal?(dynamic.send(@method)) end it "returns the same object when it's called on the same String literal" do - "unfrozen string".send(@method).should equal("unfrozen string".send(@method)) - "unfrozen string".send(@method).should_not equal("another unfrozen string".send(@method)) + "unfrozen string".send(@method).should.equal?("unfrozen string".send(@method)) + "unfrozen string".send(@method).should_not.equal?("another unfrozen string".send(@method)) end it "deduplicates frozen strings" do dynamic = %w(this string is frozen).join(' ').freeze - dynamic.should_not equal("this string is frozen".freeze) + dynamic.should_not.equal?("this string is frozen".freeze) - dynamic.send(@method).should equal("this string is frozen".freeze) - dynamic.send(@method).should equal("this string is frozen".send(@method).freeze) + dynamic.send(@method).should.equal?("this string is frozen".freeze) + dynamic.send(@method).should.equal?("this string is frozen".send(@method).freeze) end it "does not deduplicate a frozen string when it has instance variables" do @@ -44,8 +44,8 @@ describe :string_dedup, shared: true do dynamic.instance_variable_set(:@a, 1) dynamic.freeze - dynamic.send(@method).should_not equal("this string is frozen".freeze) - dynamic.send(@method).should_not equal("this string is frozen".send(@method).freeze) - dynamic.send(@method).should equal(dynamic) + dynamic.send(@method).should_not.equal?("this string is frozen".freeze) + dynamic.send(@method).should_not.equal?("this string is frozen".send(@method).freeze) + dynamic.send(@method).should.equal?(dynamic) end end diff --git a/spec/ruby/core/string/shared/each_char_without_block.rb b/spec/ruby/core/string/shared/each_char_without_block.rb index 397100ce0e..3c32bae42b 100644 --- a/spec/ruby/core/string/shared/each_char_without_block.rb +++ b/spec/ruby/core/string/shared/each_char_without_block.rb @@ -6,7 +6,7 @@ describe :string_each_char_without_block, shared: true do describe "when no block is given" do it "returns an enumerator" do enum = "hello".send(@method) - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == ['h', 'e', 'l', 'l', 'o'] end diff --git a/spec/ruby/core/string/shared/each_codepoint_without_block.rb b/spec/ruby/core/string/shared/each_codepoint_without_block.rb index 31b4c02c9c..60d603954c 100644 --- a/spec/ruby/core/string/shared/each_codepoint_without_block.rb +++ b/spec/ruby/core/string/shared/each_codepoint_without_block.rb @@ -1,14 +1,14 @@ -# -*- encoding: binary -*- +# encoding: binary describe :string_each_codepoint_without_block, shared: true do describe "when no block is given" do it "returns an Enumerator" do - "".send(@method).should be_an_instance_of(Enumerator) + "".send(@method).should.instance_of?(Enumerator) end it "returns an Enumerator even when self has an invalid encoding" do s = "\xDF".dup.force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false - s.send(@method).should be_an_instance_of(Enumerator) + s.valid_encoding?.should == false + s.send(@method).should.instance_of?(Enumerator) end describe "returned Enumerator" do @@ -24,7 +24,7 @@ describe :string_each_codepoint_without_block, shared: true do it "should return the size of the string even when the string has an invalid encoding" do s = "\xDF".dup.force_encoding(Encoding::UTF_8) - s.valid_encoding?.should be_false + s.valid_encoding?.should == false s.send(@method).size.should == 1 end end diff --git a/spec/ruby/core/string/shared/each_line.rb b/spec/ruby/core/string/shared/each_line.rb index 231a6d9d4f..d79c2b74c4 100644 --- a/spec/ruby/core/string/shared/each_line.rb +++ b/spec/ruby/core/string/shared/each_line.rb @@ -93,7 +93,7 @@ describe :string_each_line, shared: true do it "returns self" do s = "hello\nworld" - (s.send(@method) {}).should equal(s) + (s.send(@method) {}).should.equal?(s) end it "tries to convert the separator to a string using to_str" do @@ -119,8 +119,8 @@ describe :string_each_line, shared: true do end it "raises a TypeError when the separator can't be converted to a string" do - -> { "hello world".send(@method, false) {} }.should raise_error(TypeError) - -> { "hello world".send(@method, mock('x')) {} }.should raise_error(TypeError) + -> { "hello world".send(@method, false) {} }.should.raise(TypeError) + -> { "hello world".send(@method, mock('x')) {} }.should.raise(TypeError) end it "accepts a string separator" do @@ -128,7 +128,7 @@ describe :string_each_line, shared: true do end it "raises a TypeError when the separator is a symbol" do - -> { "hello world".send(@method, :o).to_a }.should raise_error(TypeError) + -> { "hello world".send(@method, :o).to_a }.should.raise(TypeError) end context "when `chomp` keyword argument is passed" do @@ -159,4 +159,18 @@ describe :string_each_line, shared: true do a.should == ["hello\r\n", "world\r\n"] end end + + it "does not split lines for dummy UTF-16" do + "a\nb".encode(Encoding::UTF_16).lines.should == [ + "\xFE\xFF\x00\x61\x00\n\x00\x62".dup.force_encoding(Encoding::UTF_16) + ] + + str = "\x00\n\n\x00".dup.force_encoding(Encoding::UTF_16) + str.lines.should == [str] + end + + it "raises Encoding::ConverterNotFoundError for dummy UTF-7" do + str = "a\nb".dup.force_encoding(Encoding::UTF_7) + -> { str.lines }.should.raise(Encoding::ConverterNotFoundError) + end end diff --git a/spec/ruby/core/string/shared/each_line_without_block.rb b/spec/ruby/core/string/shared/each_line_without_block.rb index 8e08b0390c..af0ab69c00 100644 --- a/spec/ruby/core/string/shared/each_line_without_block.rb +++ b/spec/ruby/core/string/shared/each_line_without_block.rb @@ -2,7 +2,7 @@ describe :string_each_line_without_block, shared: true do describe "when no block is given" do it "returns an enumerator" do enum = "hello world".send(@method, ' ') - enum.should be_an_instance_of(Enumerator) + enum.should.instance_of?(Enumerator) enum.to_a.should == ["hello ", "world"] end diff --git a/spec/ruby/core/string/shared/encode.rb b/spec/ruby/core/string/shared/encode.rb index 9466308886..7f644c26d9 100644 --- a/spec/ruby/core/string/shared/encode.rb +++ b/spec/ruby/core/string/shared/encode.rb @@ -11,7 +11,7 @@ describe :string_encode, shared: true do it "transcodes a 7-bit String despite no generic converting being available" do -> do Encoding::Converter.new Encoding::Emacs_Mule, Encoding::BINARY - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) Encoding.default_internal = Encoding::Emacs_Mule str = "\x79".force_encoding Encoding::BINARY @@ -22,7 +22,7 @@ describe :string_encode, shared: true do it "raises an Encoding::ConverterNotFoundError when no conversion is possible" do Encoding.default_internal = Encoding::Emacs_Mule str = [0x80].pack('C').force_encoding Encoding::BINARY - -> { str.send(@method) }.should raise_error(Encoding::ConverterNotFoundError) + -> { str.send(@method) }.should.raise(Encoding::ConverterNotFoundError) end end @@ -54,7 +54,7 @@ describe :string_encode, shared: true do it "transcodes a 7-bit String despite no generic converting being available" do -> do Encoding::Converter.new Encoding::Emacs_Mule, Encoding::BINARY - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) str = "\x79".force_encoding Encoding::BINARY str.send(@method, Encoding::Emacs_Mule).should == "y".force_encoding(Encoding::BINARY) @@ -64,13 +64,21 @@ describe :string_encode, shared: true do str = [0x80].pack('C').force_encoding Encoding::BINARY -> do str.send(@method, Encoding::Emacs_Mule) - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) end it "raises an Encoding::ConverterNotFoundError for an invalid encoding" do -> do "abc".send(@method, "xyz") - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) + end + + it "raises an Encoding::UndefinedConversionError when a character cannot be represented in the destination encoding" do + # U+0100 (Ā) is valid UTF-8 but not representable in windows-1252 + str = "test\u0100".force_encoding('utf-8') + -> { + str.send(@method, Encoding::Windows_1252) + }.should.raise(Encoding::UndefinedConversionError) end end @@ -99,7 +107,7 @@ describe :string_encode, shared: true do str = [0x80].pack('C').force_encoding Encoding::BINARY -> do str.send(@method, invalid: :replace, undef: :replace) - end.should raise_error(Encoding::ConverterNotFoundError) + end.should.raise(Encoding::ConverterNotFoundError) end it "replaces invalid characters when replacing Emacs-Mule encoded strings" do @@ -142,6 +150,14 @@ describe :string_encode, shared: true do "ab#{xFF}c".send(@method, Encoding::ISO_8859_1, invalid: :replace).should == "ab?c" end + it "raises UndefinedConversionError for characters not representable in destination encoding with only invalid: :replace" do + # U+0100 (Ā) is valid UTF-8 but not representable in windows-1252 + str = "test\u0100".force_encoding('utf-8') + -> { + str.send(@method, Encoding::Windows_1252, invalid: :replace, replace: "") + }.should.raise(Encoding::UndefinedConversionError) + end + it "calls #to_hash to convert the options object" do options = mock("string encode options") options.should_receive(:to_hash).and_return({ undef: :replace }) @@ -213,19 +229,19 @@ describe :string_encode, shared: true do obj.should_not_receive(:to_s) -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: { "\ufffd" => obj }) - }.should raise_error(TypeError, "no implicit conversion of Object into String") + }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises an error if the key is not present in the hash" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: { "foo" => "bar" }) - }.should raise_error(Encoding::UndefinedConversionError, "U+FFFD from UTF-8 to US-ASCII") + }.should.raise(Encoding::UndefinedConversionError, "U+FFFD from UTF-8 to US-ASCII") end it "raises an error if the value is itself invalid" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: { "\ufffd" => "\uffee" }) - }.should raise_error(ArgumentError, "too big fallback string") + }.should.raise(ArgumentError, "too big fallback string") end it "uses the hash's default value if set" do @@ -278,7 +294,7 @@ describe :string_encode, shared: true do it "raises an error" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: @non_hash_like) - }.should raise_error(Encoding::UndefinedConversionError, "U+FFFD from UTF-8 to US-ASCII") + }.should.raise(Encoding::UndefinedConversionError, "U+FFFD from UTF-8 to US-ASCII") end end @@ -300,13 +316,13 @@ describe :string_encode, shared: true do obj.should_not_receive(:to_s) -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: proc { |c| obj }) - }.should raise_error(TypeError, "no implicit conversion of Object into String") + }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises an error if the returned value is itself invalid" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: -> c { "\uffee" }) - }.should raise_error(ArgumentError, "too big fallback string") + }.should.raise(ArgumentError, "too big fallback string") end end @@ -328,13 +344,13 @@ describe :string_encode, shared: true do obj.should_not_receive(:to_s) -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: -> c { obj }) - }.should raise_error(TypeError, "no implicit conversion of Object into String") + }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises an error if the returned value is itself invalid" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: -> c { "\uffee" }) - }.should raise_error(ArgumentError, "too big fallback string") + }.should.raise(ArgumentError, "too big fallback string") end end @@ -367,13 +383,13 @@ describe :string_encode, shared: true do it "does not call to_s on the returned value" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: method(:replace_to_s)) - }.should raise_error(TypeError, "no implicit conversion of Object into String") + }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises an error if the returned value is itself invalid" do -> { "B\ufffd".encode(Encoding::US_ASCII, fallback: method(:replace_bad)) - }.should raise_error(ArgumentError, "too big fallback string") + }.should.raise(ArgumentError, "too big fallback string") end end end @@ -427,6 +443,6 @@ describe :string_encode, shared: true do end it "raises ArgumentError if the value of the :xml option is not :text or :attr" do - -> { ''.send(@method, "UTF-8", xml: :other) }.should raise_error(ArgumentError) + -> { ''.send(@method, "UTF-8", xml: :other) }.should.raise(ArgumentError) end end diff --git a/spec/ruby/core/string/shared/eql.rb b/spec/ruby/core/string/shared/eql.rb index 845b0a3e15..0e356c69e8 100644 --- a/spec/ruby/core/string/shared/eql.rb +++ b/spec/ruby/core/string/shared/eql.rb @@ -1,35 +1,35 @@ -# -*- encoding: binary -*- +# encoding: binary require_relative '../../../spec_helper' require_relative '../fixtures/classes' describe :string_eql_value, shared: true do it "returns true if self <=> string returns 0" do - 'hello'.send(@method, 'hello').should be_true + 'hello'.send(@method, 'hello').should == true end it "returns false if self <=> string does not return 0" do - "more".send(@method, "MORE").should be_false - "less".send(@method, "greater").should be_false + "more".send(@method, "MORE").should == false + "less".send(@method, "greater").should == false end it "ignores encoding difference of compatible string" do - "hello".dup.force_encoding("utf-8").send(@method, "hello".dup.force_encoding("iso-8859-1")).should be_true + "hello".dup.force_encoding("utf-8").send(@method, "hello".dup.force_encoding("iso-8859-1")).should == true end it "considers encoding difference of incompatible string" do - "\xff".dup.force_encoding("utf-8").send(@method, "\xff".dup.force_encoding("iso-8859-1")).should be_false + "\xff".dup.force_encoding("utf-8").send(@method, "\xff".dup.force_encoding("iso-8859-1")).should == false end it "considers encoding compatibility" do - "abcd".dup.force_encoding("utf-8").send(@method, "abcd".dup.force_encoding("utf-32le")).should be_false + "abcd".dup.force_encoding("utf-8").send(@method, "abcd".dup.force_encoding("utf-32le")).should == false end it "ignores subclass differences" do a = "hello" b = StringSpecs::MyString.new("hello") - a.send(@method, b).should be_true - b.send(@method, a).should be_true + a.send(@method, b).should == true + b.send(@method, a).should == true end it "returns true when comparing 2 empty strings but one is not ASCII-compatible" do diff --git a/spec/ruby/core/string/shared/equal_value.rb b/spec/ruby/core/string/shared/equal_value.rb index fccafb5821..dfc5c7cd29 100644 --- a/spec/ruby/core/string/shared/equal_value.rb +++ b/spec/ruby/core/string/shared/equal_value.rb @@ -3,11 +3,11 @@ require_relative '../fixtures/classes' describe :string_equal_value, shared: true do it "returns false if obj does not respond to to_str" do - 'hello'.send(@method, 5).should be_false + 'hello'.send(@method, 5).should == false not_supported_on :opal do - 'hello'.send(@method, :hello).should be_false + 'hello'.send(@method, :hello).should == false end - 'hello'.send(@method, mock('x')).should be_false + 'hello'.send(@method, mock('x')).should == false end it "returns obj == self if obj responds to to_str" do @@ -20,10 +20,10 @@ describe :string_equal_value, shared: true do # Don't use @method for :== in `obj.should_receive(:==)` obj.should_receive(:==).and_return(true) - 'hello'.send(@method, obj).should be_true + 'hello'.send(@method, obj).should == true end it "is not fooled by NUL characters" do - "abc\0def".send(@method, "abc\0xyz").should be_false + "abc\0def".send(@method, "abc\0xyz").should == false end end diff --git a/spec/ruby/core/string/shared/grapheme_clusters.rb b/spec/ruby/core/string/shared/grapheme_clusters.rb index 8b666868b1..dd8c7ed5fe 100644 --- a/spec/ruby/core/string/shared/grapheme_clusters.rb +++ b/spec/ruby/core/string/shared/grapheme_clusters.rb @@ -9,8 +9,17 @@ describe :string_grapheme_clusters, shared: true do a.should == ['a', 'b', "\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}", "\u{1F43E}"] end + it "returns grapheme clusters for various UTF encodings" do + [Encoding::UTF_16LE, Encoding::UTF_16BE, Encoding::UTF_32LE, Encoding::UTF_32BE].each do |enc| + a = [] + # test string: abc[rainbow flag emoji][paw prints] + "ab\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}\u{1F43E}".encode(enc).send(@method) { |c| a << c } + a.should == ['a', 'b', "\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}", "\u{1F43E}"].map { |s| s.encode(enc) } + end + end + it "returns self" do s = StringSpecs::MyString.new "ab\u{1f3f3}\u{fe0f}\u{200d}\u{1f308}\u{1F43E}" - s.send(@method) {}.should equal(s) + s.send(@method) {}.should.equal?(s) end end diff --git a/spec/ruby/core/string/shared/partition.rb b/spec/ruby/core/string/shared/partition.rb index 4cac149ce5..3f7e606eb3 100644 --- a/spec/ruby/core/string/shared/partition.rb +++ b/spec/ruby/core/string/shared/partition.rb @@ -4,15 +4,15 @@ require_relative '../fixtures/classes' describe :string_partition, shared: true do it "returns String instances when called on a subclass" do StringSpecs::MyString.new("hello").send(@method, "l").each do |item| - item.should be_an_instance_of(String) + item.should.instance_of?(String) end StringSpecs::MyString.new("hello").send(@method, "x").each do |item| - item.should be_an_instance_of(String) + item.should.instance_of?(String) end StringSpecs::MyString.new("hello").send(@method, /l./).each do |item| - item.should be_an_instance_of(String) + item.should.instance_of?(String) end end diff --git a/spec/ruby/core/string/shared/replace.rb b/spec/ruby/core/string/shared/replace.rb index 24dac0eb27..73b26351f1 100644 --- a/spec/ruby/core/string/shared/replace.rb +++ b/spec/ruby/core/string/shared/replace.rb @@ -2,7 +2,7 @@ describe :string_replace, shared: true do it "returns self" do a = "a" - a.send(@method, "b").should equal(a) + a.send(@method, "b").should.equal?(a) end it "replaces the content of self with other" do @@ -20,7 +20,7 @@ describe :string_replace, shared: true do it "carries over the encoding invalidity" do a = "\u{8765}".force_encoding('ascii') - "".send(@method, a).valid_encoding?.should be_false + "".send(@method, a).valid_encoding?.should == false end it "tries to convert other to string using to_str" do @@ -30,19 +30,19 @@ describe :string_replace, shared: true do end it "raises a TypeError if other can't be converted to string" do - -> { "hello".send(@method, 123) }.should raise_error(TypeError) - -> { "hello".send(@method, []) }.should raise_error(TypeError) - -> { "hello".send(@method, mock('x')) }.should raise_error(TypeError) + -> { "hello".send(@method, 123) }.should.raise(TypeError) + -> { "hello".send(@method, []) }.should.raise(TypeError) + -> { "hello".send(@method, mock('x')) }.should.raise(TypeError) end it "raises a FrozenError on a frozen instance that is modified" do a = "hello".freeze - -> { a.send(@method, "world") }.should raise_error(FrozenError) + -> { a.send(@method, "world") }.should.raise(FrozenError) end # see [ruby-core:23666] it "raises a FrozenError on a frozen instance when self-replacing" do a = "hello".freeze - -> { a.send(@method, a) }.should raise_error(FrozenError) + -> { a.send(@method, a) }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/shared/slice.rb b/spec/ruby/core/string/shared/slice.rb index 7b9b9f6a14..d296ab6680 100644 --- a/spec/ruby/core/string/shared/slice.rb +++ b/spec/ruby/core/string/shared/slice.rb @@ -21,17 +21,17 @@ describe :string_slice, shared: true do end it "raises a TypeError if the given index is nil" do - -> { "hello".send(@method, nil) }.should raise_error(TypeError) + -> { "hello".send(@method, nil) }.should.raise(TypeError) end it "raises a TypeError if the given index can't be converted to an Integer" do - -> { "hello".send(@method, mock('x')) }.should raise_error(TypeError) - -> { "hello".send(@method, {}) }.should raise_error(TypeError) - -> { "hello".send(@method, []) }.should raise_error(TypeError) + -> { "hello".send(@method, mock('x')) }.should.raise(TypeError) + -> { "hello".send(@method, {}) }.should.raise(TypeError) + -> { "hello".send(@method, []) }.should.raise(TypeError) end it "raises a RangeError if the index is too big" do - -> { "hello".send(@method, bignum_value) }.should raise_error(RangeError) + -> { "hello".send(@method, bignum_value) }.should.raise(RangeError) end end @@ -145,35 +145,35 @@ describe :string_slice_index_length, shared: true do end it "raises a TypeError when idx or length can't be converted to an integer" do - -> { "hello".send(@method, mock('x'), 0) }.should raise_error(TypeError) - -> { "hello".send(@method, 0, mock('x')) }.should raise_error(TypeError) + -> { "hello".send(@method, mock('x'), 0) }.should.raise(TypeError) + -> { "hello".send(@method, 0, mock('x')) }.should.raise(TypeError) # I'm deliberately including this here. # It means that str.send(@method, other, idx) isn't supported. - -> { "hello".send(@method, "", 0) }.should raise_error(TypeError) + -> { "hello".send(@method, "", 0) }.should.raise(TypeError) end it "raises a TypeError when the given index or the given length is nil" do - -> { "hello".send(@method, 1, nil) }.should raise_error(TypeError) - -> { "hello".send(@method, nil, 1) }.should raise_error(TypeError) - -> { "hello".send(@method, nil, nil) }.should raise_error(TypeError) + -> { "hello".send(@method, 1, nil) }.should.raise(TypeError) + -> { "hello".send(@method, nil, 1) }.should.raise(TypeError) + -> { "hello".send(@method, nil, nil) }.should.raise(TypeError) end it "raises a RangeError if the index or length is too big" do - -> { "hello".send(@method, bignum_value, 1) }.should raise_error(RangeError) - -> { "hello".send(@method, 0, bignum_value) }.should raise_error(RangeError) + -> { "hello".send(@method, bignum_value, 1) }.should.raise(RangeError) + -> { "hello".send(@method, 0, bignum_value) }.should.raise(RangeError) end it "raises a RangeError if the index or length is too small" do - -> { "hello".send(@method, -bignum_value, 1) }.should raise_error(RangeError) - -> { "hello".send(@method, 0, -bignum_value) }.should raise_error(RangeError) + -> { "hello".send(@method, -bignum_value, 1) }.should.raise(RangeError) + -> { "hello".send(@method, 0, -bignum_value) }.should.raise(RangeError) end it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.send(@method, 0,0).should be_an_instance_of(String) - s.send(@method, 0,4).should be_an_instance_of(String) - s.send(@method, 1,4).should be_an_instance_of(String) + s.send(@method, 0,0).should.instance_of?(String) + s.send(@method, 0,4).should.instance_of?(String) + s.send(@method, 1,4).should.instance_of?(String) end it "handles repeated application" do @@ -250,9 +250,9 @@ describe :string_slice_range, shared: true do it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.send(@method, 0...0).should be_an_instance_of(String) - s.send(@method, 0..4).should be_an_instance_of(String) - s.send(@method, 1..4).should be_an_instance_of(String) + s.send(@method, 0...0).should.instance_of?(String) + s.send(@method, 0..4).should.instance_of?(String) + s.send(@method, 1..4).should.instance_of?(String) end it "calls to_int on range arguments" do @@ -293,12 +293,12 @@ describe :string_slice_range, shared: true do end it "raises a type error if a range is passed with a length" do - ->{ "hello".send(@method, 1..2, 1) }.should raise_error(TypeError) + ->{ "hello".send(@method, 1..2, 1) }.should.raise(TypeError) end it "raises a RangeError if one of the bound is too big" do - -> { "hello".send(@method, bignum_value..(bignum_value + 1)) }.should raise_error(RangeError) - -> { "hello".send(@method, 0..bignum_value) }.should raise_error(RangeError) + -> { "hello".send(@method, bignum_value..(bignum_value + 1)) }.should.raise(RangeError) + -> { "hello".send(@method, 0..bignum_value) }.should.raise(RangeError) end it "works with endless ranges" do @@ -333,8 +333,8 @@ describe :string_slice_regexp, shared: true do it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.send(@method, //).should be_an_instance_of(String) - s.send(@method, /../).should be_an_instance_of(String) + s.send(@method, //).should.instance_of?(String) + s.send(@method, /../).should.instance_of?(String) end it "sets $~ to MatchData when there is a match and nil when there's none" do @@ -394,19 +394,19 @@ describe :string_slice_regexp_index, shared: true do end it "raises a TypeError when the given index can't be converted to Integer" do - -> { "hello".send(@method, /(.)(.)(.)/, mock('x')) }.should raise_error(TypeError) - -> { "hello".send(@method, /(.)(.)(.)/, {}) }.should raise_error(TypeError) - -> { "hello".send(@method, /(.)(.)(.)/, []) }.should raise_error(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, mock('x')) }.should.raise(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, {}) }.should.raise(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, []) }.should.raise(TypeError) end it "raises a TypeError when the given index is nil" do - -> { "hello".send(@method, /(.)(.)(.)/, nil) }.should raise_error(TypeError) + -> { "hello".send(@method, /(.)(.)(.)/, nil) }.should.raise(TypeError) end it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.send(@method, /(.)(.)/, 0).should be_an_instance_of(String) - s.send(@method, /(.)(.)/, 1).should be_an_instance_of(String) + s.send(@method, /(.)(.)/, 0).should.instance_of?(String) + s.send(@method, /(.)(.)/, 1).should.instance_of?(String) end it "sets $~ to MatchData when there is a match and nil when there's none" do @@ -442,14 +442,14 @@ describe :string_slice_string, shared: true do o = mock('x') o.should_not_receive(:to_str) - -> { "hello".send(@method, o) }.should raise_error(TypeError) + -> { "hello".send(@method, o) }.should.raise(TypeError) end it "returns a String instance when given a subclass instance" do s = StringSpecs::MyString.new("el") r = "hello".send(@method, s) r.should == "el" - r.should be_an_instance_of(String) + r.should.instance_of?(String) end end @@ -476,28 +476,28 @@ describe :string_slice_regexp_group, shared: true do end it "returns nil if there is no match" do - "hello there".send(@method, /(?<whut>what?)/, 'whut').should be_nil + "hello there".send(@method, /(?<whut>what?)/, 'whut').should == nil end it "raises an IndexError if there is no capture for the given name" do -> do "hello there".send(@method, /[aeiou](.)\1/, 'non') - end.should raise_error(IndexError) + end.should.raise(IndexError) end it "raises a TypeError when the given name is not a String" do - -> { "hello".send(@method, /(?<q>.)/, mock('x')) }.should raise_error(TypeError) - -> { "hello".send(@method, /(?<q>.)/, {}) }.should raise_error(TypeError) - -> { "hello".send(@method, /(?<q>.)/, []) }.should raise_error(TypeError) + -> { "hello".send(@method, /(?<q>.)/, mock('x')) }.should.raise(TypeError) + -> { "hello".send(@method, /(?<q>.)/, {}) }.should.raise(TypeError) + -> { "hello".send(@method, /(?<q>.)/, []) }.should.raise(TypeError) end it "raises an IndexError when given the empty String as a group name" do - -> { "hello".send(@method, /(?<q>)/, '') }.should raise_error(IndexError) + -> { "hello".send(@method, /(?<q>)/, '') }.should.raise(IndexError) end it "returns String instances" do s = StringSpecs::MyString.new("hello") - s.send(@method, /(?<q>.)/, 'q').should be_an_instance_of(String) + s.send(@method, /(?<q>.)/, 'q').should.instance_of?(String) end it "sets $~ to MatchData when there is a match and nil when there's none" do @@ -505,13 +505,13 @@ describe :string_slice_regexp_group, shared: true do $~[0].should == 'he' 'hello'.send(@method, /(?<non>not)/, 'non') - $~.should be_nil + $~.should == nil end end end describe :string_slice_symbol, shared: true do it "raises TypeError" do - -> { 'hello'.send(@method, :hello) }.should raise_error(TypeError) + -> { 'hello'.send(@method, :hello) }.should.raise(TypeError) end end diff --git a/spec/ruby/core/string/shared/strip.rb b/spec/ruby/core/string/shared/strip.rb index 3af77b50fe..39c7232ff9 100644 --- a/spec/ruby/core/string/shared/strip.rb +++ b/spec/ruby/core/string/shared/strip.rb @@ -7,8 +7,8 @@ describe :string_strip, shared: true do end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new(" hello ").send(@method).should be_an_instance_of(String) - StringSpecs::MyString.new(" ").send(@method).should be_an_instance_of(String) - StringSpecs::MyString.new("").send(@method).should be_an_instance_of(String) + StringSpecs::MyString.new(" hello ").send(@method).should.instance_of?(String) + StringSpecs::MyString.new(" ").send(@method).should.instance_of?(String) + StringSpecs::MyString.new("").send(@method).should.instance_of?(String) end end diff --git a/spec/ruby/core/string/shared/succ.rb b/spec/ruby/core/string/shared/succ.rb index b69a394875..8f1d327741 100644 --- a/spec/ruby/core/string/shared/succ.rb +++ b/spec/ruby/core/string/shared/succ.rb @@ -1,4 +1,4 @@ -# -*- encoding: binary -*- +# encoding: binary describe :string_succ, shared: true do it "returns an empty string for empty strings" do "".send(@method).should == "" @@ -60,9 +60,9 @@ describe :string_succ, shared: true do end it "returns String instances when called on a subclass" do - StringSpecs::MyString.new("").send(@method).should be_an_instance_of(String) - StringSpecs::MyString.new("a").send(@method).should be_an_instance_of(String) - StringSpecs::MyString.new("z").send(@method).should be_an_instance_of(String) + StringSpecs::MyString.new("").send(@method).should.instance_of?(String) + StringSpecs::MyString.new("a").send(@method).should.instance_of?(String) + StringSpecs::MyString.new("z").send(@method).should.instance_of?(String) end it "returns a String in the same encoding as self" do @@ -75,13 +75,13 @@ describe :string_succ_bang, shared: true do ["", "abcd", "THX1138"].each do |s| s = +s r = s.dup.send(@method) - s.send(@method).should equal(s) + s.send(@method).should.equal?(s) s.should == r end end it "raises a FrozenError if self is frozen" do - -> { "".freeze.send(@method) }.should raise_error(FrozenError) - -> { "abcd".freeze.send(@method) }.should raise_error(FrozenError) + -> { "".freeze.send(@method) }.should.raise(FrozenError) + -> { "abcd".freeze.send(@method) }.should.raise(FrozenError) end end diff --git a/spec/ruby/core/string/shared/to_s.rb b/spec/ruby/core/string/shared/to_s.rb index 4b87a6cbe1..96c59470d6 100644 --- a/spec/ruby/core/string/shared/to_s.rb +++ b/spec/ruby/core/string/shared/to_s.rb @@ -1,13 +1,13 @@ describe :string_to_s, shared: true do it "returns self when self.class == String" do a = "a string" - a.should equal(a.send(@method)) + a.should.equal?(a.send(@method)) end it "returns a new instance of String when called on a subclass" do a = StringSpecs::MyString.new("a string") s = a.send(@method) s.should == "a string" - s.should be_an_instance_of(String) + s.should.instance_of?(String) end end diff --git a/spec/ruby/core/string/shared/to_sym.rb b/spec/ruby/core/string/shared/to_sym.rb index 833eae100e..2a8a2e3182 100644 --- a/spec/ruby/core/string/shared/to_sym.rb +++ b/spec/ruby/core/string/shared/to_sym.rb @@ -1,42 +1,42 @@ describe :string_to_sym, shared: true do it "returns the symbol corresponding to self" do - "Koala".send(@method).should equal :Koala - 'cat'.send(@method).should equal :cat - '@cat'.send(@method).should equal :@cat - 'cat and dog'.send(@method).should equal :"cat and dog" - "abc=".send(@method).should equal :abc= + "Koala".send(@method).should.equal? :Koala + 'cat'.send(@method).should.equal? :cat + '@cat'.send(@method).should.equal? :@cat + 'cat and dog'.send(@method).should.equal? :"cat and dog" + "abc=".send(@method).should.equal? :abc= end it "does not special case +(binary) and -(binary)" do - "+(binary)".send(@method).should equal :"+(binary)" - "-(binary)".send(@method).should equal :"-(binary)" + "+(binary)".send(@method).should.equal? :"+(binary)" + "-(binary)".send(@method).should.equal? :"-(binary)" end it "does not special case certain operators" do - "!@".send(@method).should equal :"!@" - "~@".send(@method).should equal :"~@" - "!(unary)".send(@method).should equal :"!(unary)" - "~(unary)".send(@method).should equal :"~(unary)" - "+(unary)".send(@method).should equal :"+(unary)" - "-(unary)".send(@method).should equal :"-(unary)" + "!@".send(@method).should.equal? :"!@" + "~@".send(@method).should.equal? :"~@" + "!(unary)".send(@method).should.equal? :"!(unary)" + "~(unary)".send(@method).should.equal? :"~(unary)" + "+(unary)".send(@method).should.equal? :"+(unary)" + "-(unary)".send(@method).should.equal? :"-(unary)" end it "returns a US-ASCII Symbol for a UTF-8 String containing only US-ASCII characters" do sym = "foobar".send(@method) sym.encoding.should == Encoding::US_ASCII - sym.should equal :"foobar" + sym.should.equal? :"foobar" end it "returns a US-ASCII Symbol for a binary String containing only US-ASCII characters" do sym = "foobar".b.send(@method) sym.encoding.should == Encoding::US_ASCII - sym.should equal :"foobar" + sym.should.equal? :"foobar" end it "returns a UTF-8 Symbol for a UTF-8 String containing non US-ASCII characters" do sym = "il était une fois".send(@method) sym.encoding.should == Encoding::UTF_8 - sym.should equal :"il était une #{'fois'}" + sym.should.equal? :"il était une #{'fois'}" end it "returns a UTF-16LE Symbol for a UTF-16LE String containing non US-ASCII characters" do @@ -67,6 +67,6 @@ describe :string_to_sym, shared: true do invalid_utf8.should_not.valid_encoding? -> { invalid_utf8.send(@method) - }.should raise_error(EncodingError, 'invalid symbol in encoding UTF-8 :"\xC3"') + }.should.raise(EncodingError, 'invalid symbol in encoding UTF-8 :"\xC3"') end end |
