From b4207d2432575de2aa34bafd84f41c98f2beeadf Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 10 Sep 2024 13:02:33 +0900 Subject: [PATCH] Autocorrect rubocop violations https://buildkite.com/rails/rails/builds/111156#0191d93b-1a10-4283-9109-f66bb815ba68 ``` % be rubocop -A activemodel/test/cases/serializers/json_serialization_test.rb Inspecting 1 file C Offenses: activemodel/test/cases/serializers/json_serialization_test.rb:174:18: C: [Corrected] Minitest/LiteralAsActualArgument: Replace the literal with the first argument. assert_equal json, { "name" => "Konata Izumi" } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ activemodel/test/cases/serializers/json_serialization_test.rb:181:18: C: [Corrected] Minitest/LiteralAsActualArgument: Replace the literal with the first argument. assert_equal json, { "name" => "Konata Izumi" } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ activemodel/test/cases/serializers/json_serialization_test.rb:213:18: C: [Corrected] Minitest/LiteralAsActualArgument: Replace the literal with the first argument. assert_equal json["address"], { "city" => "Trichy" } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ activemodel/test/cases/serializers/json_serialization_test.rb:223:18: C: [Corrected] Minitest/LiteralAsActualArgument: Replace the literal with the first argument. assert_equal json["address"], { "city" => "Trichy" } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 file inspected, 4 offenses detected, 4 offenses corrected ``` --- .../test/cases/serializers/json_serialization_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/activemodel/test/cases/serializers/json_serialization_test.rb b/activemodel/test/cases/serializers/json_serialization_test.rb index 4073d7ebb9ea7..09e66ef537f52 100644 --- a/activemodel/test/cases/serializers/json_serialization_test.rb +++ b/activemodel/test/cases/serializers/json_serialization_test.rb @@ -171,14 +171,14 @@ def @contact.favorite_quote; "Constraints are liberating"; end json = @contact.as_json(except: [:age, :created_at, :awesome, :preferences]) assert_kind_of Hash, json - assert_equal json, { "name" => "Konata Izumi" } + assert_equal({ "name" => "Konata Izumi" }, json) end test "as_json should allow attribute filtering with only" do json = @contact.as_json(only: :name) assert_kind_of Hash, json - assert_equal json, { "name" => "Konata Izumi" } + assert_equal({ "name" => "Konata Izumi" }, json) end test "as_json should work with methods options" do @@ -210,7 +210,7 @@ def @contact.favorite_quote; "Constraints are liberating"; end %w(name age created_at awesome preferences).each do |field| assert_equal @contact.public_send(field).as_json, json[field] end - assert_equal json["address"], { "city" => "Trichy" } + assert_equal({ "city" => "Trichy" }, json["address"]) end test "as_json should work with include option paired with except filter" do @@ -220,7 +220,7 @@ def @contact.favorite_quote; "Constraints are liberating"; end %w(name age created_at awesome preferences).each do |field| assert_equal @contact.public_send(field).as_json, json[field] end - assert_equal json["address"], { "city" => "Trichy" } + assert_equal({ "city" => "Trichy" }, json["address"]) end test "from_json should work without a root (class attribute)" do