Allow be matcher to be used on structs

This commit is contained in:
Michael Miller 2020-01-19 22:39:21 -07:00
parent 3d08949c94
commit 60f1c3091b
3 changed files with 11 additions and 5 deletions

View file

@ -13,7 +13,13 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : TestExpression(T)) : Bool forall T
expected.value.same?(actual.value)
value = expected.value
if value.responds_to?(:same)
value.same?(actual.value)
else
# Value type (struct) comparison.
actual.value.class == value.class && actual.value == value
end
end
# Message displayed when the matcher isn't satisifed.