|
174 | 174 |
|
175 | 175 | failure_message do |response|
|
176 | 176 | "the expected response pair/value(s) #{@mismatched_pairs}" +
|
177 |
| - " does not match the pair/value(s) in the response #{response}" |
| 177 | + " does not match the pair/value(s) in the response #{response}" |
178 | 178 | end
|
179 | 179 |
|
180 | 180 | def sanitize_pairs(expected_pairs)
|
@@ -235,8 +235,14 @@ def compare_hash(expected_pairs, actual_hash, test)
|
235 | 235 | when Hash
|
236 | 236 | compare_hash(expected_value, actual_value, test)
|
237 | 237 | when Array
|
238 |
| - unless compare_array(expected_value, actual_value, test, actual_hash) |
239 |
| - @mismatched_pairs.merge!(expected_key => expected_value) |
| 238 | + begin |
| 239 | + unless compare_array(expected_value.sort, actual_value.sort, test, actual_hash) |
| 240 | + @mismatched_pairs.merge!(expected_key => expected_value) |
| 241 | + end |
| 242 | + rescue TypeError, ArgumentError |
| 243 | + unless compare_array(expected_value, actual_value, test, actual_hash) |
| 244 | + @mismatched_pairs.merge!(expected_key => expected_value) |
| 245 | + end |
240 | 246 | end
|
241 | 247 | when String
|
242 | 248 | unless compare_string(expected_value, actual_value, test, actual_hash)
|
@@ -283,6 +289,8 @@ def compare_array(expected, actual, test, response)
|
283 | 289 | return false unless compare_array(value, actual[i], test, response)
|
284 | 290 | when String
|
285 | 291 | return false unless compare_string(value, actual[i], test, response)
|
| 292 | + else |
| 293 | + true |
286 | 294 | end
|
287 | 295 | end
|
288 | 296 | end
|
|
0 commit comments