mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add missing methods to matchers
Fix matcher inheritance.
This commit is contained in:
parent
9bffb30041
commit
1222e24836
3 changed files with 25 additions and 1 deletions
|
@ -15,6 +15,14 @@ module Spectator::Matchers
|
|||
def initialize(@expected : TestValue(ExpectedType))
|
||||
end
|
||||
|
||||
def description
|
||||
if (message = @expected)
|
||||
"raises #{ExceptionType} with message #{message}"
|
||||
else
|
||||
"raises #{ExceptionType}"
|
||||
end
|
||||
end
|
||||
|
||||
def match(actual)
|
||||
exception = capture_exception { actual.value }
|
||||
case exception
|
||||
|
|
|
@ -34,6 +34,14 @@ module Spectator::Matchers
|
|||
end
|
||||
end
|
||||
|
||||
private def failure_message(actual)
|
||||
"#{actual.label} does not have #{expected.label}"
|
||||
end
|
||||
|
||||
private def failure_message_when_negated(actual)
|
||||
"#{actual.label} has #{expected.label}"
|
||||
end
|
||||
|
||||
# Captures all of the actual values.
|
||||
# A `NamedTuple` is returned, with each key being the attribute.
|
||||
private def snapshot_values(object)
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::Matchers
|
|||
# The `ExpectedType` type param should be a `NamedTuple`.
|
||||
# Each key in the tuple is a predicate (without the '?') to test.
|
||||
# Each value is a a `Tuple` of arguments to pass to the predicate method.
|
||||
struct PredicateMatcher(ExpectedType) < Matcher(ExpectedType)
|
||||
struct PredicateMatcher(ExpectedType) < Matcher
|
||||
private getter expected
|
||||
|
||||
def initialize(@expected : TestValue(ExpectedType))
|
||||
|
@ -33,6 +33,14 @@ module Spectator::Matchers
|
|||
end
|
||||
end
|
||||
|
||||
private def failure_message(actual)
|
||||
"#{actual.label} is not #{expected.label}"
|
||||
end
|
||||
|
||||
private def failure_message_when_negated(actual)
|
||||
"#{actual.label} is #{expected.label}"
|
||||
end
|
||||
|
||||
# Captures all of the actual values.
|
||||
# A `NamedTuple` is returned, with each key being the attribute.
|
||||
private def snapshot_values(object)
|
||||
|
|
Loading…
Reference in a new issue