mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Base PredicateMatcher off of Matcher
No need to store an expected value. Matcher's initializer must be public.
This commit is contained in:
parent
89208b8ed1
commit
0e0b8f4ae2
3 changed files with 3 additions and 3 deletions
|
@ -423,7 +423,7 @@ module Spectator::DSL
|
|||
macro method_missing(call)
|
||||
{% if call.name.starts_with?("be_") %}
|
||||
{% method_name = call.name[3..-1] %} # Remove `be_` prefix.
|
||||
::Spectator::Matchers::PredicateMatcher.new({{method_name.stringify}}, { {{method_name}}: nil })
|
||||
::Spectator::Matchers::PredicateMatcher(NamedTuple({{method_name}}: Nil)).new({{method_name.stringify}})
|
||||
{% else %}
|
||||
{% raise "Undefined local variable or method '#{call}'" %}
|
||||
{% end %}
|
||||
|
|
|
@ -9,7 +9,7 @@ module Spectator::Matchers
|
|||
private getter label : String
|
||||
|
||||
# Creates the base of the matcher.
|
||||
private def initialize(@label)
|
||||
def initialize(@label)
|
||||
end
|
||||
|
||||
# Determines whether the matcher is satisfied with the value given to it.
|
||||
|
|
|
@ -4,7 +4,7 @@ module Spectator::Matchers
|
|||
# Matcher that tests one or more predicates (methods ending in `?`).
|
||||
# The `ExpectedType` type param should be a `NamedTuple`.
|
||||
# Each key in the tuple is a predicate (without the `?`) to test.
|
||||
struct PredicateMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||
struct PredicateMatcher(ExpectedType) < Matcher
|
||||
# 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)
|
||||
|
|
Loading…
Reference in a new issue