Skip to content

Commit 5872288

Browse files
groyohmcmire
authored andcommitted
Fixes #100
When a key in the `actual` results in a noop and its key index in the `expected` is less than its index in the `actual`, the diff would display a `delete` for this key along with a noop. For instance, in the diff below we have `- profile_background_tile: false,` and ` profile_background_tile: false`. ``` Differing hashes. Expected: { created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, geo_enabled: false, verified: true, media_count: 51044, statuses_count: 273860, contributors_enabled: false, profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_color: "FFF1E0", profile_background_tile: false, profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", listed_count: 37009, profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" } Actual: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592", profile_background_tile: false } Diff: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, - geo_enabled: false, - verified: true, + utc_offset: nil, statuses_count: 273860, media_count: 51044, contributors_enabled: false, + is_translator: false, + is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", - profile_background_tile: false, - profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592", profile_background_tile: false } ```
1 parent 2bce2b1 commit 5872288

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/super_diff/operation_tree_builders/hash.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def unary_operations_using_variant_of_patience_algorithm
5353
ev2, av2 = expected[ek], actual[ek]
5454

5555
if (
56-
(!actual.include?(ek) || ev != av2) &&
56+
(!actual.include?(ek) || ev2 != av2) &&
5757
operations.none? { |operation|
5858
[:delete, :noop].include?(operation.name) &&
5959
operation.key == ek

spec/unit/equality_matchers/main_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,8 +1166,8 @@
11661166
is_translation_enabled: false,
11671167
profile_background_color: "FFF1E0",
11681168
profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",
1169-
profile_background_tile: false,
11701169
profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",
1170+
profile_background_tile: false,
11711171
}
11721172
)
11731173

@@ -1177,7 +1177,7 @@
11771177
#{
11781178
colored do
11791179
expected_line %(Expected: { created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, geo_enabled: false, verified: true, media_count: 51044, statuses_count: 273860, contributors_enabled: false, profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_color: "FFF1E0", profile_background_tile: false, profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg", listed_count: 37009, profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1180-
actual_line %( Actual: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_background_tile: false, profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592" })
1180+
actual_line %( Actual: { listed_count: 37009, created_at: "Tue Jan 13 19:28:24 +0000 2009", favourites_count: 38, utc_offset: nil, statuses_count: 273860, media_count: 51044, contributors_enabled: false, is_translator: false, is_translation_enabled: false, profile_background_color: "FFF1E0", profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png", profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592", profile_background_tile: false })
11811181
end
11821182
}
11831183
@@ -1199,9 +1199,9 @@
11991199
actual_line %(+ is_translation_enabled: false,)
12001200
plain_line %( profile_background_color: "FFF1E0",)
12011201
plain_line %( profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme1/bg.png",)
1202-
plain_line %( profile_background_tile: false,)
12031202
expected_line %(- profile_image_url: "http://pbs.twimg.com/profile_images/931156393108885504/EqEMtLhM_normal.jpg",)
1204-
plain_line %( profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592")
1203+
plain_line %( profile_banner_url: "https://pbs.twimg.com/profile_banners/18949452/1581526592",)
1204+
plain_line %( profile_background_tile: false)
12051205
plain_line %( })
12061206
end
12071207
}

0 commit comments

Comments
 (0)