structure_compare 0.1.6 → 0.1.7
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: ad5bf30bbf0c94e5ea5dec89456c7a4cd4c763bc
|
4
|
+
data.tar.gz: 2c683dcc8cabcbe96ce4810e804a33719e4a4ad2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 002d954268e5900d71db1d4519088a184357a81374187ddf581a28333abd4208c431d36e45572ae21ac22bd3133d5a6b56a4578a72f396c79a0d902de9890f89
|
7
|
+
data.tar.gz: c0f4d36ba46c4536c0a90301cda3834c8a9d03d983be97c4fe502d0f74da4c7236ba063383690cebeb378100f35f4395bc3db14cc23142925fba615e5936f449
|
@@ -149,7 +149,7 @@ module StructureCompare
|
|
149
149
|
|
150
150
|
def with_indifferent_access!(actual, key)
|
151
151
|
if [Symbol, String].include?(key.class)
|
152
|
-
has_both_types = (actual.has_key?(key) && actual.has_key?(key.to_s))
|
152
|
+
has_both_types = (actual.has_key?(key.to_sym) && actual.has_key?(key.to_s))
|
153
153
|
duplicate_key_error!(key) if has_both_types
|
154
154
|
|
155
155
|
actual.has_key?(key.to_s) ? actual[key.to_s] : actual[key.to_sym]
|
@@ -113,6 +113,20 @@ class StructureCompareTest < MiniTest::Test
|
|
113
113
|
hash, hash, strict_key_order: true, indifferent_access: true
|
114
114
|
)
|
115
115
|
end
|
116
|
+
|
117
|
+
# this was a bug where exception was raised even if everything is ok
|
118
|
+
hash = { "a" => 1 }
|
119
|
+
assert_structures_equal(hash, hash, indifferent_access: true)
|
120
|
+
hash = { a: 1 }
|
121
|
+
assert_structures_equal(hash, hash, indifferent_access: true)
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_indifferent_access_error_triggers_only_when_both_types_present
|
125
|
+
string_key_hash = { "a" => 1, "b" => 2 }
|
126
|
+
symbol_key_hash = { "a": 1, "b": 2 }
|
127
|
+
|
128
|
+
assert_structures_equal(string_key_hash, symbol_key_hash, indifferent_access: true)
|
129
|
+
assert_structures_equal(symbol_key_hash, string_key_hash, indifferent_access: true)
|
116
130
|
end
|
117
131
|
|
118
132
|
def test_compares_floats_correctly
|