File: json_decode_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 (20 lines) | stat: -rw-r--r-- 500 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require "minitest/autorun"
require "fog/json"

class TestJSONDecoding < Minitest::Test
  def test_decode_array
    @json = %q{["one", "two", "three"]}
    @expected = %w(one two three)
    assert_equal @expected, Fog::JSON.decode(@json)
  end

  def test_decode_hash
    @json = %q{{"key":"value"}}
    @expected = { "key" => "value" }
    assert_equal @expected, Fog::JSON.decode(@json)
  end

  def test_decode_with_nil
    assert_raises(Fog::JSON::DecodeError) { Fog::JSON.decode(nil) }
  end
end