Change how values are passed to helper

Working around a segfault (dunno why this fixes it).
This commit is contained in:
Michael Miller 2019-03-22 11:53:20 -06:00
parent d705ef657c
commit e7e1d0e084
24 changed files with 106 additions and 107 deletions

View file

@ -1,6 +1,6 @@
# Retrieves a value from match data given its key/label.
def match_data_value_with_key(match_data, key)
labeled_value = match_data.values.find { |v| v.label == key }
def match_data_value_with_key(match_data_values, key)
labeled_value = match_data_values.find { |v| v.label == key }
raise "#{key} is missing" unless labeled_value
labeled_value.value
end
@ -8,17 +8,13 @@ end
# Retrieves the string representation and base value
# from a `Spectator::Matchers::PrefixedMatchDataValue` (or similar)
# in the values returned by `Spectator::Matchers::MatchData#values`.
def match_data_value_sans_prefix(match_data, key)
prefix = match_data_value_with_key(match_data, key)
if prefix.responds_to?(:value)
{to_s: prefix.to_s, value: prefix.value}
else
{to_s: prefix.to_s, value: prefix}
end
def match_data_value_sans_prefix(match_data_values, key)
prefix = match_data_value_with_key(match_data_values, key)
{to_s: prefix.to_s, value: prefix.value}
end
# Check whether match data has a value with a specified key/label.
def match_data_has_key?(match_data, key)
found = match_data.values.find { |v| v.label == key }
def match_data_has_key?(match_data_values, key)
found = match_data_values.find { |v| v.label == key }
!!found
end