Add custom messages for matchers
This gives users natural, easier to understand text for expectations.
This commit is contained in:
parent
562b544223
commit
8fb051d61e
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue