Skip to content

Commit

Permalink
improve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
martinemde committed Dec 3, 2024
1 parent b04b418 commit 63cc695
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ def assert_event(tag, expected_additional, actual)
assert_equal actual.additional_type.new(user_agent_info:, **expected_additional), actual.additional
end

# Asserts that both are the same nested hash, using equality checks unless
# the value is a hash, in which case it will recursively check the nested hash
# The purpose of this assertion is mostly to provide a more useful error when
# a nested hash contains different elements instead of overwhelming the user
# with a giant nested hash diff that is mostly sorting problems.
# Hashes with different orders will still be equal according to assert_equal,
# but when they are not equal, the output diff will print them in their
# original order, which makes it hard to see what is actually different.
# Sort the hashes and any nested hashes (leaving array order untouched) before
# comparing them to make the diff output more useful.
def assert_equal_hash(expected, actual, context = "expected")
assert_equal deep_sort_hashes(expected), deep_sort_hashes(actual), "Expected equal elements in #{context}"
end
Expand Down

0 comments on commit 63cc695

Please sign in to comment.