Skip to content

Commit 06411e4

Browse files
committed
Added regex to expect() for debug messages to ensure we are getting the correct messages + moved those expect() lines out of the before(:each) blocks and into it blocks
1 parent 19f742e commit 06411e4

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

spec/connectors/crawler/crawler_scheduler_spec.rb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,14 @@
174174

175175
before(:each) do
176176
allow(cron_parser).to receive(:next_time).with(time_at_poll_start).and_return(next_trigger_time, weekly_next_trigger_time, monthly_next_trigger_time)
177-
expect(Utility::Logger).to receive(:debug).exactly(3).times.with(instance_of(String)) # expect three debug messages because three schedules are not being triggered
178177
end
179178

180-
it_behaves_like 'does not trigger'
179+
# functionally the same as shared test 'does not trigger' but with an extra expect() to check for debug messages
180+
it 'does not yield task' do
181+
# expect three debug messages because three schedules are not being triggered
182+
expect(Utility::Logger).to receive(:debug).exactly(3).times.with(match(/^Sync for (\w+.*)|( - \w+) not triggered as .*/))
183+
expect { |b| subject.when_triggered(&b) }.to_not yield_control
184+
end
181185
end
182186

183187
context 'when base and custom scheduling are enabled, but one is scheduled after the poll interval' do
@@ -189,10 +193,13 @@
189193

190194
before(:each) do
191195
allow(cron_parser).to receive(:next_time).with(time_at_poll_start).and_return(next_trigger_time, weekly_next_trigger_time)
192-
expect(Utility::Logger).to receive(:debug).exactly(1).times.with(instance_of(String))
193196
end
194197

195-
it_behaves_like 'triggers', :weekly_key
198+
# functionally the same as shared test 'triggers', but with an extra expect() to check for a debug message
199+
it 'yields :sync task with an optional scheduling_key value' do
200+
expect(Utility::Logger).to receive(:debug).exactly(1).times.with(match(/^Sync for (\w+.*)|( - \w+) not triggered as .*/))
201+
expect { |b| subject.when_triggered(&b) }.to yield_with_args(connector_settings, :sync, :weekly_key)
202+
end
196203
end
197204

198205
context 'when base and custom scheduling are enabled and require sync and are scheduled at the start of the poll interval' do

0 commit comments

Comments
 (0)