
Untitled
By: a guest on
May 8th, 2012 | syntax:
None | size: 0.78 KB | hits: 8 | expires: Never
# encoding: utf-8
# Run this with 1.9.2 or 1.9.3
require 'psych'
require 'minitest/autorun'
require 'date'
class ZOMGTest < MiniTest::Unit::TestCase
# Quoted strings are assumed to be Strings
def test_json
json = <<EOF
{
"date_a": "2011-07-22T09:54:44Z",
"city": "wroc\u0142aw", # after this the next date is not parsed anymore!
"date_b": "2011-07-22T09:54:44Z"
}
EOF
hash = Psych.load json
assert_equal "wrocław", hash['city']
end
# Tagged string literals are typecast
def test_yaml
yaml = <<EOF
{
"date_a": ! "2011-07-22T09:54:44Z",
"city": "wroc\u0142aw", # after this the next date is not parsed anymore!
"date_b": ! "2011-07-22T09:54:44Z"
}
EOF
hash = Psych.load yaml
assert_kind_of Time, hash['date_a']
end
end