From a2adfbc7b533818917df86965002c8c653721cfb Mon Sep 17 00:00:00 2001 From: gemshrine <113778529+gemshrine@users.noreply.github.com> Date: Sat, 3 Oct 2026 10:03:38 +0300 Subject: [PATCH] #835: accept property arrays in Conclude#follow --- lib/fbe/conclude.rb | 13 ++++++++++++- test/fbe/test_conclude.rb | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/fbe/conclude.rb b/lib/fbe/conclude.rb index 3dfbad89..081cc6d6 100644 --- a/lib/fbe/conclude.rb +++ b/lib/fbe/conclude.rb @@ -131,7 +131,18 @@ def on(query) # @raise [Fbe::Error] If +what+ or +details+ is in the list, since +draw+ sets them def follow(props) raise(Fbe::Error, 'Follow is already set') unless @follows.nil? - list = props.strip.split.compact + list = + case props + when String + props.strip.split + when Array + unless props.all? { |prop| prop.is_a?(String) } + raise(Fbe::Error, 'Follow expects an Array of Strings') + end + props.map(&:strip).reject(&:empty?) + else + raise(Fbe::Error, 'Follow expects a String or an Array of Strings') + end bad = list & %w[what details] raise(Fbe::Error, "Can't follow #{bad.join(' and ')}, the judge sets it in the new fact") unless bad.empty? @follows = list diff --git a/test/fbe/test_conclude.rb b/test/fbe/test_conclude.rb index 66e9343c..c18334a5 100644 --- a/test/fbe/test_conclude.rb +++ b/test/fbe/test_conclude.rb @@ -351,7 +351,7 @@ def test_follow_multivalued Fbe.conclude(judge: 'judge-follow') do quota_unaware on('(exists foo)') - follow('tags') + follow(%w[tags]) draw do |n, _prev| n.processed = 'yes' 'Some long description that satisfies the twenty five chars minimum.' @@ -426,6 +426,19 @@ def test_follow_raises_on_second_call end end + def test_follow_rejects_non_string_properties + fb = Factbase.new + error = + assert_raises(Fbe::Error) do + Fbe.conclude(fb:, judge: 'judge-follow', options: Judges::Options.new, global: {}, loog: Loog::NULL) do + quota_unaware + on('(exists foo)') + follow(['tags', 42]) + end + end + assert_includes(error.message, 'Array of Strings') + end + def test_follow_refuses_properties_set_by_judge %w[what details].each do |prop| fb = Factbase.new