File: json_sanitize_test.rb

package info (click to toggle)
ruby-fog-json 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 124 kB
  • sloc: ruby: 100; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 781 bytes parent folder | download
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