Add custom messages for matchers

This gives users natural, easier to understand text for expectations.
This commit is contained in:
Michael Miller 2018-09-24 22:56:48 -06:00
parent 562b544223
commit 8fb051d61e
2 changed files with 10 additions and 0 deletions

View file

@ -10,6 +10,14 @@ module Spectator
def match?(expectation : Expectation)
expectation.actual == @expected
end
def message(expectation : Expectation) : String
"Expected #{expectation.actual} to equal #{@expected} (using ==)"
end
def negated_message(expectation : Expectation) : String
"Expected #{expectation.actual} to not equal #{@expected} (using ==)"
end
end
end
end

View file

@ -7,6 +7,8 @@ module Spectator
end
abstract def match?(expectation : Expectation)
abstract def message(expectation : Expectation) : String
abstract def negated_message(expectation : Expectation) : String
end
end
end