aruba 2.1.0 → 2.3.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 (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +90 -39
  3. data/CONTRIBUTING.md +0 -1
  4. data/LICENSE +19 -17
  5. data/README.md +5 -6
  6. data/exe/aruba +3 -2
  7. data/lib/aruba/api/bundler.rb +4 -2
  8. data/lib/aruba/api/commands.rb +10 -8
  9. data/lib/aruba/api/core.rb +34 -32
  10. data/lib/aruba/api/environment.rb +4 -2
  11. data/lib/aruba/api/filesystem.rb +17 -19
  12. data/lib/aruba/api/text.rb +5 -3
  13. data/lib/aruba/api.rb +13 -11
  14. data/lib/aruba/{platforms/aruba_logger.rb → aruba_logger.rb} +4 -2
  15. data/lib/aruba/aruba_path.rb +4 -2
  16. data/lib/aruba/basic_configuration/option.rb +2 -0
  17. data/lib/aruba/basic_configuration.rb +15 -13
  18. data/lib/aruba/cli.rb +10 -8
  19. data/lib/aruba/colorizer.rb +2 -0
  20. data/lib/aruba/command.rb +10 -6
  21. data/lib/aruba/{platforms/command_monitor.rb → command_monitor.rb} +7 -5
  22. data/lib/aruba/config/jruby.rb +11 -9
  23. data/lib/aruba/config_wrapper.rb +4 -2
  24. data/lib/aruba/configuration.rb +17 -15
  25. data/lib/aruba/console/help.rb +7 -5
  26. data/lib/aruba/console.rb +12 -11
  27. data/lib/aruba/contracts/absolute_path.rb +3 -1
  28. data/lib/aruba/contracts/enum.rb +3 -1
  29. data/lib/aruba/contracts/is_power_of_two.rb +4 -2
  30. data/lib/aruba/contracts/relative_path.rb +3 -1
  31. data/lib/aruba/cucumber/command.rb +108 -99
  32. data/lib/aruba/cucumber/environment.rb +9 -7
  33. data/lib/aruba/cucumber/file.rb +4 -2
  34. data/lib/aruba/cucumber/hooks.rb +31 -29
  35. data/lib/aruba/cucumber/parameter_types.rb +4 -1
  36. data/lib/aruba/cucumber/testing_frameworks.rb +20 -18
  37. data/lib/aruba/cucumber.rb +10 -8
  38. data/lib/aruba/errors.rb +2 -6
  39. data/lib/aruba/event_bus.rb +8 -47
  40. data/lib/aruba/events.rb +15 -7
  41. data/lib/aruba/file_size.rb +3 -1
  42. data/lib/aruba/generators/script_file.rb +4 -2
  43. data/lib/aruba/hooks.rb +2 -0
  44. data/lib/aruba/in_config_wrapper.rb +3 -1
  45. data/lib/aruba/initializer.rb +25 -42
  46. data/lib/aruba/matchers/base/message_indenter.rb +3 -1
  47. data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -4
  48. data/lib/aruba/matchers/command/have_exit_status.rb +2 -0
  49. data/lib/aruba/matchers/command/have_finished_in_time.rb +2 -0
  50. data/lib/aruba/matchers/command/have_output.rb +3 -1
  51. data/lib/aruba/matchers/command/have_output_on_stderr.rb +2 -0
  52. data/lib/aruba/matchers/command/have_output_on_stdout.rb +2 -0
  53. data/lib/aruba/matchers/command/have_output_size.rb +21 -5
  54. data/lib/aruba/matchers/command.rb +3 -1
  55. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +3 -1
  56. data/lib/aruba/matchers/directory/have_sub_directory.rb +4 -2
  57. data/lib/aruba/matchers/directory.rb +3 -1
  58. data/lib/aruba/matchers/environment.rb +3 -1
  59. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +7 -5
  60. data/lib/aruba/matchers/file/be_an_existing_executable.rb +3 -1
  61. data/lib/aruba/matchers/file/be_an_existing_file.rb +3 -1
  62. data/lib/aruba/matchers/file/have_file_content.rb +2 -0
  63. data/lib/aruba/matchers/file/have_file_size.rb +2 -0
  64. data/lib/aruba/matchers/file/have_same_file_content.rb +3 -1
  65. data/lib/aruba/matchers/file.rb +3 -1
  66. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -0
  67. data/lib/aruba/matchers/path/be_an_absolute_path.rb +2 -0
  68. data/lib/aruba/matchers/path/be_an_existing_path.rb +2 -0
  69. data/lib/aruba/matchers/path/have_permissions.rb +3 -1
  70. data/lib/aruba/matchers/path.rb +3 -1
  71. data/lib/aruba/matchers/string/include_output_string.rb +3 -1
  72. data/lib/aruba/matchers/string/match_output_string.rb +3 -1
  73. data/lib/aruba/matchers/string/output_string_eq.rb +3 -1
  74. data/lib/aruba/matchers/string.rb +3 -1
  75. data/lib/aruba/platform.rb +4 -2
  76. data/lib/aruba/platforms/announcer.rb +16 -14
  77. data/lib/aruba/platforms/aruba_file_creator.rb +2 -0
  78. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +3 -1
  79. data/lib/aruba/platforms/determine_disk_usage.rb +3 -1
  80. data/lib/aruba/platforms/determine_file_size.rb +2 -0
  81. data/lib/aruba/platforms/filesystem_status.rb +3 -1
  82. data/lib/aruba/platforms/local_environment.rb +9 -1
  83. data/lib/aruba/platforms/simple_table.rb +4 -2
  84. data/lib/aruba/platforms/unix_command_string.rb +4 -2
  85. data/lib/aruba/platforms/unix_environment_variables.rb +4 -2
  86. data/lib/aruba/platforms/unix_platform.rb +32 -26
  87. data/lib/aruba/platforms/unix_which.rb +3 -1
  88. data/lib/aruba/platforms/windows_command_string.rb +3 -18
  89. data/lib/aruba/platforms/windows_environment_variables.rb +3 -1
  90. data/lib/aruba/platforms/windows_platform.rb +12 -6
  91. data/lib/aruba/platforms/windows_which.rb +7 -5
  92. data/lib/aruba/processes/basic_process.rb +5 -3
  93. data/lib/aruba/processes/debug_process.rb +8 -6
  94. data/lib/aruba/processes/in_process.rb +11 -8
  95. data/lib/aruba/processes/spawn_process.rb +110 -37
  96. data/lib/aruba/rspec.rb +8 -6
  97. data/lib/aruba/runtime.rb +9 -7
  98. data/lib/aruba/setup.rb +8 -6
  99. data/lib/aruba/version.rb +3 -1
  100. data/lib/aruba.rb +3 -1
  101. metadata +24 -99
  102. data/lib/aruba/event_bus/name_resolver.rb +0 -158
@@ -1,64 +1,77 @@
1
- require "aruba/generators/script_file"
1
+ # frozen_string_literal: true
2
2
 
3
- When(/^I run `([^`]*)`$/) do |cmd|
3
+ require 'aruba/generators/script_file'
4
+
5
+ When 'I run {command}' do |cmd|
4
6
  cmd = sanitize_text(cmd)
5
7
  run_command_and_stop(cmd, fail_on_error: false)
6
8
  end
7
9
 
8
- ## I successfully run `echo -n "Hello"`
9
- ## I successfully run `sleep 29` for up to 30 seconds
10
- When(/^I successfully run `(.*?)`(?: for up to ([\d.]+) seconds)?$/) do |cmd, secs|
10
+ When 'I successfully run {command}' do |cmd|
11
+ cmd = sanitize_text(cmd)
12
+ run_command_and_stop(cmd, fail_on_error: true)
13
+ end
14
+
15
+ When 'I successfully run {command} for up to {float} seconds' do |cmd, secs|
11
16
  cmd = sanitize_text(cmd)
12
- run_command_and_stop(cmd, fail_on_error: true, exit_timeout: secs && secs.to_f)
17
+ run_command_and_stop(cmd, fail_on_error: true, exit_timeout: secs.to_f)
18
+ end
19
+
20
+ When 'I run the following commands:/script:' do |commands|
21
+ full_path = expand_path('bin/myscript')
22
+
23
+ Aruba.platform.mkdir(expand_path('bin'))
24
+ shell = Aruba.platform.default_shell
25
+
26
+ Aruba::ScriptFile.new(interpreter: shell, content: commands, path: full_path).call
27
+ run_command_and_stop(Shellwords.escape(full_path), fail_on_error: false)
13
28
  end
14
29
 
15
- When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) \
16
- do |shell, commands|
17
- full_path = expand_path("bin/myscript")
30
+ When 'I run the following commands/script with/in {command}:' do |shell, commands|
31
+ full_path = expand_path('bin/myscript')
18
32
 
19
- Aruba.platform.mkdir(expand_path("bin"))
20
- shell ||= Aruba.platform.default_shell
33
+ Aruba.platform.mkdir(expand_path('bin'))
21
34
 
22
35
  Aruba::ScriptFile.new(interpreter: shell, content: commands, path: full_path).call
23
36
  run_command_and_stop(Shellwords.escape(full_path), fail_on_error: false)
24
37
  end
25
38
 
26
- When(/^I run `([^`]*)` interactively$/) do |cmd|
39
+ When 'I run {command} interactively' do |cmd|
27
40
  run_command(sanitize_text(cmd))
28
41
  end
29
42
 
30
43
  # Merge interactive and background after refactoring with event queue
31
- When(/^I run `([^`]*)` in background$/) do |cmd|
44
+ When 'I run {command} in background' do |cmd|
32
45
  run_command(sanitize_text(cmd))
33
46
  end
34
47
 
35
- When "I type {string}" do |input|
48
+ When 'I type {string}' do |input|
36
49
  type(unescape_text(input))
37
50
  end
38
51
 
39
- When "I close the stdin stream" do
52
+ When 'I close the stdin stream' do
40
53
  close_input
41
54
  end
42
55
 
43
- When "I pipe in a/the file( named) {string}" do |file|
56
+ When 'I pipe in a/the file( named) {string}' do |file|
44
57
  pipe_in_file(file)
45
58
 
46
59
  close_input
47
60
  end
48
61
 
49
- When "I stop the command started last" do
62
+ When 'I stop the command started last' do
50
63
  last_command_started.stop
51
64
  end
52
65
 
53
- When "I stop the command {string}" do |command|
66
+ When 'I stop the command {string}' do |command|
54
67
  aruba.command_monitor.find(command).stop
55
68
  end
56
69
 
57
- When "I terminate the command started last" do
70
+ When 'I terminate the command started last' do
58
71
  last_command_started.terminate
59
72
  end
60
73
 
61
- When "I terminate the command {string}" do |command|
74
+ When 'I terminate the command {string}' do |command|
62
75
  aruba.command_monitor.find(command).terminate
63
76
  end
64
77
 
@@ -81,14 +94,14 @@ When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$
81
94
  sleep 0.1
82
95
  end
83
96
  end
84
- rescue ChildProcess::TimeoutError, Timeout::Error
97
+ rescue Timeout::Error
85
98
  last_command_started.terminate
86
99
  end
87
100
 
88
- When "I wait for output/stdout to contain:" do |expected|
101
+ When 'I wait for output/stdout to contain:' do |expected|
89
102
  Timeout.timeout(aruba.config.exit_timeout) do
90
103
  loop do
91
- output = last_command_started.public_send :stdout, wait_for_io: 0
104
+ output = last_command_started.stdout wait_for_io: 0
92
105
 
93
106
  output = sanitize_text(output)
94
107
  expected = sanitize_text(expected)
@@ -100,10 +113,10 @@ When "I wait for output/stdout to contain:" do |expected|
100
113
  end
101
114
  end
102
115
 
103
- When "I wait for output/stdout to contain {string}" do |expected|
116
+ When 'I wait for output/stdout to contain {string}' do |expected|
104
117
  Timeout.timeout(aruba.config.exit_timeout) do
105
118
  loop do
106
- output = last_command_started.public_send :stdout, wait_for_io: 0
119
+ output = last_command_started.stdout wait_for_io: 0
107
120
 
108
121
  output = sanitize_text(output)
109
122
  expected = sanitize_text(expected)
@@ -115,44 +128,44 @@ When "I wait for output/stdout to contain {string}" do |expected|
115
128
  end
116
129
  end
117
130
 
118
- Then "the output should be {int} bytes long" do |size|
119
- expect(last_command_started.output).to have_output_size size.to_i
131
+ Then 'the output should be {int} bytes long' do |size|
132
+ expect(last_command_started).to have_output_size size.to_i
120
133
  end
121
134
 
122
135
  ## the stderr should contain "hello"
123
- Then "(the ){channel} should contain {string}" do |channel, expected|
124
- combined_output = send("all_#{channel}")
136
+ Then '(the ){channel} should contain {string}' do |channel, expected|
137
+ combined_output = send(:"all_#{channel}")
125
138
 
126
139
  expect(combined_output).to include_output_string expected
127
140
  end
128
141
 
129
142
  ## the stderr should not contain "hello"
130
- Then "(the ){channel} should not contain {string}" do |channel, expected|
131
- combined_output = send("all_#{channel}")
143
+ Then '(the ){channel} should not contain {string}' do |channel, expected|
144
+ combined_output = send(:"all_#{channel}")
132
145
 
133
146
  expect(combined_output).not_to include_output_string expected
134
147
  end
135
148
 
136
149
  ## the stderr should contain exactly "hello"
137
- Then "(the ){channel} should contain exactly {string}" do |channel, expected|
138
- combined_output = send("all_#{channel}")
150
+ Then '(the ){channel} should contain exactly {string}' do |channel, expected|
151
+ combined_output = send(:"all_#{channel}")
139
152
 
140
153
  expect(combined_output).to output_string_eq expected
141
154
  end
142
155
 
143
156
  ## the stderr should not contain exactly "hello"
144
- Then "(the ){channel} should not contain exactly {string}" do |channel, expected|
145
- combined_output = send("all_#{channel}")
157
+ Then '(the ){channel} should not contain exactly {string}' do |channel, expected|
158
+ combined_output = send(:"all_#{channel}")
146
159
 
147
160
  expect(combined_output).not_to output_string_eq expected
148
161
  end
149
162
 
150
163
  ## the stderr from "echo -n 'Hello'" should contain "hello"
151
- Then "(the ){channel} from {string} should contain {string}" do |channel, cmd, expected|
164
+ Then '(the ){channel} from {string} should contain {string}' do |channel, cmd, expected|
152
165
  matcher = case channel
153
- when "output"; then :have_output
154
- when "stderr"; then :have_output_on_stderr
155
- when "stdout"; then :have_output_on_stdout
166
+ when 'output'; then :have_output
167
+ when 'stderr'; then :have_output_on_stderr
168
+ when 'stdout'; then :have_output_on_stdout
156
169
  end
157
170
 
158
171
  command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
@@ -163,12 +176,12 @@ Then "(the ){channel} from {string} should contain {string}" do |channel, cmd, e
163
176
  end
164
177
 
165
178
  ## the stderr from "echo -n 'Hello'" should contain exactly "hello"
166
- Then "(the ){channel} from {string} should contain exactly {string}" \
179
+ Then '(the ){channel} from {string} should contain exactly {string}' \
167
180
  do |channel, cmd, expected|
168
181
  matcher = case channel
169
- when "output"; then :have_output
170
- when "stderr"; then :have_output_on_stderr
171
- when "stdout"; then :have_output_on_stdout
182
+ when 'output'; then :have_output
183
+ when 'stderr'; then :have_output_on_stderr
184
+ when 'stdout'; then :have_output_on_stdout
172
185
  end
173
186
 
174
187
  command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
@@ -179,11 +192,11 @@ Then "(the ){channel} from {string} should contain exactly {string}" \
179
192
  end
180
193
 
181
194
  ## the stderr from "echo -n 'Hello'" should not contain "hello"
182
- Then "(the ){channel} from {string} should not contain {string}" do |channel, cmd, expected|
195
+ Then '(the ){channel} from {string} should not contain {string}' do |channel, cmd, expected|
183
196
  matcher = case channel
184
- when "output"; then :have_output
185
- when "stderr"; then :have_output_on_stderr
186
- when "stdout"; then :have_output_on_stdout
197
+ when 'output'; then :have_output
198
+ when 'stderr'; then :have_output_on_stderr
199
+ when 'stdout'; then :have_output_on_stdout
187
200
  end
188
201
 
189
202
  command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
@@ -194,12 +207,12 @@ Then "(the ){channel} from {string} should not contain {string}" do |channel, cm
194
207
  end
195
208
 
196
209
  ## the stderr from "echo -n 'Hello'" should not contain exactly "hello"
197
- Then "(the ){channel} from {string} should not contain exactly {string}" \
210
+ Then '(the ){channel} from {string} should not contain exactly {string}' \
198
211
  do |channel, cmd, expected|
199
212
  matcher = case channel
200
- when "output"; then :have_output
201
- when "stderr"; then :have_output_on_stderr
202
- when "stdout"; then :have_output_on_stdout
213
+ when 'output'; then :have_output
214
+ when 'stderr'; then :have_output_on_stderr
215
+ when 'stdout'; then :have_output_on_stdout
203
216
  end
204
217
 
205
218
  command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
@@ -210,39 +223,39 @@ Then "(the ){channel} from {string} should not contain exactly {string}" \
210
223
  end
211
224
 
212
225
  ## the stderr should contain:
213
- Then "(the ){channel} should contain:" do |channel, expected|
214
- combined_output = send("all_#{channel}")
226
+ Then '(the ){channel} should contain:' do |channel, expected|
227
+ combined_output = send(:"all_#{channel}")
215
228
 
216
229
  expect(combined_output).to include_output_string(expected)
217
230
  end
218
231
 
219
232
  ## the stderr should not contain:
220
- Then "(the ){channel} should not contain:" do |channel, expected|
221
- combined_output = send("all_#{channel}")
233
+ Then '(the ){channel} should not contain:' do |channel, expected|
234
+ combined_output = send(:"all_#{channel}")
222
235
 
223
236
  expect(combined_output).not_to include_output_string(expected)
224
237
  end
225
238
 
226
239
  ## the stderr should contain exactly:
227
- Then "(the ){channel} should contain exactly:" do |channel, expected|
228
- combined_output = send("all_#{channel}")
240
+ Then '(the ){channel} should contain exactly:' do |channel, expected|
241
+ combined_output = send(:"all_#{channel}")
229
242
 
230
243
  expect(combined_output).to output_string_eq(expected)
231
244
  end
232
245
 
233
246
  ## the stderr should not contain exactly:
234
- Then "(the ){channel} should not contain exactly:" do |channel, expected|
235
- combined_output = send("all_#{channel}")
247
+ Then '(the ){channel} should not contain exactly:' do |channel, expected|
248
+ combined_output = send(:"all_#{channel}")
236
249
 
237
250
  expect(combined_output).not_to output_string_eq(expected)
238
251
  end
239
252
 
240
253
  ## the stderr from "echo -n 'Hello'" should not contain:
241
- Then "(the ){channel} from {string} should not contain:" do |channel, cmd, expected|
254
+ Then '(the ){channel} from {string} should not contain:' do |channel, cmd, expected|
242
255
  matcher = case channel
243
- when "output"; then :have_output
244
- when "stderr"; then :have_output_on_stderr
245
- when "stdout"; then :have_output_on_stdout
256
+ when 'output'; then :have_output
257
+ when 'stderr'; then :have_output_on_stderr
258
+ when 'stdout'; then :have_output_on_stdout
246
259
  end
247
260
 
248
261
  command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
@@ -253,11 +266,11 @@ Then "(the ){channel} from {string} should not contain:" do |channel, cmd, expec
253
266
  end
254
267
 
255
268
  ## the stderr from "echo -n 'Hello'" should not contain exactly:
256
- Then "(the ){channel} from {string} should not contain exactly:" do |channel, cmd, expected|
269
+ Then '(the ){channel} from {string} should not contain exactly:' do |channel, cmd, expected|
257
270
  matcher = case channel
258
- when "output"; then :have_output
259
- when "stderr"; then :have_output_on_stderr
260
- when "stdout"; then :have_output_on_stdout
271
+ when 'output'; then :have_output
272
+ when 'stderr'; then :have_output_on_stderr
273
+ when 'stdout'; then :have_output_on_stdout
261
274
  end
262
275
 
263
276
  command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
@@ -268,11 +281,11 @@ Then "(the ){channel} from {string} should not contain exactly:" do |channel, cm
268
281
  end
269
282
 
270
283
  ## the stderr from "echo -n 'Hello'" should contain:
271
- Then "(the ){channel} from {string} should contain:" do |channel, cmd, expected|
284
+ Then '(the ){channel} from {string} should contain:' do |channel, cmd, expected|
272
285
  matcher = case channel
273
- when "output"; then :have_output
274
- when "stderr"; then :have_output_on_stderr
275
- when "stdout"; then :have_output_on_stdout
286
+ when 'output'; then :have_output
287
+ when 'stderr'; then :have_output_on_stderr
288
+ when 'stdout'; then :have_output_on_stdout
276
289
  end
277
290
 
278
291
  command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
@@ -283,11 +296,11 @@ Then "(the ){channel} from {string} should contain:" do |channel, cmd, expected|
283
296
  end
284
297
 
285
298
  ## the stderr from "echo -n 'Hello'" should contain exactly:
286
- Then "(the ){channel} from {string} should contain exactly:" do |channel, cmd, expected|
299
+ Then '(the ){channel} from {string} should contain exactly:' do |channel, cmd, expected|
287
300
  matcher = case channel
288
- when "output"; then :have_output
289
- when "stderr"; then :have_output_on_stderr
290
- when "stdout"; then :have_output_on_stdout
301
+ when 'output'; then :have_output
302
+ when 'stderr'; then :have_output_on_stderr
303
+ when 'stdout'; then :have_output_on_stdout
291
304
  end
292
305
 
293
306
  command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
@@ -344,7 +357,7 @@ end
344
357
  Then(/^it should not (pass|fail) with "(.*?)"$/) do |pass_fail, expected|
345
358
  last_command_started.stop
346
359
 
347
- if pass_fail == "pass"
360
+ if pass_fail == 'pass'
348
361
  expect(last_command_stopped).to be_successfully_executed
349
362
  else
350
363
  expect(last_command_stopped).not_to be_successfully_executed
@@ -356,7 +369,7 @@ end
356
369
  Then(/^it should (pass|fail) with "(.*?)"$/) do |pass_fail, expected|
357
370
  last_command_started.stop
358
371
 
359
- if pass_fail == "pass"
372
+ if pass_fail == 'pass'
360
373
  expect(last_command_stopped).to be_successfully_executed
361
374
  else
362
375
  expect(last_command_stopped).not_to be_successfully_executed
@@ -368,7 +381,7 @@ end
368
381
  Then(/^it should not (pass|fail) with:$/) do |pass_fail, expected|
369
382
  last_command_started.stop
370
383
 
371
- if pass_fail == "pass"
384
+ if pass_fail == 'pass'
372
385
  expect(last_command_stopped).to be_successfully_executed
373
386
  else
374
387
  expect(last_command_stopped).not_to be_successfully_executed
@@ -380,7 +393,7 @@ end
380
393
  Then(/^it should (pass|fail) with:$/) do |pass_fail, expected|
381
394
  last_command_started.stop
382
395
 
383
- if pass_fail == "pass"
396
+ if pass_fail == 'pass'
384
397
  expect(last_command_stopped).to be_successfully_executed
385
398
  else
386
399
  expect(last_command_stopped).not_to be_successfully_executed
@@ -392,7 +405,7 @@ end
392
405
  Then(/^it should not (pass|fail) with exactly:$/) do |pass_fail, expected|
393
406
  last_command_started.stop
394
407
 
395
- if pass_fail == "pass"
408
+ if pass_fail == 'pass'
396
409
  expect(last_command_stopped).to be_successfully_executed
397
410
  else
398
411
  expect(last_command_stopped).not_to be_successfully_executed
@@ -404,19 +417,19 @@ end
404
417
  Then(/^it should (pass|fail) with exactly:$/) do |pass_fail, expected|
405
418
  last_command_started.stop
406
419
 
407
- if pass_fail == "pass"
420
+ if pass_fail == 'pass'
408
421
  expect(last_command_stopped).to be_successfully_executed
409
422
  else
410
423
  expect(last_command_stopped).not_to be_successfully_executed
411
424
  end
412
425
 
413
- expect(last_command_stopped).to have_output an_output_string_being_eq(expected)
426
+ expect(last_command_stopped.output).to output_string_eq(expected)
414
427
  end
415
428
 
416
429
  Then(/^it should not (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected|
417
430
  last_command_started.stop
418
431
 
419
- if pass_fail == "pass"
432
+ if pass_fail == 'pass'
420
433
  expect(last_command_stopped).to be_successfully_executed
421
434
  else
422
435
  expect(last_command_stopped).not_to be_successfully_executed
@@ -428,7 +441,7 @@ end
428
441
  Then(/^it should (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected|
429
442
  last_command_started.stop
430
443
 
431
- if pass_fail == "pass"
444
+ if pass_fail == 'pass'
432
445
  expect(last_command_stopped).to be_successfully_executed
433
446
  else
434
447
  expect(last_command_stopped).not_to be_successfully_executed
@@ -437,23 +450,19 @@ Then(/^it should (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expect
437
450
  expect(last_command_stopped).to have_output an_output_string_matching(expected)
438
451
  end
439
452
 
440
- Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channel|
441
- matcher = case channel
442
- when "output"; then :have_output
443
- when "stderr"; then :have_output_on_stderr
444
- when "stdout"; then :have_output_on_stdout
445
- end
453
+ Then '(the ){channel} should not contain anything' do |channel|
454
+ combined_output = send(:"all_#{channel}")
446
455
 
447
- expect(all_commands).to include send(matcher, be_nil.or(be_empty))
456
+ expect(combined_output).to output_string_eq ''
448
457
  end
449
458
 
450
459
  Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) \
451
460
  do |channel, negated, table|
452
461
  table.raw.flatten.each do |expected|
453
462
  _matcher = case channel
454
- when "output"; then :have_output
455
- when "stderr"; then :have_output_on_stderr
456
- when "stdout"; then :have_output_on_stdout
463
+ when 'output'; then :have_output
464
+ when 'stderr'; then :have_output_on_stderr
465
+ when 'stdout'; then :have_output_on_stdout
457
466
  end
458
467
 
459
468
  # TODO: This isn't actually using the above. It's hardcoded to use have_output only
@@ -476,7 +485,7 @@ Given(/^the (?:default )?aruba exit timeout is ([\d.]+) seconds?$/) do |seconds|
476
485
  aruba.config.exit_timeout = seconds.to_f
477
486
  end
478
487
 
479
- Given "the( default) aruba stop signal is {string}" do |signal|
488
+ Given 'the( default) aruba stop signal is {string}' do |signal|
480
489
  aruba.config.stop_signal = signal
481
490
  end
482
491
 
@@ -484,17 +493,17 @@ Given(/^I wait ([\d.]+) seconds? for (?:a|the) command to start up$/) do |second
484
493
  aruba.config.startup_wait_time = seconds.to_f
485
494
  end
486
495
 
487
- When "I send the signal {string} to the command {string}" do |signal, command|
496
+ When 'I send the signal {string} to the command {string}' do |signal, command|
488
497
  cmd = all_commands.find { |c| c.commandline == command }
489
498
  raise ArgumentError, %(No command "#{command}" found) if cmd.nil?
490
499
 
491
500
  cmd.send_signal signal
492
501
  end
493
502
 
494
- When "I send the signal {string} to the command started last" do |signal|
503
+ When 'I send the signal {string} to the command started last' do |signal|
495
504
  last_command_started.send_signal signal
496
505
  end
497
506
 
498
- Given "I look for executables in {string} within the current directory" do |directory|
499
- prepend_environment_variable "PATH", expand_path(directory) + File::PATH_SEPARATOR
507
+ Given 'I look for executables in {string} within the current directory' do |directory|
508
+ prepend_environment_variable 'PATH', expand_path(directory) + File::PATH_SEPARATOR
500
509
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Given(/^a mocked home directory$/) do
2
- set_environment_variable "HOME", expand_path(".")
4
+ set_environment_variable 'HOME', expand_path('.')
3
5
  end
4
6
 
5
7
  Given(/^I set the environment variable "(.*)" to "(.*)"/) do |variable, value|
@@ -16,8 +18,8 @@ end
16
18
 
17
19
  Given(/^I set the environment variables? to:/) do |table|
18
20
  table.hashes.each do |row|
19
- variable = row["variable"].to_s
20
- value = row["value"].to_s
21
+ variable = row['variable'].to_s
22
+ value = row['value'].to_s
21
23
 
22
24
  set_environment_variable(variable, value)
23
25
  end
@@ -25,8 +27,8 @@ end
25
27
 
26
28
  Given(/^I append the values? to the environment variables?:/) do |table|
27
29
  table.hashes.each do |row|
28
- variable = row["variable"].to_s
29
- value = row["value"].to_s
30
+ variable = row['variable'].to_s
31
+ value = row['value'].to_s
30
32
 
31
33
  append_environment_variable(variable, value)
32
34
  end
@@ -34,8 +36,8 @@ end
34
36
 
35
37
  Given(/^I prepend the values? to the environment variables?:/) do |table|
36
38
  table.hashes.each do |row|
37
- variable = row["variable"].to_s
38
- value = row["value"].to_s
39
+ variable = row['variable'].to_s
40
+ value = row['value'].to_s
39
41
 
40
42
  prepend_environment_variable(variable, value)
41
43
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Given(/^I use (?:a|the) fixture(?: named)? "([^"]*)"$/) do |name|
2
4
  copy File.join(aruba.config.fixtures_path_prefix, name), name
3
5
  cd name
@@ -46,12 +48,12 @@ Given(/^(?:a|the) (\d+) byte file(?: named)? "([^"]*)"$/) do |file_size, file_na
46
48
  end
47
49
 
48
50
  Given(/^(?:an|the) empty file(?: named)? "([^"]*)"$/) do |file_name|
49
- write_file(file_name, "")
51
+ write_file(file_name, '')
50
52
  end
51
53
 
52
54
  Given(/^(?:an|the) empty file(?: named)? "([^"]*)" with mode "([^"]*)"$/) \
53
55
  do |file_name, file_mode|
54
- write_file(file_name, "")
56
+ write_file(file_name, '')
55
57
  chmod(file_mode, file_name)
56
58
  end
57
59