spec/parsing/one_off_spec.rb in yajl-ruby-1.2.0 vs spec/parsing/one_off_spec.rb in yajl-ruby-1.2.1

- old
+ new

@@ -18,11 +18,11 @@ it "should parse JSON with a comment, with :allow_comments set to true" do json = StringIO.new('{"key": /* this is a comment */ "value"}') lambda { Yajl::Parser.parse(json, :allow_comments => true) - }.should_not raise_error(Yajl::ParseError) + }.should_not raise_error end it "should not parse invalid UTF8 with :check_utf8 set to true" do parser = Yajl::Parser.new(:check_utf8 => true) lambda { @@ -65,9 +65,14 @@ Yajl::Parser.parse("{\"id\": 5687389800}").should eql({"id" => 5687389800}) Yajl::Parser.parse("{\"id\": 1046289770033519442869495707521600000000}").should eql({"id" => 1046289770033519442869495707521600000000}) end if RUBY_VERSION =~ /^1.9/ + it "should encode non-ascii symbols in utf-8" do + parsed = Yajl::Parser.parse('{"曦": 1234}', :symbolize_keys => true) + parsed.keys.fetch(0).encoding.should eq(Encoding::UTF_8) + end + it "should return strings and hash keys in utf-8 if Encoding.default_internal is nil" do Encoding.default_internal = nil Yajl::Parser.parse('{"key": "value"}').keys.first.encoding.should eql(Encoding.find('utf-8')) Yajl::Parser.parse('{"key": "value"}').values.first.encoding.should eql(Encoding.find('utf-8')) end