diff --git a/spec/site/tlc/signal_plans_spec.rb b/spec/site/tlc/signal_plans_spec.rb index bd192c4c..0751049b 100644 --- a/spec/site/tlc/signal_plans_spec.rb +++ b/spec/site/tlc/signal_plans_spec.rb @@ -260,30 +260,8 @@ # 6. Then reading cycle time should confirm the reversion specify 'cycle time is set with M0018', sxl: '>=1.0.13' do |example| Validator::Site.connected do |task,supervisor,site| - extension = 5 - - # read current plan - plan = read_current_plan(site) - - # read initial cycle times - times = read_cycle_times(site) - time = times[plan] - - # change cycle tme - time_extended = time + extension - need_to_reset = true - set_cycle_time plan, time_extended, "Extend cycle time to #{time_extended} for plan #{plan}" - - # read updated cycle times - increase = 5 - times = read_cycle_times(site, "updated cycle times") - time_extended_actual = times[plan] - expect(time_extended_actual).to eq(time_extended) - - ensure - if need_to_reset - log "Reset cycle time" - set_cycle_time plan, time + with_cycle_time_extended(site) do + log "Cycle time extension confirmed" end end end diff --git a/spec/support/command_helpers.rb b/spec/support/command_helpers.rb index 86ac3f8a..ff7c9d31 100644 --- a/spec/support/command_helpers.rb +++ b/spec/support/command_helpers.rb @@ -262,6 +262,36 @@ def set_cycle_time plan, cycle_time, description="Set cycle time to #{cycle_time send_command_and_confirm @task, command_list, description end + def with_cycle_time_extended site, extension=5, &block + # read current plan + plan = read_current_plan(site) + + # read initial cycle times + times = read_cycle_times(site) + time = times[plan] + + expect(time).to_not be_nil, "Site returned empty cycle times list" + + # change cycle tme + time_extended = time + extension + need_to_reset = true + set_cycle_time plan, time_extended, "Extend cycle time to #{time_extended} for plan #{plan}" + + # read updated cycle times + increase = 5 + times = read_cycle_times(site, "updated cycle times") + time_extended_actual = times[plan] + expect(time_extended_actual).to eq(time_extended) + + block.yield + ensure + if need_to_reset + log "Reset cycle time" + set_cycle_time plan, time + end + end + + def force_input input:, status:'True', value: 'True', validate:true require_security_codes if status == 'True'