compare scrubbed attribute values rather than attribute hashes#6
compare scrubbed attribute values rather than attribute hashes#6davebenvenuti wants to merge 1 commit intomasterfrom
Conversation
There was a problem hiding this comment.
Why use Date instead of DateTime here (like above)? I believe cassandra_datum uses DateTime to be compatible with ActiveAttr. You could easily convert to a date and take the integer if that is the desired comparison.
There was a problem hiding this comment.
I'll make it a DateTime
There was a problem hiding this comment.
I don't believe Date has a "to_i" method. Perhaps the end of this method should be:
try_to_i = lambda {|v| v.respond_to?(:to_i) && v.to_i || v}
assert_equal try_to_i.call(value1), try_to_i.call(value2), full_explanation
Alternatively, you could still remove the assert_hashes_equal method and change this:
assert_attributes_equal datum1, datum2, explanation
to something like (this could certainly be cleaned up to make it more DRY):
try_to_i = lambda {|v| v.respond_to?(:to_i) && v.to_i || v}
assert_equal Hash[datum1.attributes.map {|k, v| [k, try_to_i.call(v)]}], Hash[datum2.attributes.map {|k, v| [k, try_to_i.call(v)]}], explanation
Otherwise, LGTM
Cleans up output and attribute comparisons in assert_data_equal and related methods