Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/db_factory/helpers.rb
Instance Method Summary collapse
-
#diff(other) ⇒ Object
Returns difference between 2 hashes (actual values and expecyted values) as Hash with “expected” and “actual” keys.
Instance Method Details
#diff(other) ⇒ Object
Returns difference between 2 hashes (actual values and expecyted values) as Hash with “expected” and “actual” keys
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/db_factory/helpers.rb', line 22 def diff(other) l_keys = self.keys.concat(other.keys).uniq l_keys.inject({}) do |memo, key| l_expected = other[key] rescue {} unless self[key] == l_expected memo[key] = {"actual" => self[key], "expected" => l_expected} end memo end end |