From 876a1ccdffb0099b09b3a7929cb782fb00cf6e49 Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Tue, 3 Dec 2024 11:27:44 -0800 Subject: [PATCH] assert_equal_hash performs assert_equal, but improves diffs on fail Convert all multi-line hash comparisons to assert_equal_hash --- .../api/v1/oidc/api_key_roles_test.rb | 12 ++-- .../integration/api/v1/oidc/id_tokens_test.rb | 2 +- ...ygem_trusted_publishers_controller_test.rb | 11 ++-- .../oidc/trusted_publisher_controller_test.rb | 2 +- test/jobs/upload_info_file_job_test.rb | 2 +- test/jobs/upload_names_file_job_test.rb | 2 +- test/jobs/upload_versions_file_job_test.rb | 2 +- .../trusted_publisher/github_action_test.rb | 4 +- test/models/sendgrid_event_test.rb | 2 +- test/models/web_hook_test.rb | 4 +- test/system/avo/manual_changes_test.rb | 6 +- test/system/avo/rubygems_test.rb | 8 +-- test/system/avo/users_test.rb | 14 ++--- test/system/avo/versions_test.rb | 2 +- test/system/avo/web_hooks_test.rb | 2 +- test/system/oidc_test.rb | 58 ++++++++++--------- ...set_links_to_version_metadata_task_test.rb | 6 +- test/test_helper.rb | 23 ++++++++ test/unit/avo/actions/base_action_test.rb | 6 +- .../unit/gemcutter/request_ip_address_test.rb | 2 +- 20 files changed, 98 insertions(+), 72 deletions(-) diff --git a/test/integration/api/v1/oidc/api_key_roles_test.rb b/test/integration/api/v1/oidc/api_key_roles_test.rb index 242b03ce242..b41e68aa108 100644 --- a/test/integration/api/v1/oidc/api_key_roles_test.rb +++ b/test/integration/api/v1/oidc/api_key_roles_test.rb @@ -56,7 +56,7 @@ class Api::V1::OIDC::ApiKeyRolesTest < ActionDispatch::IntegrationTest headers: { "HTTP_AUTHORIZATION" => @user_api_key } assert_response :success - assert_equal( + assert_equal_hash( { "id" => @role.id, "token" => @role.token, @@ -252,7 +252,7 @@ def jwt(claims = @claims, key: @pkey) resp = response.parsed_body assert_match(/^rubygems_/, resp["rubygems_api_key"]) - assert_equal({ + assert_equal_hash({ "rubygems_api_key" => resp["rubygems_api_key"], "name" => "#{@role.name}-79685b65-945d-450a-a3d8-a36bcf72c23d", "scopes" => ["push_rubygem"], @@ -281,7 +281,7 @@ def jwt(claims = @claims, key: @pkey) resp = response.parsed_body assert_match(/^rubygems_/, resp["rubygems_api_key"]) - assert_equal({ + assert_equal_hash({ "rubygems_api_key" => resp["rubygems_api_key"], "name" => "#{@role.name}-79685b65-945d-450a-a3d8-a36bcf72c23d", "scopes" => ["push_rubygem"], @@ -344,7 +344,7 @@ def jwt(claims = @claims, key: @pkey) resp = response.parsed_body assert_match(/^rubygems_/, resp["rubygems_api_key"]) - assert_equal({ + assert_equal_hash({ "rubygems_api_key" => resp["rubygems_api_key"], "name" => "#{@role.name}-79685b65-945d-450a-a3d8-a36bcf72c23d", "scopes" => ["push_rubygem"], @@ -358,7 +358,7 @@ def jwt(claims = @claims, key: @pkey) assert_equal hashed_key, oidc_id_token.api_key.hashed_key assert_equal @role.provider, oidc_id_token.provider - assert_equal( + assert_equal_hash( { "claims" => @claims, "header" => { @@ -377,7 +377,7 @@ def jwt(claims = @claims, key: @pkey) headers: {} assert_response :unprocessable_content - assert_equal({ + assert_equal_hash({ "errors" => { "jwt.claims.jti" => ["must be unique"] } }, response.parsed_body) end diff --git a/test/integration/api/v1/oidc/id_tokens_test.rb b/test/integration/api/v1/oidc/id_tokens_test.rb index 60bd7154cc4..67896579ff3 100644 --- a/test/integration/api/v1/oidc/id_tokens_test.rb +++ b/test/integration/api/v1/oidc/id_tokens_test.rb @@ -38,7 +38,7 @@ class Api::V1::OIDC::IdTokensTest < ActionDispatch::IntegrationTest headers: { "HTTP_AUTHORIZATION" => @user_api_key } assert_response :success - assert_equal( + assert_equal_hash( { "api_key_role_token" => @id_token.api_key_role.token, "jwt" => { diff --git a/test/integration/api/v1/oidc/rubygem_trusted_publishers_controller_test.rb b/test/integration/api/v1/oidc/rubygem_trusted_publishers_controller_test.rb index 64af8414c8c..899aaca6c16 100644 --- a/test/integration/api/v1/oidc/rubygem_trusted_publishers_controller_test.rb +++ b/test/integration/api/v1/oidc/rubygem_trusted_publishers_controller_test.rb @@ -107,7 +107,7 @@ class Api::V1::OIDC::RubygemTrustedPublishersControllerTest < ActionDispatch::In repository_name = @trusted_publisher.trusted_publisher.repository_name assert_response :success - assert_equal( + assert_equal_hash( { "id" => @trusted_publisher.id, "trusted_publisher_type" => "OIDC::TrustedPublisher::GitHubAction", "trusted_publisher" => { @@ -142,7 +142,7 @@ class Api::V1::OIDC::RubygemTrustedPublishersControllerTest < ActionDispatch::In trusted_publisher = OIDC::RubygemTrustedPublisher.find(response.parsed_body["id"]) assert_equal @rubygem, trusted_publisher.rubygem - assert_equal( + assert_equal_hash( { "id" => response.parsed_body["id"], "trusted_publisher_type" => "OIDC::TrustedPublisher::GitHubAction", "trusted_publisher" => { @@ -180,9 +180,10 @@ class Api::V1::OIDC::RubygemTrustedPublishersControllerTest < ActionDispatch::In headers: { "HTTP_AUTHORIZATION" => "12345" } assert_response :unprocessable_content - assert_equal({ "trusted_publisher.repository_name" => ["can't be blank"], - "trusted_publisher.workflow_filename" => ["can't be blank"] }, - response.parsed_body["errors"]) + assert_equal_hash({ + "trusted_publisher.repository_name" => ["can't be blank"], + "trusted_publisher.workflow_filename" => ["can't be blank"] + }, response.parsed_body["errors"]) end end diff --git a/test/integration/api/v1/oidc/trusted_publisher_controller_test.rb b/test/integration/api/v1/oidc/trusted_publisher_controller_test.rb index 98286492fd6..db42c1a7890 100644 --- a/test/integration/api/v1/oidc/trusted_publisher_controller_test.rb +++ b/test/integration/api/v1/oidc/trusted_publisher_controller_test.rb @@ -241,7 +241,7 @@ def jwt(claims = @claims, key: @pkey) resp = response.parsed_body assert_match(/^rubygems_/, resp["rubygems_api_key"]) - assert_equal({ + assert_equal_hash({ "rubygems_api_key" => resp["rubygems_api_key"], "name" => "GitHub Actions segiddins/oidc-test @ .github/workflows/token.yml 2023-03-28T16:22:17Z", "scopes" => ["push_rubygem"], diff --git a/test/jobs/upload_info_file_job_test.rb b/test/jobs/upload_info_file_job_test.rb index f6780421052..6e2aa5b724b 100644 --- a/test/jobs/upload_info_file_job_test.rb +++ b/test/jobs/upload_info_file_job_test.rb @@ -17,7 +17,7 @@ class UploadInfoFileJobTest < ActiveJob::TestCase assert_equal content, RubygemFs.compact_index.get("info/#{version.rubygem.name}") - assert_equal( + assert_equal_hash( { metadata: { "surrogate-control" => "max-age=3600, stale-while-revalidate=1800", diff --git a/test/jobs/upload_names_file_job_test.rb b/test/jobs/upload_names_file_job_test.rb index 09437026bcb..e4b7df4eb20 100644 --- a/test/jobs/upload_names_file_job_test.rb +++ b/test/jobs/upload_names_file_job_test.rb @@ -17,7 +17,7 @@ class UploadNamesFileJobTest < ActiveJob::TestCase assert_equal content, RubygemFs.compact_index.get("names") - assert_equal( + assert_equal_hash( { metadata: { "surrogate-control" => "max-age=3600, stale-while-revalidate=1800", diff --git a/test/jobs/upload_versions_file_job_test.rb b/test/jobs/upload_versions_file_job_test.rb index 6aaf266f283..885b0348f51 100644 --- a/test/jobs/upload_versions_file_job_test.rb +++ b/test/jobs/upload_versions_file_job_test.rb @@ -18,7 +18,7 @@ class UploadVersionsFileJobTest < ActiveJob::TestCase assert_equal content, RubygemFs.compact_index.get("versions") - assert_equal( + assert_equal_hash( { metadata: { "surrogate-control" => "max-age=3600, stale-while-revalidate=1800", diff --git a/test/models/oidc/trusted_publisher/github_action_test.rb b/test/models/oidc/trusted_publisher/github_action_test.rb index bae69432ff9..09cf350def0 100644 --- a/test/models/oidc/trusted_publisher/github_action_test.rb +++ b/test/models/oidc/trusted_publisher/github_action_test.rb @@ -79,7 +79,7 @@ class OIDC::TrustedPublisher::GitHubActionTest < ActiveSupport::TestCase test "#to_access_policy" do publisher = create(:oidc_trusted_publisher_github_action, repository_name: "rubygem1") - assert_equal( + assert_equal_hash( { statements: [ { @@ -113,7 +113,7 @@ class OIDC::TrustedPublisher::GitHubActionTest < ActiveSupport::TestCase publisher.update!(environment: "test") - assert_equal( + assert_equal_hash( { statements: [ { diff --git a/test/models/sendgrid_event_test.rb b/test/models/sendgrid_event_test.rb index 3acbf590856..631f048cda3 100644 --- a/test/models/sendgrid_event_test.rb +++ b/test/models/sendgrid_event_test.rb @@ -78,7 +78,7 @@ class SendgridEventTest < ActiveSupport::TestCase assert_equal("bounce", event.event_type) assert_equal(occurred_at, event.occurred_at) assert_predicate event, :pending? - assert_equal( + assert_equal_hash( { "email" => "user@example.com", "sg_event_id" => "t61hI0Xpmk8XSR1YX4s0Kg==", diff --git a/test/models/web_hook_test.rb b/test/models/web_hook_test.rb index 048eced3c6b..0c24dad3f14 100644 --- a/test/models/web_hook_test.rb +++ b/test/models/web_hook_test.rb @@ -97,7 +97,7 @@ def stub_hook_relay_request(url, webhook_id, authorization, max_attempts = 3) end should "show limited attributes for to_json" do - assert_equal( + assert_equal_hash( { "url" => @url, "failure_count" => @webhook.failure_count @@ -115,7 +115,7 @@ def stub_hook_relay_request(url, webhook_id, authorization, max_attempts = 3) end should "show limited attributes for to_yaml" do - assert_equal( + assert_equal_hash( { "url" => @url, "failure_count" => @webhook.failure_count diff --git a/test/system/avo/manual_changes_test.rb b/test/system/avo/manual_changes_test.rb index 8d47468e5ea..91ad03c67e4 100644 --- a/test/system/avo/manual_changes_test.rb +++ b/test/system/avo/manual_changes_test.rb @@ -35,7 +35,7 @@ class Avo::ManualChangesSystemTest < ApplicationSystemTestCase assert_equal log_ticket, audit.auditable assert_equal "LogTicket", audit.auditable_type assert_equal "Manual create of LogTicket", audit.action - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/LogTicket/#{log_ticket.id}" => { @@ -80,7 +80,7 @@ class Avo::ManualChangesSystemTest < ApplicationSystemTestCase assert_equal log_ticket, audit.auditable assert_equal "LogTicket", audit.auditable_type assert_equal "Manual update of LogTicket", audit.action - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/LogTicket/#{log_ticket.id}" => { @@ -129,7 +129,7 @@ class Avo::ManualChangesSystemTest < ApplicationSystemTestCase assert_equal log_ticket.id, audit.auditable_id assert_equal "LogTicket", audit.auditable_type assert_equal "Manual destroy of LogTicket", audit.action - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/LogTicket/#{log_ticket.id}" => { diff --git a/test/system/avo/rubygems_test.rb b/test/system/avo/rubygems_test.rb index e9d9dda8c00..df2099044a5 100644 --- a/test/system/avo/rubygems_test.rb +++ b/test/system/avo/rubygems_test.rb @@ -40,7 +40,7 @@ class Avo::RubygemsSystemTest < ApplicationSystemTestCase page.assert_text audit.id assert_equal "Rubygem", audit.auditable_type assert_equal "Release reserved namespace", audit.action - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/Rubygem/#{rubygem.id}" => { @@ -106,7 +106,7 @@ class Avo::RubygemsSystemTest < ApplicationSystemTestCase page.assert_text audit.id assert_equal "Rubygem", audit.auditable_type assert_equal "Yank Rubygem", audit.action - assert_equal( + assert_equal_hash( { "fields" => { "version" => version.id.to_s }, "arguments" => {}, @@ -187,7 +187,7 @@ class Avo::RubygemsSystemTest < ApplicationSystemTestCase assert_equal "Rubygem", audit.auditable_type assert_equal "Yank Rubygem", audit.action - assert_equal( + assert_equal_hash( { "fields" => { "version" => "All" }, "arguments" => {}, @@ -274,7 +274,7 @@ class Avo::RubygemsSystemTest < ApplicationSystemTestCase assert_equal "Rubygem", audit.auditable_type assert_equal "Add owner", audit.action - assert_equal( + assert_equal_hash( { "fields" => { "owner" => { "id" => new_owner.id, "handle" => new_owner.handle } }, "arguments" => {}, diff --git a/test/system/avo/users_test.rb b/test/system/avo/users_test.rb index 19a99118c28..97d4c1c4dab 100644 --- a/test/system/avo/users_test.rb +++ b/test/system/avo/users_test.rb @@ -48,7 +48,7 @@ class Avo::UsersSystemTest < ApplicationSystemTestCase page.assert_text audit.id assert_equal "User", audit.auditable_type assert_equal "Reset User 2FA", audit.action - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/User/#{user.id}" => { @@ -123,7 +123,7 @@ class Avo::UsersSystemTest < ApplicationSystemTestCase page.assert_text audit.id assert_equal "User", audit.auditable_type assert_equal "Block User", audit.action - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/User/#{user.id}" => { @@ -208,7 +208,7 @@ class Avo::UsersSystemTest < ApplicationSystemTestCase page.assert_text audit.id assert_equal "User", audit.auditable_type assert_equal "Reset Api Key", audit.action - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/User/#{user.id}" => { @@ -294,7 +294,7 @@ class Avo::UsersSystemTest < ApplicationSystemTestCase end rubygem_updated_at_changes = rubygem_audit["gid://gemcutter/Rubygem/#{rubygem.id}"]["changes"]["updated_at"] - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/Deletion/#{deletion.id}" => { @@ -398,7 +398,7 @@ class Avo::UsersSystemTest < ApplicationSystemTestCase password_changed_event = user.events.where(tag: Events::UserEvent::PASSWORD_CHANGED).sole version_yanked_event = rubygem.events.where(tag: Events::RubygemEvent::VERSION_YANKED).sole - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/Deletion/#{deletion.id}" => { @@ -519,7 +519,7 @@ class Avo::UsersSystemTest < ApplicationSystemTestCase page.assert_text audit.id assert_equal "User", audit.auditable_type assert_equal "Change User Email", audit.action - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/User/#{user.id}" => { @@ -593,7 +593,7 @@ class Avo::UsersSystemTest < ApplicationSystemTestCase page.assert_text audit.id assert_equal "User", audit.auditable_type assert_equal "Create User", audit.action - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/User/#{user.id}" => { diff --git a/test/system/avo/versions_test.rb b/test/system/avo/versions_test.rb index 75a868ad56f..11b506c1b45 100644 --- a/test/system/avo/versions_test.rb +++ b/test/system/avo/versions_test.rb @@ -53,7 +53,7 @@ class Avo::VersionsSystemTest < ApplicationSystemTestCase rubygem_updated_at_changes = rubygem_audit["gid://gemcutter/Rubygem/#{rubygem.id}"]["changes"]["updated_at"] version_unyank_event = rubygem.events.where(tag: Events::RubygemEvent::VERSION_UNYANKED).sole - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/Version/#{version.id}" => diff --git a/test/system/avo/web_hooks_test.rb b/test/system/avo/web_hooks_test.rb index bbc2c22ca7b..1c28ffeb016 100644 --- a/test/system/avo/web_hooks_test.rb +++ b/test/system/avo/web_hooks_test.rb @@ -31,7 +31,7 @@ class Avo::WebHooksSystemTest < ApplicationSystemTestCase page.assert_text audit.id assert_equal "WebHook", audit.auditable_type assert_equal "Delete Webhook", audit.action - assert_equal( + assert_equal_hash( { "records" => { "gid://gemcutter/WebHook/#{web_hook.id}" => { diff --git a/test/system/oidc_test.rb b/test/system/oidc_test.rb index a6e19618a8a..f18f5d5a627 100644 --- a/test/system/oidc_test.rb +++ b/test/system/oidc_test.rb @@ -142,14 +142,14 @@ def verify_session # rubocop:disable Minitest/TestMethodName } } - assert_equal(expected, role.as_json.slice(*expected.keys)) + assert_equal_hash(expected, role.as_json.slice(*expected.keys)) click_button "Edit API Key Role" page.scroll_to :bottom click_button "Update Api key role" page.assert_selector "h1", text: "API Key Role Push #{rubygem.name}" - assert_equal(expected, role.reload.as_json.slice(*expected.keys)) + assert_equal_hash(expected, role.reload.as_json.slice(*expected.keys)) click_button "Edit API Key Role" @@ -176,7 +176,7 @@ def verify_session # rubocop:disable Minitest/TestMethodName click_button "Update Api key role" page.assert_text "Access policy statements[1] conditions[1] claim unknown for the provider" - assert_equal(expected, role.reload.as_json.slice(*expected.keys)) + assert_equal_hash(expected, role.reload.as_json.slice(*expected.keys)) page.find_field("Claim", with: "fudge").fill_in with: "event_name" @@ -188,31 +188,33 @@ def verify_session # rubocop:disable Minitest/TestMethodName click_button "Update Api key role" page.assert_selector "h1", text: "API Key Role Push gems" - assert_equal(expected.merge( - "name" => "Push gems", - "api_key_permissions" => { - "scopes" => %w[push_rubygem yank_rubygem], "valid_for" => 1800, "gems" => nil - }, - "access_policy" => { - "statements" => [ - { - "effect" => "allow", - "principal" => { "oidc" => "https://token.actions.githubusercontent.com" }, - "conditions" => [ - { "operator" => "string_equals", "claim" => "aud", "value" => "localhost" } - ] - }, - { - "effect" => "allow", - "principal" => { "oidc" => "https://token.actions.githubusercontent.com" }, - "conditions" => [ - { "operator" => "string_matches", "claim" => "sub", "value" => "repo:example/repo:ref:refs/tags/.*" }, - { "operator" => "string_equals", "claim" => "event_name", "value" => "" } - ] - } - ] - } - ), role.reload.as_json.slice(*expected.keys)) + + expected.merge!( + "name" => "Push gems", + "api_key_permissions" => { + "scopes" => %w[push_rubygem yank_rubygem], "valid_for" => 1800, "gems" => nil + }, + "access_policy" => { + "statements" => [ + { + "effect" => "allow", + "principal" => { "oidc" => "https://token.actions.githubusercontent.com" }, + "conditions" => [ + { "operator" => "string_equals", "claim" => "aud", "value" => "localhost" } + ] + }, + { + "effect" => "allow", + "principal" => { "oidc" => "https://token.actions.githubusercontent.com" }, + "conditions" => [ + { "operator" => "string_matches", "claim" => "sub", "value" => "repo:example/repo:ref:refs/tags/.*" }, + { "operator" => "string_equals", "claim" => "event_name", "value" => "" } + ] + } + ] + } + ) + assert_equal_hash(expected, role.reload.as_json.slice(*expected.keys)) end test "creating rubygem trusted publishers" do diff --git a/test/tasks/maintenance/backfill_linkset_links_to_version_metadata_task_test.rb b/test/tasks/maintenance/backfill_linkset_links_to_version_metadata_task_test.rb index 258ed6d2b38..96c76172f56 100644 --- a/test/tasks/maintenance/backfill_linkset_links_to_version_metadata_task_test.rb +++ b/test/tasks/maintenance/backfill_linkset_links_to_version_metadata_task_test.rb @@ -42,7 +42,7 @@ class Maintenance::BackfillLinksetLinksToVersionMetadataTaskTest < ActiveSupport should "only update the home uri" do Maintenance::BackfillLinksetLinksToVersionMetadataTask.process(@version) - assert_equal({ + assert_equal_hash({ "source_code_uri" => "https://example.com/source", "documentation_uri" => "https://example.com/docs", "foo" => "bar", @@ -56,7 +56,7 @@ class Maintenance::BackfillLinksetLinksToVersionMetadataTaskTest < ActiveSupport Maintenance::BackfillLinksetLinksToVersionMetadataTask.process(@version) - assert_equal({ + assert_equal_hash({ "source_code_uri" => "https://example.com/source", "documentation_uri" => "https://example.com/docs", "foo" => "bar", @@ -76,7 +76,7 @@ class Maintenance::BackfillLinksetLinksToVersionMetadataTaskTest < ActiveSupport should "update the version metadata" do Maintenance::BackfillLinksetLinksToVersionMetadataTask.process(@version) - assert_equal({ + assert_equal_hash({ "wiki_uri" => "https://example.com/wiki", "foo" => "bar", "homepage_uri" => "https://example.com/home", diff --git a/test/test_helper.rb b/test/test_helper.rb index b5c11b97833..a1da1d4b86f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -144,6 +144,29 @@ def assert_event(tag, expected_additional, actual) assert_equal actual.additional_type.new(user_agent_info:, **expected_additional), actual.additional end + # Hashes with different orders will still be equal according to assert_equal. + # However, 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. + # + # Improve diff output by sorting any nested hashes within enumerables, + # leaving array order untouched. + def assert_equal_hash(expected, actual, context = "expected") + assert_equal deep_sort_hashes(expected), deep_sort_hashes(actual), "Expected equal elements in #{context}" + end + + # sort the hash keys and recursively sort nested hashes within enumberables + def deep_sort_hashes(obj) + if obj.is_a?(Hash) + obj.map do |k, v| + [k, deep_sort_hashes(v)] + end.sort!.to_h + elsif obj.respond_to?(:map) + obj.map { |v| deep_sort_hashes(v) } + else + obj + end + end + def headless_chrome_driver Capybara.current_driver = :selenium_chrome_headless Capybara.default_max_wait_time = 2 diff --git a/test/unit/avo/actions/base_action_test.rb b/test/unit/avo/actions/base_action_test.rb index ff803c1da39..43318668f80 100644 --- a/test/unit/avo/actions/base_action_test.rb +++ b/test/unit/avo/actions/base_action_test.rb @@ -83,7 +83,7 @@ def each as_json = audit.as_json.except("created_at", "updated_at") as_json.dig("audited_changes", "records").values.sole["changes"].except!("created_at", "updated_at") - assert_equal({ + assert_equal_hash({ "id" => audit.id, "auditable_type" => "WebHook", "auditable_id" => webhook.id, @@ -127,7 +127,7 @@ def each audit = Audit.sole as_json = audit.as_json.except("created_at", "updated_at") - assert_equal({ + assert_equal_hash({ "id" => audit.id, "auditable_type" => "User", "auditable_id" => user.id, @@ -167,7 +167,7 @@ def each as_json = audit.as_json.except("created_at", "updated_at") as_json.dig("audited_changes", "records").values.sole["changes"].except!("created_at", "updated_at") - assert_equal({ + assert_equal_hash({ "id" => audit.id, "auditable_type" => "User", "auditable_id" => user.id, diff --git a/test/unit/gemcutter/request_ip_address_test.rb b/test/unit/gemcutter/request_ip_address_test.rb index 9a7600823f4..197578de624 100644 --- a/test/unit/gemcutter/request_ip_address_test.rb +++ b/test/unit/gemcutter/request_ip_address_test.rb @@ -75,7 +75,7 @@ class Gemcutter::RequestIpAddressTest < ActiveSupport::TestCase geoip_info = @request.ip_address.geoip_info refute_nil geoip_info - assert_equal( + assert_equal_hash( { "continent_code" => "NA", "country_code" => "US", "country_code3" => "USA", "country_name" => "United States of America", "region" => "NY", "city" => "Buffalo" },