Fix "should" syntax

This commit is contained in:
Michael Miller 2019-03-23 20:15:35 -06:00
parent ebfec8058e
commit 102105911c

View file

@ -20,18 +20,13 @@ class Object
# First argument of the `Expectation` initializer is the expression label. # First argument of the `Expectation` initializer is the expression label.
# However, since this isn't a macro and we can't "look behind" this method call # However, since this isn't a macro and we can't "look behind" this method call
# to see what it was invoked on, the argument is an empty string. # to see what it was invoked on, the argument is an empty string.
expectation = ::Spectator::Expectation.new(self) # Additionally, the source file and line can't be obtained.
unless matcher.match?(expectation) ::Spectator::Expectations::ValueExpectationPartial.new(self, __FILE__, __LINE__).to(matcher)
raise ::Spectator::ExpectationFailed.new(matcher.message(expectation))
end
end end
# Works the same as `#should` except the condition is inverted. # Works the same as `#should` except the condition is inverted.
# When `#should` succeeds, this method will fail, and vice-versa. # When `#should` succeeds, this method will fail, and vice-versa.
def should_not(matcher : ::Spectator::Matchers::Matcher) def should_not(matcher : ::Spectator::Matchers::Matcher)
expectation = ::Spectator::Expectation.new(self) ::Spectator::Expectations::ValueExpectationPartial.new(self, __FILE__, __LINE__).to_not(matcher)
if matcher.match?(expectation)
raise ::Spectator::ExpectationFailed.new(matcher.message(expectation))
end
end end
end end