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: c7e3a4d3ba5b971952f4c8b36cbc5625eddeef86
4
- data.tar.gz: 696b6e7775ff575315164a84cd4156082f12d369
3
+ metadata.gz: ad5bf30bbf0c94e5ea5dec89456c7a4cd4c763bc
4
+ data.tar.gz: 2c683dcc8cabcbe96ce4810e804a33719e4a4ad2
5
5
  SHA512:
6
- metadata.gz: a6ede945d269bfdebb0eb77783a9a3797d426e0b0198a3b801fd7b076be9790ac2f6116ac6282098b3af3ce5373108abb08a9eaa6af54348b026278a962d450e
7
- data.tar.gz: dcead81b09f0223e65cc5a7120cbdf4059ec2c2a085c3170ae3ab4c1178915dbed9ae53b14c04f794e8a8a5e2b14e4fee23b5f4f2d2fe47ec76025ed9dd32fe5
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]
@@ -1,3 +1,3 @@
1
1
  module StructureCompare
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structure_compare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Seeger