Skip to content

Commit

Permalink
Autocorrect rubocop violations
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
kamipo committed Sep 10, 2024
1 parent 1016673 commit b4207d2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions activemodel/test/cases/serializers/json_serialization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b4207d2

Please sign in to comment.