Sha256: df1a6ef6cf809ad3f6180856d051ae8ee776d63321149150b202496086130630

Contents?: true

Size: 1.12 KB

Versions: 13

Compression:

Stored size: 1.12 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require File.expand_path(File.join(File.dirname(__FILE__), '..', '..','test_helper'))
require 'new_relic/agent/hash_extensions'

class HashExtensionsTest < Minitest::Test

  def test_stringify_keys_in_object_with_nested_hash
    hash = {:foo => {:bar => [{:baz => "qux"}, "quux"]}}
    expected = {"foo" => {"bar" => [{"baz" => "qux"}, "quux"]}}

    actual = NewRelic::Agent::HashExtensions.stringify_keys_in_object(hash)

    assert_equal expected, actual
  end

  def test_stringify_keys_in_object_with_array
    array = ["foo", {:bar => [{:baz => "qux"}, "quux"]}]
    expected = ["foo", {"bar" => [{"baz" => "qux"}, "quux"]}]

    actual = NewRelic::Agent::HashExtensions.stringify_keys_in_object(array)

    assert_equal expected, actual
  end

  def test_stringify_keys_in_object_does_not_mutate_argument
    arg = {:foo => "bar"}
    result = NewRelic::Agent::HashExtensions.stringify_keys_in_object(arg)
    refute_same arg, result
    assert_includes arg.keys, :foo
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.15.2.317 test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.15.1.316 test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.15.0.314 test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.14.3.313 test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.14.2.312 test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.14.1.311 test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.14.0.305 test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.13.2.302 test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.13.1.300 test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.13.0.299 test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.12.1.298 test/new_relic/agent/hash_extensions_test.rb
newrelic_rpm-3.12.0.288 test/new_relic/agent/hash_extensions_test.rb