Skip to content

Commit 64f55b2

Browse files
committed
adjust sorting before comparison
1 parent bb4a58f commit 64f55b2

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

test/lib/rails_stats/json_formatter_test.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,18 +263,20 @@
263263
expectation = JSON.parse(JSON_STRING)
264264
result = formatter.result
265265

266-
expectation.each do |hash|
267-
if hash["gems"]
268-
hash["gems"].each do |gem|
269-
gem["transitive_dependencies"]&.sort!
270-
end
271-
end
272-
end
266+
[expectation, result].each do |data|
267+
data.each do |hash|
268+
next unless hash["gems"]
273269

274-
result.each do |hash|
275-
if hash["gems"]
276270
hash["gems"].each do |gem|
277-
gem["transitive_dependencies"]&.sort!
271+
next unless gem["transitive_dependencies"]
272+
273+
gem["transitive_dependencies"].map! do |dep|
274+
name, constraints = dep.split(/[()]/)
275+
next dep unless constraints
276+
277+
normalized_constraints = constraints.split(/,\s*/).sort.join(', ')
278+
"#{name}(#{normalized_constraints})"
279+
end.sort!
278280
end
279281
end
280282
end

0 commit comments

Comments
 (0)