Sha256: 082adbe6bace4d2be030dff90210af1b4bb4ea43ae85a2df67ebee127043b80d

Contents?: true

Size: 578 Bytes

Versions: 10

Compression:

Stored size: 578 Bytes

Contents

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

Version data entries

10 entries across 7 versions & 3 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-json-1.2.0/test/json_encode_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-json-1.2.0/test/json_encode_test.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-json-1.2.0/test/json_encode_test.rb
fog-json-1.2.0 test/json_encode_test.rb
fog-json-1.1.0 test/json_encode_test.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-json-1.0.2/test/json_encode_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-json-1.0.1/test/json_encode_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-json-1.0.2/test/json_encode_test.rb
fog-json-1.0.2 test/json_encode_test.rb
fog-json-1.0.1 test/json_encode_test.rb