spec/string_spec.rb in utf8-0.1.1 vs spec/string_spec.rb in utf8-0.1.2

- old
+ new

@@ -1,18 +1,21 @@ # encoding: utf-8 require File.expand_path('../spec_helper', __FILE__) describe String::UTF8 do - before(:all) do + before(:each) do @char_array = ["怎", "麼", "也", "沒", "人", "寫", "了", "這", "個", "嗎"] @str = @char_array.join @utf8 = @str.as_utf8 @utf8_len = @char_array.size end it "should blow up on invalid utf8 chars" do # lets cut right into the middle of a sequence so we know it's bad - utf8 = @str[0..1].as_utf8 + @str.force_encoding('binary') if @str.respond_to?(:force_encoding) + utf8 = @str[0..1] + utf8.force_encoding('utf-8') if utf8.respond_to?(:force_encoding) + utf8 = utf8.as_utf8 lambda { utf8.length }.should raise_error(ArgumentError) \ No newline at end of file