https://github.com/plentz/jruby_report/blob/master/ok_json_test.rb
~/Projects/opensource/jruby_report (master) $ ruby -I. ok_json_test.rb
Run options: --seed 31809
# Running tests:
"\xEF\xBF\xBD"
..F
Finished tests in 0.049639s, 60.4364 tests/s, 60.4364 assertions/s.
1) Failure:
test_json_encode(OkJsonTest) [ok_json_test.rb:14]:
Expected: "{\"message\":\"á\"}"
Actual: "{\"message\":\"\\ufffd\"}"
3 tests, 3 assertions, 1 failures, 0 errors, 0 skips
to this
~/Projects/opensource/jruby_report (master) $ ruby -I. ok_json_test.rb
Run options: --seed 3567
# Running tests:
.FF
Finished tests in 0.028424s, 105.5446 tests/s, 105.5446 assertions/s.
1) Failure:
test_decode_bad(OkJsonTest) [ok_json_test.rb:24]:
Expected: "\xEF\xBF\xBD"
Actual: "�"
2) Failure:
test_json_encode(OkJsonTest) [ok_json_test.rb:14]:
Expected: "{\"message\":\"á\"}"
Actual: "{\"message\":\"\\u00e1\"}"
3 tests, 3 assertions, 2 failures, 0 errors, 0 skips
~/Projects/opensource/jruby_report (master) $ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
My tweet wasn't a very good way to reply. I can be more thorough here:
more picky than it needs to be.
"\u00e1"
is a valid json string and meansthe same thing as
"á"
.okjson bug, so now the test fails. OkJson.decode used to return ASCII-8BIT
strings containing UTF-8 bytes; now it returns true UTF-8 strings, as it should.
[0xef, 0xbf, 0xbd].pack('C*')
encoding is ASCII-8BIT. It could berewritten as
"\xEF\xBF\xBD"
and I believe the test will pass. (Notably here,the actual string data is the same. Only the metadata has changed.)