diff --git a/src/spectator/expectations/expectation.cr b/src/spectator/expectations/expectation.cr index f88b4b6..731f3b2 100644 --- a/src/spectator/expectations/expectation.cr +++ b/src/spectator/expectations/expectation.cr @@ -2,13 +2,12 @@ module Spectator::Expectations # Ties together a partial, matcher, and their outcome. class Expectation # Populates the base portiion of the expectation with values. - # The *matched* flag should be true if the matcher is satisfied with the partial. # The *negated* flag should be true if the expectation is inverted. - # These options are mutually-exclusive in this context. - # Don't flip the value of *matched* because *negated* is true. # The *match_data* is the value returned by `Spectator::Matcher#match` # when the expectation was evaluated. - def initialize(@matched : Bool, @negated : Bool, @match_data : MatchData) + # The *negated* flag and `MatchData#matched?` flag + # are mutually-exclusive in this context. + def initialize(@match_data : MatchData, @negated : Bool) end # Indicates whether the expectation was satisifed. @@ -16,7 +15,7 @@ module Spectator::Expectations # - The matcher was satisified and the expectation is not negated. # - The matcher wasn't satisfied and the expectation is negated. def satisfied? - @matched ^ @negated + @match_data.matched? ^ @negated end # Text that indicates the condition that must be met for the expectation to be satisifed. diff --git a/src/spectator/expectations/expectation_partial.cr b/src/spectator/expectations/expectation_partial.cr index 9265178..0238a8e 100644 --- a/src/spectator/expectations/expectation_partial.cr +++ b/src/spectator/expectations/expectation_partial.cr @@ -45,7 +45,7 @@ module Spectator::Expectations # Evaluates the expectation and returns it. private def eval(matcher, negated = false) match_data = matcher.match(self) - Expectation.new(matched, negated, match_data) + Expectation.new(match_data, negated) end # Reports an expectation to the current harness.