1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
require "minitest/autorun"
require "fog/json"
class TestJSONSanitizing < Minitest::Test
def setup
@time = Time.utc(2014, 02, 14, 12, 34, 56)
end
def test_sanitize_with_array
@data = [@time]
@expected = ["2014-02-14T12:34:56+00:00"]
assert_equal @expected, Fog::JSON.sanitize(@data)
end
def test_sanitize_with_hash
@data = { "key" => @time }
@expected = { "key" => "2014-02-14T12:34:56+00:00" }
assert_equal @expected, Fog::JSON.sanitize(@data)
end
def test_sanitize_with_time
@data = @time
@expected = "2014-02-14T12:34:56+00:00"
assert_equal @expected, Fog::JSON.sanitize(@data)
end
def test_sanitize_with_string
@data = "fog"
@expected = "fog"
assert_equal @expected, Fog::JSON.sanitize(@data)
end
end
|