File: json_encode_test.rb

package info (click to toggle)
ruby-fog-json 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 128 kB
  • ctags: 29
  • sloc: ruby: 100; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 578 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
21
22
23
require "minitest/autorun"
require "fog/json"

class TestJSONEncoding < Minitest::Test
  def test_encode_array
    @array = %W(one two three)
    @expected = %q{["one","two","three"]}
    assert_equal @expected, Fog::JSON.encode(@array)
  end

  def test_encode_hash
    @hash = {
      "key" => "value"
    }
    @expected = %q{{"key":"value"}}
    assert_equal @expected, Fog::JSON.encode(@hash)
  end

  def test_encode_with_bad_input
    skip if %w(1.8.7 2.0.0).include?(RUBY_VERSION)
    assert_raises(Fog::JSON::EncodeError) { Fog::JSON.encode("\x82\xAC\xEF") }
  end
end