Skip to content

Commit f1aeeb4

Browse files
sobrinhosausman
authored andcommitted
Fix equality comparator of super hash with nil (#30)
Fix an #<ArgumentError: odd number of arguments for Hash> exception.
1 parent ce3a887 commit f1aeeb4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/dwolla_v2/super_hash.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class SuperHash < Hash
66
include Hashie::Extensions::DeepFetch
77

88
def == other
9-
super(other) || super(self.class[other])
9+
super(other) || other && super(self.class[other])
1010
end
1111
end
1212
end

spec/dwolla_v2/super_hash_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,10 @@
2222
super_hash = DwollaV2::Util.deep_super_hasherize(hash)
2323
expect(super_hash).to eq hash
2424
end
25+
26+
it "== works with nil values" do
27+
hash = { a: { b: { c: "d" } } }
28+
super_hash = DwollaV2::Util.deep_super_hasherize(hash)
29+
expect(super_hash).not_to eq nil
30+
end
2531
end

0 commit comments

Comments
 (0)