2019-03-07 01:40:57 +00:00
|
|
|
# Retrieves a value from the `NamedTuple` returned by `Spectator::Matchers::MatchData#values`.
|
2019-03-07 23:12:23 +00:00
|
|
|
def match_data_value(match_data, key)
|
|
|
|
match_data.values.fetch(key) { raise "#{key} is missing" }
|
2019-03-07 01:40:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Retrieves the string representation and base value
|
|
|
|
# from a `Spectator::Matchers::PrefixedValue`
|
|
|
|
# in a `NamedTuple` returned by `Spectator::Matchers::MatchData#values`.
|
2019-03-07 23:12:23 +00:00
|
|
|
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}
|
2019-03-07 01:40:57 +00:00
|
|
|
end
|
|
|
|
end
|