diff options
Diffstat (limited to 'test/psych/test_json_tree.rb')
-rw-r--r-- | test/psych/test_json_tree.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/test/psych/test_json_tree.rb b/test/psych/test_json_tree.rb index 84bd36c..5fcb0d6 100644 --- a/test/psych/test_json_tree.rb +++ b/test/psych/test_json_tree.rb @@ -3,11 +3,11 @@ require_relative 'helper' module Psych class TestJSONTree < TestCase def test_string - assert_match(/(['"])foo\1/, Psych.to_json("foo")) + assert_match(/"foo"/, Psych.to_json("foo")) end def test_symbol - assert_match(/(['"])foo\1/, Psych.to_json(:foo)) + assert_match(/"foo"/, Psych.to_json(:foo)) end def test_nil @@ -36,8 +36,18 @@ module Psych json = Psych.to_json(list) assert_match(/]$/, json) assert_match(/^\[/, json) - assert_match(/['"]one['"]/, json) - assert_match(/['"]two['"]/, json) + 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 |