Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
code review feedback: defines diff_hashes_as_object conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlHeitmann committed Jun 15, 2024
1 parent 31f086e commit 15843e3
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions lib/rspec/support/differ.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,26 @@ def diff_as_string(actual, expected)
end
# rubocop:enable Metrics/MethodLength

def diff_hashes_as_object(actual, expected)
if defined?(RSpec::Mocks::ArgumentMatchers::AnyArgMatcher)
expected_to_diff =
expected.reduce({}) do |hash, (key, value)|
if RSpec::Mocks::ArgumentMatchers::AnyArgMatcher === value
hash[key] = actual[key]
else
hash[key] = expected[key]
if defined?(RSpec::Mocks::ArgumentMatchers::AnyArgMatcher)
def diff_hashes_as_object(actual, expected)
if defined?(RSpec::Mocks::ArgumentMatchers::AnyArgMatcher)
expected_to_diff =
expected.reduce({}) do |hash, (key, value)|
if RSpec::Mocks::ArgumentMatchers::AnyArgMatcher === value
hash[key] = actual[key]
else
hash[key] = expected[key]
end
hash
end
hash
end

diff_as_object(actual, expected_to_diff)
else
diff_as_object(actual, expected_to_diff)
else
diff_as_object(actual, expected)
end
end
else
def diff_hashes_as_object(actual, expected)
diff_as_object(actual, expected)
end
end
Expand Down

0 comments on commit 15843e3

Please sign in to comment.