mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fix tests to account for negation wrappers
This commit is contained in:
parent
37f2ce99a3
commit
0ca0ba0a55
19 changed files with 53 additions and 45 deletions
|
@ -1,23 +1,16 @@
|
|||
# Retrieves a value from the `NamedTuple` returned by `Spectator::Matchers::MatchData#values`.
|
||||
def match_data_value(match_data, key, t : T.class) forall T
|
||||
match_data.values.fetch(key) { raise "#{key} is missing" }.as(T)
|
||||
def match_data_value(match_data, key)
|
||||
match_data.values.fetch(key) { raise "#{key} is missing" }
|
||||
end
|
||||
|
||||
# Retrieves the string representation and base value
|
||||
# from a `Spectator::Matchers::PrefixedValue`
|
||||
# in a `NamedTuple` returned by `Spectator::Matchers::MatchData#values`.
|
||||
def match_data_prefix(match_data, key, t : T.class) forall T
|
||||
prefix = match_data_value(match_data, key, Spectator::Matchers::PrefixGrabber.get(t))
|
||||
{to_s: prefix.to_s, value: prefix.value}
|
||||
end
|
||||
|
||||
# Dirty cheat to get around visibility restriction.
|
||||
module Spectator::Matchers
|
||||
module PrefixGrabber
|
||||
extend self
|
||||
|
||||
def get(t : T.class) forall T
|
||||
PrefixedValue(T)
|
||||
end
|
||||
def match_data_prefix(match_data, key)
|
||||
prefix = match_data.values.fetch(key) { raise "#{key} is missing" }
|
||||
if prefix.responds_to?(:value)
|
||||
{to_s: prefix.to_s, value: prefix.value}
|
||||
else
|
||||
{to_s: prefix.to_s, value: prefix}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue