diff --git a/spec/datadog/di/integration/everything_from_remote_config_spec.rb b/spec/datadog/di/integration/everything_from_remote_config_spec.rb index 8383dc81b3..13d2743d91 100644 --- a/spec/datadog/di/integration/everything_from_remote_config_spec.rb +++ b/spec/datadog/di/integration/everything_from_remote_config_spec.rb @@ -1,4 +1,5 @@ require 'spec_helper' +require 'datadog/di/spec_helper' class EverythingFromRemoteConfigSpecTestClass def target_method @@ -81,8 +82,7 @@ def target_method end after do - probe_manager.clear_hooks - probe_manager.close + component.shutdown! end let(:agent_settings) do @@ -217,8 +217,9 @@ def do_rc notify_payload = if env.path == '/debugger/v1/diagnostics' JSON.parse(env.form.fetch('event').io.read, symbolize_names: true) else - env.form + JSON.parse(env.body) end + expect(notify_payload).to be_a(Array) notify_payload.each do |payload| payloads << payload.merge(path: env.path) end @@ -242,7 +243,7 @@ def do_rc expect(payloads.length).to eq 1 received_payload = payloads.first - expect(received_payload).to match(expected_received_payload) + expect(order_hash_keys(received_payload)).to match(order_hash_keys(expected_received_payload)) expect(probe_manager.pending_probes.length).to eq 1 end @@ -295,7 +296,7 @@ def assert_received_and_installed expect(emitting_payload).to match(expected_emitting_payload) snapshot_payload = payloads.shift - expect(snapshot_payload).to match(expected_snapshot_payload) + expect(order_hash_keys(snapshot_payload)).to match(deep_stringify_keys(order_hash_keys(expected_snapshot_payload))) end end end diff --git a/spec/datadog/di/spec_helper.rb b/spec/datadog/di/spec_helper.rb index 9b088c6762..41490e3c24 100644 --- a/spec/datadog/di/spec_helper.rb +++ b/spec/datadog/di/spec_helper.rb @@ -50,6 +50,21 @@ def without_code_tracking end module InstanceMethods + def order_hash_keys(hash) + Hash[hash.keys.map do |key| + [key.to_s, hash[key]] + end] + end + + def deep_stringify_keys(hash) + if Hash === hash + Hash[hash.map do |key, value| + [key.to_s, deep_stringify_keys(value)] + end] + else + hash + end + end end end