structure_compare 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ccf54b4f42263485c1a93a50989e69b82d40e91
|
4
|
+
data.tar.gz: a0a85c991d901feb6fdfae988df7e48c07d628d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1d25d9ddf2945090a8b9cb534e63dce989e241199e72145a8caf374fab5325afc4afab9c7acdd05fe88cd4af187d4f6a358ad728ed082b75348a96c2241a79d
|
7
|
+
data.tar.gz: f2ef2e68269c3f9a9555214189d98e25e849d2e7db6ecf706daa80ae5999d3f5dc42df529d80b4956c71f53499c55e47756e89b23e0d5f83335c4e5e48a29433
|
@@ -68,7 +68,7 @@ module StructureCompare
|
|
68
68
|
actual_value = actual[key]
|
69
69
|
end
|
70
70
|
|
71
|
-
path_segment =
|
71
|
+
path_segment = "[#{dump_key(key)}]"
|
72
72
|
@path.push(path_segment)
|
73
73
|
|
74
74
|
check_structures_equal!(expected_value, actual_value)
|
@@ -82,8 +82,7 @@ module StructureCompare
|
|
82
82
|
actual_keys = actual.keys
|
83
83
|
|
84
84
|
failure_message = "hash keys aren't equal. " \
|
85
|
-
"expected: #{expected_keys
|
86
|
-
"actual: #{actual_keys.map(&:to_s).join(',')}"
|
85
|
+
"expected: #{dump_keys(expected_keys)}, actual: #{dump_keys(actual_keys)}"
|
87
86
|
|
88
87
|
if @options[:indifferent_access]
|
89
88
|
# NOTE: not all hash keys are symbols/strings, only convert symbols
|
@@ -165,5 +164,14 @@ module StructureCompare
|
|
165
164
|
"can not use indifferent_access option!"
|
166
165
|
)
|
167
166
|
end
|
167
|
+
|
168
|
+
def dump_keys(keys)
|
169
|
+
key_names = keys.map { |key| dump_key(key) }
|
170
|
+
"[#{key_names.join(', ')}]"
|
171
|
+
end
|
172
|
+
|
173
|
+
def dump_key(key)
|
174
|
+
key.is_a?(Symbol) ? ":#{key}" : "\"#{key}\""
|
175
|
+
end
|
168
176
|
end
|
169
177
|
end
|
@@ -9,7 +9,8 @@ class StructureCompareTest < MiniTest::Test
|
|
9
9
|
|
10
10
|
def test_compares_keys_of_hashes
|
11
11
|
refute_structures_equal({a: 1, b: 2}, {a: 1, other_key: 2})
|
12
|
-
refute_structures_equal({a: 1, b: 2}, {a: 1, b: 2, c
|
12
|
+
refute_structures_equal({a: 1, b: 2}, {a: 1, b: 2, "c" => 3})
|
13
|
+
refute_structures_equal({a: 1, b: 2, "c" => 3}, {a: 1, b: 2})
|
13
14
|
end
|
14
15
|
|
15
16
|
def test_hash_key_order_is_compared_if_option_set
|