mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add nil matcher
This commit is contained in:
parent
90de8c312d
commit
69d0856256
1 changed files with 25 additions and 0 deletions
25
src/spectator/matchers/nil_matcher.cr
Normal file
25
src/spectator/matchers/nil_matcher.cr
Normal file
|
@ -0,0 +1,25 @@
|
|||
require "./value_matcher"
|
||||
|
||||
module Spectator::Matchers
|
||||
# Common matcher that tests whether a value is nil.
|
||||
# The values are compared with the `#nil?` method.
|
||||
struct NilMatcher < ConditionMatcher
|
||||
# Determines whether the matcher is satisfied with the value given to it.
|
||||
# True is returned if the match was successful, false otherwise.
|
||||
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
|
||||
partial.actual.nil?
|
||||
end
|
||||
|
||||
# Describes the condition that satisfies the matcher.
|
||||
# This is informational and displayed to the end-user.
|
||||
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
|
||||
"Expected #{partial.label} to be nil"
|
||||
end
|
||||
|
||||
# Describes the condition that won't satsify the matcher.
|
||||
# This is informational and displayed to the end-user.
|
||||
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
|
||||
"Expected #{partial.label} to not be nil"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue