From 3fc271b8e3db6fa511618844ce82495416f5d3a3 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Mon, 12 Aug 2024 11:52:51 +0300 Subject: [PATCH] #64 fixed --- lib/fbe/repeatedly.rb | 2 +- test/fbe/test_repeatedly.rb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/fbe/repeatedly.rb b/lib/fbe/repeatedly.rb index 53acdb4..edf62e1 100644 --- a/lib/fbe/repeatedly.rb +++ b/lib/fbe/repeatedly.rb @@ -47,5 +47,5 @@ def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog, f.what = judge end Fbe.overwrite(f, 'when', Time.now) - yield f + yield fb.query("(and (eq what '#{judge}'))").each.to_a.first end diff --git a/test/fbe/test_repeatedly.rb b/test/fbe/test_repeatedly.rb index f5a71ac..4f3f3f7 100644 --- a/test/fbe/test_repeatedly.rb +++ b/test/fbe/test_repeatedly.rb @@ -25,6 +25,7 @@ require 'minitest/autorun' require 'loog' require 'factbase' +require 'judges/options' require_relative '../test__helper' require_relative '../../lib/fbe/repeatedly' @@ -35,14 +36,16 @@ class TestRepeatedly < Minitest::Test def test_simple $fb = Factbase.new - loog = Loog::NULL + $loog = Loog::NULL + $options = Judges::Options.new judge = 'test' $global = {} 3.times do - Fbe.repeatedly('pmp', 'every_x_hours', loog:, judge:) do |f| + Fbe.repeatedly('pmp', 'every_x_hours', judge:) do |f| f.foo = 42 end end assert_equal(1, $fb.size) + assert_equal(42, $fb.query('(always)').each.to_a.first.foo) end end