From 9b1fe1d3cbb7a55defef7c8f1441e72220887079 Mon Sep 17 00:00:00 2001 From: Robert Haines Date: Wed, 2 Jul 2014 12:58:58 +0100 Subject: [PATCH] Add tests for the Util#clean_json method. --- test/tc_util.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/tc_util.rb b/test/tc_util.rb index 9e03423..345bb51 100644 --- a/test/tc_util.rb +++ b/test/tc_util.rb @@ -11,6 +11,19 @@ class TestUtil < Test::Unit::TestCase + def test_clean_json + json_ok = { :one => "one", :uri => URI.parse("/file.txt") } + json_nil = { :nil => nil } + json_empty = { :empty => "" } + json_mix = json_ok.merge(json_nil).merge(json_empty) + empty = {} + + assert_same json_ok, ROBundle::Util.clean_json(json_ok) + assert_equal empty, ROBundle::Util.clean_json(json_nil) + assert_equal empty, ROBundle::Util.clean_json(json_empty) + assert_equal json_ok, ROBundle::Util.clean_json(json_mix) + end + def test_parse_time now = Time.now iso = now.iso8601