rsmp-validator 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/config/secrets_example.yaml +2 -2
  3. data/config/simulator/supervisor.yaml +1 -1
  4. data/config/simulator/tlc.yaml +2 -1
  5. data/config/{cross_rs4s.yaml → sites/cross_rs4s.yaml} +5 -5
  6. data/config/sites/cross_rs5.yaml +62 -0
  7. data/config/{lightmotion_satellite.yaml → sites/lightmotion_satellite.yaml} +1 -1
  8. data/config/{swarco_itc3.yaml → sites/swarco_itc3.yaml} +3 -4
  9. data/config/validator.rb +1 -0
  10. data/config/validator_example.yaml +2 -2
  11. data/lib/rsmp/validator/buffer_replay_queue.rb +37 -0
  12. data/lib/rsmp/validator/cli/config_cli.rb +34 -9
  13. data/lib/rsmp/validator/config_check.rb +21 -2
  14. data/lib/rsmp/validator/config_normalizer.rb +3 -2
  15. data/lib/rsmp/validator/configuration/loader.rb +7 -13
  16. data/lib/rsmp/validator/configuration/secrets.rb +7 -3
  17. data/lib/rsmp/validator/configuration/sxls_override.rb +19 -4
  18. data/lib/rsmp/validator/configuration/test_requirements.rb +63 -0
  19. data/lib/rsmp/validator/configuration/version_normalization.rb +10 -5
  20. data/lib/rsmp/validator/configuration.rb +2 -9
  21. data/lib/rsmp/validator/helpers/alarms.rb +3 -3
  22. data/lib/rsmp/validator/helpers/connection.rb +14 -14
  23. data/lib/rsmp/validator/helpers/expectations.rb +35 -0
  24. data/lib/rsmp/validator/helpers/input.rb +3 -3
  25. data/lib/rsmp/validator/helpers/signal_plans.rb +11 -16
  26. data/lib/rsmp/validator/helpers/signal_priority.rb +23 -22
  27. data/lib/rsmp/validator/lifecycle.rb +2 -0
  28. data/lib/rsmp/validator/missing_configuration.rb +10 -0
  29. data/lib/rsmp/validator/options/site_test_options.rb +1 -1
  30. data/lib/rsmp/validator/options/supervisor_test_options.rb +1 -1
  31. data/lib/rsmp/validator/site_tester.rb +4 -19
  32. data/lib/rsmp/validator/version.rb +1 -1
  33. data/lib/rsmp/validator.rb +1 -0
  34. data/schemas/site_test.json +0 -4
  35. data/schemas/supervisor_test.json +0 -2
  36. data/schemas/test_config/common.json +21 -0
  37. data/schemas/test_config/core/3.1.4.json +14 -0
  38. data/schemas/test_config/core/3.1.5.json +14 -0
  39. data/schemas/test_config/core.json +33 -0
  40. data/schemas/test_config/tlc/1.0.15.json +13 -0
  41. data/schemas/test_config/tlc/1.0.7.json +67 -0
  42. data/schemas/test_config/tlc/1.0.8.json +13 -0
  43. data/schemas/test_config/tlc/1.1.0.json +13 -0
  44. data/schemas/test_config/versions.json +28 -0
  45. data/test/site/core/aggregated_status_spec.rb +28 -6
  46. data/test/site/core/message_buffer_spec.rb +90 -75
  47. data/test/site/tlc/alarm_spec.rb +9 -5
  48. data/test/site/tlc/clock_spec.rb +9 -9
  49. data/test/site/tlc/detector_logics_spec.rb +11 -9
  50. data/test/site/tlc/emergency_routes_spec.rb +4 -4
  51. data/test/site/tlc/invalid_command_spec.rb +9 -8
  52. data/test/site/tlc/invalid_status_spec.rb +8 -7
  53. data/test/site/tlc/modes_spec.rb +21 -21
  54. data/test/site/tlc/signal_groups_spec.rb +10 -10
  55. data/test/site/tlc/signal_plans_spec.rb +21 -21
  56. data/test/site/tlc/signal_priority_spec.rb +5 -5
  57. data/test/site/tlc/subscribe_spec.rb +5 -3
  58. data/test/site/tlc/system_spec.rb +11 -11
  59. data/test/site/tlc/traffic_data_spec.rb +12 -10
  60. data/test/site/tlc/traffic_situations_spec.rb +3 -3
  61. data/test/supervisor/aggregated_status_spec.rb +4 -0
  62. metadata +25 -11
  63. /data/config/{gem_tlc.yaml → sites/gem_tlc.yaml} +0 -0
  64. /data/config/{gem_tlc_secrets.yaml → sites/gem_tlc_secrets.yaml} +0 -0
  65. /data/config/{kapsch_etx.yaml → sites/kapsch_etx.yaml} +0 -0
  66. /data/config/{semaforica_cartesio.yaml → sites/semaforica_cartesio.yaml} +0 -0
  67. /data/config/{gem_supervisor.yaml → supervisors/gem_supervisor.yaml} +0 -0
  68. /data/config/{tecsen_tmacs_supervisor.yaml → supervisors/tecsen_tmacs_supervisor.yaml} +0 -0
@@ -1,81 +1,104 @@
1
+ require_relative '../../../lib/rsmp/validator/buffer_replay_queue'
2
+
1
3
  describe 'Site::Core' do
2
4
  describe 'Message Buffer' do
3
- def buffered_status_list(site_proxy)
4
- status_list = [{ 'sCI' => 'S0001', 'n' => 'signalgroupstatus', 'uRt' => '1' }]
5
- status_list.map! { |item| item.merge('sOc' => true) } if site_proxy.tlc.use_soc?
6
- status_list
5
+ let(:update_rate) { 1 }
6
+ let(:outage_duration) { 2 * update_rate }
7
+ let(:boundary_margin) { 0.25 * update_rate }
8
+ let(:status_list) { [{ 'sCI' => 'S0001', 'n' => 'signalgroupstatus' }] }
9
+ let(:component) { RSMP::Validator.get_config('main_component') }
10
+ let(:collect_timeout) { RSMP::Validator.get_config('timeouts', 'status_update') }
11
+
12
+ def subscribe_list(site_proxy)
13
+ # Confirm that live updates are arriving before disconnecting.
14
+ subscribe_list = status_list.map { |item| item.merge('uRt' => update_rate.to_s, 'q' => 'recent') }
15
+ return subscribe_list unless site_proxy.tlc.use_soc?
16
+
17
+ subscribe_list.map { |item| item.merge('sOc' => false) }
18
+ end
19
+
20
+ def monotonic_now
21
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
7
22
  end
8
23
 
9
- def buffered_status_timeout
10
- RSMP::Validator.get_config('timeouts', 'ready') +
11
- RSMP::Validator.get_config('timeouts', 'status_update') + 1
24
+ def subscribe_to_status(site_proxy)
25
+ site_proxy.subscribe_to_status_and_collect(
26
+ subscribe_list(site_proxy), component: component, within: collect_timeout
27
+ ).value!
12
28
  end
13
29
 
14
- def subscribe_buffered_status(component)
15
- with_site(:connected, core: '>=3.1.4') do |site_proxy|
16
- status_list = buffered_status_list(site_proxy)
17
- site_proxy.subscribe_to_status_and_collect(
18
- status_list,
19
- component: component,
20
- within: RSMP::Validator.get_config('timeouts', 'status_update')
21
- ).value!
22
- status_list
30
+ def simulate_outage
31
+ closed_at = monotonic_now
32
+ sleep outage_duration
33
+ closed_at...monotonic_now
34
+ end
35
+
36
+ def queue_factory
37
+ proc { |proxy| RSMP::Validator::BufferReplayQueue.new(proxy, component: component) }
38
+ end
39
+
40
+ def matching_statuses(message)
41
+ message.attribute('sS').select do |status|
42
+ status_list.any? { |wanted| wanted == status.slice('sCI', 'n') }
23
43
  end
24
44
  end
25
45
 
26
- def simulate_status_buffer_disruption
27
- RSMP::Validator::SiteTester.instance.stop 'Simulating communication disruption'
28
- Async::Task.current.sleep 1.5
29
- Time.now.utc
46
+ def matching_status_update?(message)
47
+ message.is_a?(RSMP::StatusUpdate) && !matching_statuses(message).empty?
30
48
  end
31
49
 
32
- def collect_status_after_reconnect(component, status_list)
33
- with_site(:connected,
34
- core: '>=3.1.4',
35
- 'collect' => {
36
- filter: RSMP::Filter.new(type: 'StatusUpdate',
37
- component: component,
38
- ingoing: true,
39
- outgoing: false),
40
- timeout: buffered_status_timeout,
41
- num: 1,
42
- ingoing: true
43
- }) do |site_proxy|
44
- collector = site_proxy.collector
45
- messages = collector.wait!
46
- update = messages.first
47
-
48
- unsubscribe_list = status_list.map { |item| item.slice('sCI', 'n') }
49
- site_proxy.unsubscribe_to_status! unsubscribe_list, component: component
50
- update
50
+ def wait_for_buffered_update(queue, outage_window)
51
+ timestamps = []
52
+ Async::Task.current.with_timeout(collect_timeout) do
53
+ loop do
54
+ update = queue.wait_for_message!
55
+ next unless matching_status_update?(update)
56
+
57
+ timestamp = Time.parse(update.attribute('sTs'))
58
+ timestamps << timestamp
59
+ return [update, timestamps] if timestamp > outage_window.begin && timestamp < outage_window.end
60
+ end
51
61
  end
62
+ rescue RSMP::OperationError => e
63
+ raise unless e.failure.code == :timeout
64
+
65
+ [nil, timestamps]
52
66
  end
53
67
 
54
- def collect_buffered_status_after_disruption
55
- collect_buffered_status_after_disruption_with_timing[:update]
68
+ def format_outage_window(window)
69
+ first, last = [window.begin, window.end].map(&:getutc)
70
+ same_date = first.strftime('%Y-%m-%d') == last.strftime('%Y-%m-%d')
71
+ end_format = same_date ? '%H:%M:%S.%L' : '%Y-%m-%d %H:%M:%S.%L'
72
+ "#{first.strftime('%Y-%m-%d %H:%M:%S.%L')}..#{last.strftime(end_format)} UTC"
56
73
  end
57
74
 
58
- def collect_buffered_status_after_disruption_with_timing
59
- component = RSMP::Validator.get_config('main_component')
60
- status_list = subscribe_buffered_status component
61
- reconnect_started_at = simulate_status_buffer_disruption
62
- update = collect_status_after_reconnect component, status_list
63
- { update: update, reconnect_started_at: reconnect_started_at }
75
+ def assert_message(buffered_message, outage_window)
76
+ expectation = 'Received StatusUpdate timestamped within window'
77
+ return expectation if buffered_message
78
+
79
+ window_string = format_outage_window(outage_window)
80
+ "#{expectation} #{window_string}"
64
81
  end
65
82
 
66
- # Verify that a site sends buffered status messages after communication is restored.
83
+ # Verify that historical status data arrives after communication is restored.
67
84
  #
68
85
  # 1. Given the site is connected and a status subscription is active
69
86
  # 2. When communication is disrupted long enough for a status update to be due
70
87
  # 3. And communication is restored
71
- # 4. Then the site should send the buffered status update
72
- it 'sends buffered status messages after communication is restored' do
88
+ # 4. Then an update timestamped within the outage should arrive, even if fresh updates arrive first
89
+ it 'sends status updates timestamped during the communication outage' do
73
90
  skip 'requires core >= 3.1.4' unless RSMP::Validator.core_matches?('>=3.1.4')
74
91
 
75
- update = collect_buffered_status_after_disruption
76
-
77
- expect(update).to be_a(RSMP::StatusUpdate)
78
- assert(!update.attributes['sS'].empty?, 'expected buffered status update to include status values')
92
+ with_site(:connected) { |site_proxy| subscribe_to_status(site_proxy) }
93
+ offline = with_site(:disconnected) { simulate_outage }
94
+ with_site(:connected, 'collect' => queue_factory) do |site_proxy|
95
+ outage_window = site_proxy.collector.site_time_window(offline, boundary_margin)
96
+ buffered_message, = wait_for_buffered_update(site_proxy.collector, outage_window)
97
+ assert(buffered_message, assert_message(buffered_message, outage_window))
98
+ ensure
99
+ site_proxy.collector.stop
100
+ site_proxy.unsubscribe_to_status! status_list, component: component
101
+ end
79
102
  end
80
103
 
81
104
  # Verify that buffered status messages use quality "old" for core versions
@@ -88,27 +111,19 @@ describe 'Site::Core' do
88
111
  it 'marks buffered status values as old for rsmp 3.2.0 and later' do
89
112
  skip 'requires core >= 3.2.0' unless RSMP::Validator.core_matches?('>=3.2.0')
90
113
 
91
- update = collect_buffered_status_after_disruption
92
-
93
- expect(update.attributes['sS'].map { |status| status['q'] }.uniq).to be == ['old']
94
- end
95
-
96
- # Verify that buffered status timestamps reflect when the status data was
97
- # generated, not when the buffered message was sent after reconnect.
98
- #
99
- # 1. Given the site is connected and a status subscription is active
100
- # 2. When communication is disrupted long enough for a status update to be due
101
- # 3. And communication is restored
102
- # 4. Then the buffered status timestamp should be older than the reconnect
103
- it 'preserves buffered status timestamps from before reconnect' do
104
- skip 'requires core >= 3.1.4' unless RSMP::Validator.core_matches?('>=3.1.4')
105
-
106
- result = collect_buffered_status_after_disruption_with_timing
107
- status_time = Time.parse(result[:update].attributes['sTs'])
108
-
109
- assert(status_time < result[:reconnect_started_at],
110
- "expected buffered status timestamp #{status_time} to be before reconnect " \
111
- "#{result[:reconnect_started_at]}")
114
+ with_site(:connected) { |site_proxy| subscribe_to_status(site_proxy) }
115
+ offline = with_site(:disconnected) { simulate_outage }
116
+ with_site(:connected, 'collect' => queue_factory) do |site_proxy|
117
+ outage_window = site_proxy.collector.site_time_window(offline, boundary_margin)
118
+ buffered_update, = wait_for_buffered_update(site_proxy.collector, outage_window)
119
+ assert(buffered_update, assert_message(buffered_update, outage_window))
120
+ next unless buffered_update # skip the rest if no message was received
121
+
122
+ assert(buffered_update.attribute('sS').all? { |status| status['q'] == 'old' }, 'Each status values have q=old')
123
+ ensure
124
+ site_proxy.collector.stop
125
+ site_proxy.unsubscribe_to_status! status_list, component: component
126
+ end
112
127
  end
113
128
  end
114
129
  end
@@ -68,7 +68,10 @@ describe 'Site::Tlc::Alarm' do
68
68
 
69
69
  # verify that the alarm is not acknowledged when initially raised
70
70
  ack_message = "Alarm should not be acknowledged when raised, got: #{alarm.attributes['ack']}"
71
- assert(alarm.attributes['ack'].match?(/notAcknowledged/i), ack_message)
71
+ unacknowledged = alarm.attributes['ack'].match?(/\AnotAcknowledged\z/i)
72
+ assert(unacknowledged, ack_message)
73
+ next unless unacknowledged
74
+
72
75
  log "Verified alarm #{alarm_code_id} is correctly not acknowledged when raised"
73
76
 
74
77
  # test acknowledge and confirm
@@ -79,9 +82,9 @@ describe 'Site::Tlc::Alarm' do
79
82
  num: 1,
80
83
  matcher: {
81
84
  'aCId' => alarm_code_id,
82
- 'aSp' => /Acknowledge/i,
83
- 'ack' => /Acknowledged/i,
84
- 'aS' => /Active/i
85
+ 'aSp' => /\AAcknowledge\z/i,
86
+ 'ack' => /\AAcknowledged\z/i,
87
+ 'aS' => /\AActive\z/i
85
88
  },
86
89
  timeout: timeout).collect!
87
90
  end
@@ -92,7 +95,8 @@ describe 'Site::Tlc::Alarm' do
92
95
  'aCId' => alarm_code_id
93
96
  )
94
97
  messages = collect_task.wait
95
- expect(messages).to be_a(Array)
98
+ expect_or_stop(messages).to be_a(Array)
99
+
96
100
  expect(messages.first).to be_a(RSMP::Alarm)
97
101
  end
98
102
  end
@@ -13,7 +13,7 @@ describe 'Site::Tlc::Clock' do
13
13
 
14
14
  # Verify status 0096 current date and time
15
15
  #
16
- # 1. Given the site_proxy is connected
16
+ # 1. Given the site is connected
17
17
  # 2. Request status
18
18
  # 3. Expect status response before timeout
19
19
  it 'can be read with S0096' do
@@ -25,7 +25,7 @@ describe 'Site::Tlc::Clock' do
25
25
 
26
26
  # Verify that the controller responds to M0104
27
27
  #
28
- # 1. Given the site_proxy is connected
28
+ # 1. Given the site is connected
29
29
  # 2. Send command
30
30
  # 3. Expect status response before timeout
31
31
  it 'can be set with M0104' do
@@ -37,7 +37,7 @@ describe 'Site::Tlc::Clock' do
37
37
 
38
38
  # Verify status S0096 clock after changing clock
39
39
  #
40
- # 1. Given the site_proxy is connected
40
+ # 1. Given the site is connected
41
41
  # 2. Send control command to set_clock
42
42
  # 3. Request status S0096
43
43
  # 4. Compare set_clock and status timestamp
@@ -86,7 +86,7 @@ describe 'Site::Tlc::Clock' do
86
86
 
87
87
  # Verify status response timestamp after changing clock
88
88
  #
89
- # 1. Given the site_proxy is connected
89
+ # 1. Given the site is connected
90
90
  # 2. Send control command to set_clock
91
91
  # 3. Request status S0096
92
92
  # 4. Compare set_clock and response timestamp
@@ -120,7 +120,7 @@ describe 'Site::Tlc::Clock' do
120
120
 
121
121
  # Verify aggregated status response timestamp after changing clock
122
122
  #
123
- # 1. Given the site_proxy is connected
123
+ # 1. Given the site is connected
124
124
  # 2. Send control command to set clock
125
125
  # 3. Wait for status = true
126
126
  # 4. Request aggregated status
@@ -146,7 +146,7 @@ describe 'Site::Tlc::Clock' do
146
146
 
147
147
  # Verify command response timestamp after changing clock
148
148
  #
149
- # 1. Given the site_proxy is connected
149
+ # 1. Given the site is connected
150
150
  # 2. Send control command to set clock
151
151
  # 3. Send command to set functional position
152
152
  # 4. Compare set_clock and response timestamp
@@ -169,7 +169,7 @@ describe 'Site::Tlc::Clock' do
169
169
 
170
170
  # Verify command response timestamp after changing clock
171
171
  #
172
- # 1. Given the site_proxy is connected
172
+ # 1. Given the site is connected
173
173
  # 2. Send control command to set clock
174
174
  # 3. Send command to set functional position
175
175
  # 4. Compare set_clock and response timestamp
@@ -195,7 +195,7 @@ describe 'Site::Tlc::Clock' do
195
195
  # a A0302 alarm can be raise by activating a specific input, as
196
196
  # configuted in the test config.
197
197
  #
198
- # 1. Given the site_proxy is connected
198
+ # 1. Given the site is connected
199
199
  # 2. When we send a command to change the clock
200
200
  # 3. And we raise an alarm, by acticate an input
201
201
  # 4. Then we should receive an alarm
@@ -221,7 +221,7 @@ describe 'Site::Tlc::Clock' do
221
221
 
222
222
  # Verify timestamp of watchdog after changing clock
223
223
  #
224
- # 1. Given the site_proxy is connected
224
+ # 1. Given the site is connected
225
225
  # 2. Send control command to setset_clock
226
226
  # 3. Wait for Watchdog
227
227
  # 4. Compare set_clock and alarm response timestamp
@@ -4,7 +4,7 @@ describe 'Site::Tlc::DetectorLogics' do
4
4
 
5
5
  # Verify status S0016 number of detector logics
6
6
  #
7
- # 1. Given the site_proxy is connected
7
+ # 1. Given the site is connected
8
8
  # 2. Request status
9
9
  # 3. Expect status response before timeout
10
10
  it 'list size is read with S0016' do
@@ -16,7 +16,7 @@ describe 'Site::Tlc::DetectorLogics' do
16
16
 
17
17
  # Verify status S0002 detector logic status
18
18
  #
19
- # 1. Given the site_proxy is connected
19
+ # 1. Given the site is connected
20
20
  # 2. Request status
21
21
  # 3. Expect status response before timeout
22
22
  it 'status is read with S0002' do
@@ -28,7 +28,7 @@ describe 'Site::Tlc::DetectorLogics' do
28
28
 
29
29
  # Verify status S0021 manually set detector logic
30
30
  #
31
- # 1. Given the site_proxy is connected
31
+ # 1. Given the site is connected
32
32
  # 2. Request status
33
33
  # 3. Expect status response before timeout
34
34
  it 'forcing is read with S0021' do
@@ -38,9 +38,11 @@ describe 'Site::Tlc::DetectorLogics' do
38
38
  end
39
39
  end
40
40
 
41
- # 1. Verify connection
42
- # 2. Send control command to switch detector_logic= true
43
- # 3. Wait for status = true
41
+ # 1. Given the site is connected
42
+ # 2. When we force each detector logic on with M0008
43
+ # 3. Then S0002 should show the detector logic is on
44
+ # 4. When we force the detector logic off with M0008
45
+ # 5. Then S0002 should show the detector logic is off
44
46
  it 'forcing is set with M0008' do
45
47
  with_site(:connected, sxl: '>=1.0.7') do |site_proxy|
46
48
  RSMP::Validator.get_config('components', 'detector_logic').keys.each_with_index do |component, indx|
