mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Define some Expectation methods
This commit is contained in:
parent
3035273e9a
commit
4c2f6157af
2 changed files with 21 additions and 1 deletions
|
@ -1,4 +1,11 @@
|
|||
module Spectator::Expectations
|
||||
abstract class Expectation
|
||||
getter? negated : Bool
|
||||
|
||||
private def initialize(@negated)
|
||||
end
|
||||
|
||||
abstract def eval : Bool
|
||||
abstract def message : String
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,19 @@
|
|||
require "./expectation"
|
||||
|
||||
module Spectator::Expectations
|
||||
class ValueExpectation < Expectation
|
||||
class ValueExpectation(ActualType, ExpectedType) < Expectation
|
||||
def initialize(negated,
|
||||
@partial : ValueExpectationPartial(ActualType),
|
||||
@matcher : ValueMatcher(ExpectedType))
|
||||
super(negated)
|
||||
end
|
||||
|
||||
def eval : Bool
|
||||
@matcher.match?(@partial) ^ negated?
|
||||
end
|
||||
|
||||
def message : String
|
||||
negated? ? @matcher.negated_message(@partial) : @matcher.message(@partial)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue