Fix the actual type reported by the type matcher

If an object has a difference between compiler and runtime type, then 
the type matcher would report the actual as the compiler type.
The match would be successful, because it uses the runtime check 
(is_a?).
This commit is contained in:
Michael Miller 2019-06-01 20:48:24 -06:00
parent b6ac736dd2
commit cc4ab9756a

View file

@ -19,13 +19,13 @@ module Spectator::Matchers
# `MatchData` is returned that contains information about the match.
def match(partial)
actual = partial.actual
MatchData(Expected, typeof(actual)).new(match?(actual), partial.label)
MatchData(Expected, typeof(actual)).new(match?(actual), actual, partial.label)
end
# Match data specific to this matcher.
private struct MatchData(ExpectedType, ActualType) < MatchData
# Creates the match data.
def initialize(matched, @actual_label : String)
def initialize(matched, @actual : ActualType, @actual_label : String)
super(matched)
end
@ -33,7 +33,7 @@ module Spectator::Matchers
def named_tuple
{
expected: NegatableMatchDataValue.new(ExpectedType),
actual: ActualType,
actual: @actual.class,
}
end