mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Parameterless initializer that generates the label
This commit is contained in:
parent
0e0b8f4ae2
commit
6bfd15b7f9
2 changed files with 7 additions and 1 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(NamedTuple({{method_name}}: Nil)).new({{method_name.stringify}})
|
||||
::Spectator::Matchers::PredicateMatcher(NamedTuple({{method_name}}: Nil)).new
|
||||
{% else %}
|
||||
{% raise "Undefined local variable or method '#{call}'" %}
|
||||
{% end %}
|
||||
|
|
|
@ -5,6 +5,12 @@ module Spectator::Matchers
|
|||
# The `ExpectedType` type param should be a `NamedTuple`.
|
||||
# Each key in the tuple is a predicate (without the `?`) to test.
|
||||
struct PredicateMatcher(ExpectedType) < Matcher
|
||||
# Creates the matcher.
|
||||
# Constructs the label from the type parameters.
|
||||
def initialize
|
||||
super({{ExpectedType.keys.splat.stringify}})
|
||||
end
|
||||
|
||||
# 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