@@ -49,14 +51,14 @@ describe 'Site::Tlc::DetectorLogics' do
49
51
  wait_for_status(
50
52
  site_proxy,
51
53
  "detector logic #{component} to be True",
52
- [{ 'sCI' => 'S0002', 'n' => 'detectorlogicstatus', 's' => /^.{#{indx}}1/ }]
54
+ [{ 'sCI' => 'S0002', 'n' => 'detectorlogicstatus', 's' => /\A.{#{indx}}1/ }]
53
55
  )
54
56
 
55
57
  site_proxy.tlc.force_detector_logic!(component, status: 'True', mode: 'False', within: timeout)
56
58
  wait_for_status(
57
59
  site_proxy,
58
60
  "detector logic #{component} to be False",
59
- [{ 'sCI' => 'S0002', 'n' => 'detectorlogicstatus', 's' => /^.{#{indx}}0/ }]
61
+ [{ 'sCI' => 'S0002', 'n' => 'detectorlogicstatus', 's' => /\A.{#{indx}}0/ }]
60
62
  )
61
63
  end
62
64
  end
@@ -64,7 +66,7 @@ describe 'Site::Tlc::DetectorLogics' do
64
66
 
65
67
  # Verify status S0031 trigger level sensitivity for loop detector
66
68
  #
67
- # 1. Given the site_proxy is connected
69
+ # 1. Given the site is connected
68
70
  # 2. Request status
69
71
  # 3. Expect status response before timeout
70
72
  it 'sensitivity is read with S0031' do
@@ -3,7 +3,7 @@ describe 'Site::Tlc::EmergencyRoutes' do
3
3
 
4
4
  # Verify that current emergency route can be read with S0006.
5
5
  # Deprecated from 1.2.0, use S0035 instead.
6
- # 1. Given the site_proxy is connected.
6
+ # 1. Given the site is connected.
7
7
  # 2. When we request S0006.
8
8
  # 3. Then we should receive a status response.
9
9
  it 'emergency route is read with S0006' do
@@ -15,7 +15,7 @@ describe 'Site::Tlc::EmergencyRoutes' do
15
15
 
16
16
  # Verify that current emergency routes can be read with S0035.
17
17
  # Requires core >= 3.2.0 since it uses the array data type.
18
- # 1. Given the site_proxy is connected.
18
+ # 1. Given the site is connected.
19
19
  # 2. When we request S0035.
20
20
  # 3. Then we should receive a status response.
21
21
  it 'emergency route is read with S0035' do
@@ -28,7 +28,7 @@ describe 'Site::Tlc::EmergencyRoutes' do
28
28
 
29
29
  # Verify that emergency routes can be activated with M0005.
30
30
  # S0006 should reflect the last route enabled/disabled.
31
- # 1. Given the site_proxy is connected.
31
+ # 1. Given the site is connected.
32
32
  # 2. When we send M0005 to set emergency route.
33
33
  # 3. Then we should get a command responds confirming the change.
34
34
  it 'can be activated with M0005 and read with S0006' do
@@ -61,7 +61,7 @@ describe 'Site::Tlc::EmergencyRoutes' do
61
61
 
62
62
  # Verify that emergency routes can be activated with M0005.
63
63
  # S0035 should show all active routes.
64
- # 1. Given the site_proxy is connected.
64
+ # 1. Given the site is connected.
65
65
  # 2. When we send M0005 to set emergency route.
66
66
  # 3. Then we should get a command responds confirming the change.
67
67
  # 4. When we request the current emergency routes with S035.
@@ -1,7 +1,6 @@
1
1
  describe 'Site::Tlc::InvalidCommand' do
2
2
  def expect_message_rejected(result)
3
- expect(result).to be_a(RSMP::Result::Failure)
4
- return unless result.failure?
3
+ expect_or_stop(result).to be_a(RSMP::Result::Failure)
5
4
 
6
5
  expect(result.failure.code).to eq(:message_rejected)
7
6
  expect(result.failure.source).to eq(:peer)
@@ -10,7 +9,7 @@ describe 'Site::Tlc::InvalidCommand' do
10
9
  # Verify that site_proxy reponds with age=undefined when receiving
11
10
  # a command with an unknown component id
12
11
  #
13
- # 1. Given the site_proxy is connected
12
+ # 1. Given the site is connected
14
13
  # 2. When we send a command with an unknown component id
15
14
  # 3. Then the site_proxy should return a command response with age=undefined
16
15
 
@@ -30,9 +29,11 @@ describe 'Site::Tlc::InvalidCommand' do
30
29
  )
31
30
  exchange = result.value!
32
31
  response = exchange.messages.first
33
- expect(response).to be_a(RSMP::CommandResponse)
32
+ expect_or_stop(response).to be_a(RSMP::CommandResponse)
33
+
34
34
  rvs = response.attributes['rvs']
35
- expect(rvs).to be_a(Array)
35
+ expect_or_stop(rvs).to be_a(Array)
36
+
36
37
  rvs.each do |rv|
37
38
  age = rv['age']
38
39
  expect(age).to eq('undefined')
@@ -42,7 +43,7 @@ describe 'Site::Tlc::InvalidCommand' do
42
43
 
43
44
  # Verify that site_proxy returns NotAck when receiving an unknown command
44
45
  #
45
- # 1. Given the site_proxy is connected
46
+ # 1. Given the site is connected
46
47
  # 2. When we send a non-existing M0000 command
47
48
  # 3. Then the site_proxy should return NotAck
48
49
 
@@ -62,7 +63,7 @@ describe 'Site::Tlc::InvalidCommand' do
62
63
  # Verify that site_proxy returns NotAck when receiving a command
63
64
  # with a mising command attribute
64
65
  #
65
- # 1. Given the site_proxy is connected
66
+ # 1. Given the site is connected
66
67
  # 2. When we send an M0001 command with 'status' missing
67
68
  # 3. Then the site_proxy return NotAck
68
69
 
@@ -85,7 +86,7 @@ describe 'Site::Tlc::InvalidCommand' do
85
86
  # Verify that site_proxy returns NotAck when receiving a command
86
87
  # with an unknown command name
87
88
  #
88
- # 1. Given the site_proxy is connected
89
+ # 1. Given the site is connected
89
90
  # 2. When we send an M0001 command with 'bad' as command name
90
91
  # 3. Then the site_proxy should return NotAck
91
92
 
@@ -1,7 +1,6 @@
1
1
  describe 'Site::Tlc::InvalidStatus' do
2
2
  def expect_message_rejected(result)
3
- expect(result).to be_a(RSMP::Result::Failure)
4
- return unless result.failure?
3
+ expect_or_stop(result).to be_a(RSMP::Result::Failure)
5
4
 
6
5
  expect(result.failure.code).to eq(:message_rejected)
7
6
  expect(result.failure.source).to eq(:peer)
@@ -10,7 +9,7 @@ describe 'Site::Tlc::InvalidStatus' do
10
9
  # Verify that site_proxy reponds with q=undefined when receiving a
11
10
  # status request with an unknown component id.
12
11
  #
13
- # 1. Given the site_proxy is connected
12
+ # 1. Given the site is connected
14
13
  # 2. When we send a status request with an unknown component id
15
14
  # 3. Then the site_proxy should return a status response with q=undefined
16
15
 
@@ -25,9 +24,11 @@ describe 'Site::Tlc::InvalidStatus' do
25
24
  )
26
25
  exchange = result.value!
27
26
  response = exchange.messages.first
28
- expect(response).to be_a(RSMP::StatusResponse)
27
+ expect_or_stop(response).to be_a(RSMP::StatusResponse)
28
+
29
29
  ss = response.attributes['sS']
30
- expect(ss).to be_a(Array)
30
+ expect_or_stop(ss).to be_a(Array)
31
+
31
32
  ss.each do |s|
32
33
  q = s['q']
33
34
  expect(q).to eq('undefined')
@@ -38,7 +39,7 @@ describe 'Site::Tlc::InvalidStatus' do
38
39
  # Verify that site_proxy returns NotAck when receiving
39
40
  # a request for an unknown status
40
41
  #
41
- # 1. Given the site_proxy is connected
42
+ # 1. Given the site is connected
42
43
  # 2. When we send a non-existing S000 status request
43
44
  # 3. Then the site_proxy should return NotAck
44
45
  it 'returns NotAck when status code is unknown' do
@@ -57,7 +58,7 @@ describe 'Site::Tlc::InvalidStatus' do
57
58
  # Verify that site_proxy returns NotAck when receiving
58
59
  # a request for an unknown status
59
60
  #
60
- # 1. Given the site_proxy is connected
61
+ # 1. Given the site is connected
61
62
  # 2. When we send an S0001 request with the stauts name 'bad'
62
63
  # 3. Then the site_proxy should return NotAck
63
64
  it 'returns NotAck when status name is unknown' do