diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-20 00:20:57 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-20 00:20:57 +0000 |
commit | 74b0a7a06f62216d46ccb1ae53b2c52121622809 (patch) | |
tree | 4522f3d19de9c026cb6390795ba92cab2ebf24d3 /test/psych | |
parent | a17cdfdde29faa7e6c5feb1c31d41e4f42328daa (diff) |
* ext/psych/lib/psych/visitors/json_tree.rb: Fix JSON emit for
DateTime and Time classes.
* test/psych/test_json_tree.rb: test for JSON emit
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych')
-rw-r--r-- | test/psych/test_json_tree.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/psych/test_json_tree.rb b/test/psych/test_json_tree.rb index 96e17be961..5fcb0d6a37 100644 --- a/test/psych/test_json_tree.rb +++ b/test/psych/test_json_tree.rb @@ -39,5 +39,15 @@ module Psych assert_match(/"one"/, json) assert_match(/"two"/, json) end + + def test_time + time = Time.new(2010, 10, 10).utc + assert_equal "{\"a\": \"2010-10-10 07:00:00.000000000Z\"}\n", Psych.to_json({'a' => time }) + end + + def test_datetime + time = Time.new(2010, 10, 10).to_datetime + assert_equal "{\"a\": \"#{time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")}\"}\n", Psych.to_json({'a' => time }) + end end end |