aruba 0.11.0.pre → 0.11.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/History.md +21 -1
  4. data/aruba.gemspec +1 -0
  5. data/features/api/command/find_command.feature +83 -0
  6. data/features/api/command/last_command_started.feature +50 -0
  7. data/features/api/command/last_command_stopped.feature +89 -0
  8. data/features/api/command/run.feature +259 -0
  9. data/features/api/command/stop.feature +53 -1
  10. data/features/api/text/replace_variables.feature +1 -1
  11. data/features/getting_started/run_commands.feature +177 -0
  12. data/features/matchers/file/be_existing_executable.feature +87 -0
  13. data/features/{integration/rspec/getting_started.feature → rspec/integration.feature} +31 -0
  14. data/fixtures/getting-started-app/Gemfile +1 -1
  15. data/lib/aruba.rb +0 -19
  16. data/lib/aruba/api.rb +2 -0
  17. data/lib/aruba/api/command.rb +103 -44
  18. data/lib/aruba/api/core.rb +13 -8
  19. data/lib/aruba/api/deprecated.rb +26 -4
  20. data/lib/aruba/api/environment.rb +21 -13
  21. data/lib/aruba/api/filesystem.rb +13 -0
  22. data/lib/aruba/api/rvm.rb +5 -0
  23. data/lib/aruba/api/text.rb +7 -1
  24. data/lib/aruba/aruba_path.rb +6 -0
  25. data/lib/aruba/basic_configuration.rb +35 -3
  26. data/lib/aruba/basic_configuration/option.rb +7 -0
  27. data/lib/aruba/cli.rb +4 -0
  28. data/lib/aruba/command.rb +47 -1
  29. data/lib/aruba/config.rb +15 -2
  30. data/lib/aruba/config_wrapper.rb +49 -8
  31. data/lib/aruba/console.rb +4 -1
  32. data/lib/aruba/console/help.rb +2 -0
  33. data/lib/aruba/contracts/absolute_path.rb +7 -0
  34. data/lib/aruba/contracts/enum.rb +5 -0
  35. data/lib/aruba/contracts/is_power_of_two.rb +9 -2
  36. data/lib/aruba/contracts/relative_path.rb +7 -0
  37. data/lib/aruba/cucumber/command.rb +6 -9
  38. data/lib/aruba/cucumber/file.rb +1 -1
  39. data/lib/aruba/cucumber/hooks.rb +36 -29
  40. data/lib/aruba/errors.rb +16 -1
  41. data/lib/aruba/events.rb +39 -0
  42. data/lib/aruba/extensions/string/strip.rb +1 -0
  43. data/lib/aruba/file_size.rb +11 -0
  44. data/lib/aruba/hooks.rb +2 -0
  45. data/lib/aruba/in_config_wrapper.rb +24 -0
  46. data/lib/aruba/in_process.rb +2 -0
  47. data/lib/aruba/initializer.rb +37 -0
  48. data/lib/aruba/matchers/base/base_matcher.rb +2 -0
  49. data/lib/aruba/matchers/base/object_formatter.rb +4 -0
  50. data/lib/aruba/matchers/collection/all.rb +2 -0
  51. data/lib/aruba/matchers/collection/include_an_object.rb +2 -0
  52. data/lib/aruba/matchers/command/have_exit_status.rb +1 -1
  53. data/lib/aruba/matchers/command/have_finished_in_time.rb +1 -10
  54. data/lib/aruba/matchers/command/have_output.rb +1 -10
  55. data/lib/aruba/matchers/command/have_output_on_stderr.rb +1 -10
  56. data/lib/aruba/matchers/command/have_output_on_stdout.rb +1 -10
  57. data/lib/aruba/matchers/file/be_an_existing_executable.rb +37 -0
  58. data/lib/aruba/platform.rb +4 -0
  59. data/lib/aruba/platforms/announcer.rb +225 -0
  60. data/lib/aruba/platforms/aruba_file_creator.rb +4 -0
  61. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +4 -0
  62. data/lib/aruba/{aruba_logger.rb → platforms/aruba_logger.rb} +4 -0
  63. data/lib/aruba/platforms/command_monitor.rb +229 -0
  64. data/lib/aruba/platforms/determine_disk_usage.rb +5 -0
  65. data/lib/aruba/platforms/determine_file_size.rb +9 -0
  66. data/lib/aruba/platforms/disk_usage_calculator.rb +9 -0
  67. data/lib/aruba/platforms/local_environment.rb +12 -0
  68. data/lib/aruba/platforms/simple_table.rb +11 -0
  69. data/lib/aruba/platforms/unix_command_string.rb +3 -0
  70. data/lib/aruba/platforms/unix_environment_variables.rb +3 -0
  71. data/lib/aruba/platforms/unix_platform.rb +20 -2
  72. data/lib/aruba/platforms/unix_which.rb +6 -2
  73. data/lib/aruba/platforms/windows_command_string.rb +7 -0
  74. data/lib/aruba/platforms/windows_environment_variables.rb +2 -0
  75. data/lib/aruba/platforms/windows_platform.rb +3 -0
  76. data/lib/aruba/platforms/windows_which.rb +6 -2
  77. data/lib/aruba/processes/basic_process.rb +20 -5
  78. data/lib/aruba/processes/debug_process.rb +3 -1
  79. data/lib/aruba/processes/in_process.rb +18 -2
  80. data/lib/aruba/processes/spawn_process.rb +14 -13
  81. data/lib/aruba/rspec.rb +34 -23
  82. data/lib/aruba/runtime.rb +65 -6
  83. data/lib/aruba/setup.rb +87 -0
  84. data/lib/aruba/version.rb +1 -1
  85. data/spec/aruba/api_spec.rb +13 -36
  86. data/spec/aruba/{config_wrapper_spec.rb → in_config_wrapper_spec.rb} +1 -1
  87. data/spec/aruba/spawn_process_spec.rb +9 -14
  88. data/spec/support/configs/pry.rb +3 -0
  89. data/spec/support/shared_contexts/aruba.rb +1 -0
  90. metadata +40 -14
  91. data/features/getting_started/supported_programming_languages.feature +0 -89
  92. data/lib/aruba/announcer.rb +0 -219
  93. data/lib/aruba/matchers/rspec.rb +0 -0
  94. data/lib/aruba/process_monitor.rb +0 -201
  95. data/lib/aruba/processes/null_process.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0d970f3502a082de16bb266924f0c7900377b76
4
- data.tar.gz: 011f90e024a29624795ad9883d29b8547c3fdeda
3
+ metadata.gz: 5e93dadabb88f5dd615ae393d84932f5f1c2eb6b
4
+ data.tar.gz: d08af1d7ff5dcc684d05fcd03a9795caa476d244
5
5
  SHA512:
6
- metadata.gz: e769fd6414236a83911ef5e5c3a068ea88f8795d2de079ae140b834b452fc0a89167ff2e7466fed1a88c920105cd884652d791d5d246d20361da5fbe763f3faa
7
- data.tar.gz: e2415039514fa5fa15ebf0649e13aaafaf339f77348c5a1167b792f08ea7c7c31ba37eb9af6cf1dae1f54cdb40634d90cc8a0dbc97479fd84a43b668a2e5f0ec
6
+ metadata.gz: 800cedf76eaaadb53e801974ccf9df8d9d6ba8534aaa0591606d3aa28e8f6ba6c92d802e8549c43862b0f387795a655472475b34254646350980ec2159a369d4
7
+ data.tar.gz: 0af17d2ae845c40a06b0be27433868d8f2637c22774566a67353a8c5e4a66e8079d53b6cad7ef9d80a3115a8486bbf4a600a71ea497ef8fb130709b10c133022
data/Gemfile CHANGED
@@ -42,7 +42,7 @@ group :development, :test do
42
42
  gem 'simplecov', '~> 0.10'
43
43
 
44
44
  # Test api
45
- gem 'rspec', '~> 3.3.0'
45
+ gem 'rspec', '~> 3.4'
46
46
  gem 'fuubar', '~> 2.0.0'
47
47
 
48
48
  # using platform for this make bundler complain about the same gem given
data/History.md CHANGED
@@ -14,12 +14,14 @@
14
14
  * Added announce formatter for time spans, e.g. `startup_wait_time`
15
15
  * All `*Process`-classes e.g. `BasicProcess`, `SpawnProcess` etc. are marked as
16
16
  private. Users should use `#run('cmd')` and don't use the classes directly.
17
+ * `rvm`-methods are deprecated. They too ruby specific.
18
+
19
+ # Old releases
17
20
 
18
21
  ## [v0.10.2](https://github.com/cucumber/aruba/compare/v0.10.1...v0.10.2)
19
22
 
20
23
  * Fixed problem in regex after merge of step definitions
21
24
 
22
- # Old releases
23
25
 
24
26
  ## [v0.10.1](https://github.com/cucumber/aruba/compare/v0.10.0...v0.10.1)
25
27
 
@@ -445,6 +447,24 @@
445
447
 
446
448
  # Upcoming un-released versions
447
449
 
450
+ ## [v0.11.0.pre2](https://github.com/cucumber/aruba/compare/v0.11.pre2...v0.11.0.pre2)
451
+
452
+ * Integrate `EventBus` to decouple announcers from starting, stopping commands
453
+ etc. This uses nearly the same implementation like `cucumber`. (PR #309)
454
+ * Starting/Stopping a command directly (`command.start`, `command.stop`) is now
455
+ reported to the command monitor and `last_command_stopped` is updated
456
+ correctly
457
+ * Added `#restart` to `Command` to make it possible to restart a command
458
+ * Added check to prevent a command which has already been started, to be
459
+ started again. Otherwise you've got hidden commands which are not stopped
460
+ after a cucumber/rspec/minitest run.
461
+ * Adding alot of documentation to `aruba`
462
+ * Refactored `#run`: Now it wants you to pass a `Hash` containing the options.
463
+ The old syntax is still supported, but is deprecated.
464
+ * Added `#find_command` as experimental feature. It searches the started
465
+ commands from last to first.
466
+ * Added `be_an_executable` matcher
467
+
448
468
  ## [v1.0.0](https://github.com/cucumber/aruba/compare/v0.11.0...v1.0.0)
449
469
 
450
470
  * Support for rubies older than 1.9.3 is discontinued - e.g 1.8.7 and 1.9.2
data/aruba.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_runtime_dependency 'rspec-expectations', '>= 2.99'
20
20
  s.add_runtime_dependency 'contracts', '~> 0.9'
21
21
  s.add_runtime_dependency 'thor', '~> 0.19'
22
+ s.add_runtime_dependency 'event-bus', '~> 0.2.0'
22
23
 
23
24
  s.add_development_dependency 'bundler', '~> 1.10.2'
24
25
 
@@ -0,0 +1,83 @@
1
+ Feature: Find a started command
2
+
3
+ This feature is experimental and may change without further notice.
4
+
5
+ Background:
6
+ Given I use a fixture named "cli-app"
7
+
8
+ Scenario: Exising command
9
+ Given a file named "spec/run_spec.rb" with:
10
+ """ruby
11
+ require 'spec_helper'
12
+
13
+ RSpec.describe 'Run command', :type => :aruba do
14
+ before(:each) { run('echo hello') }
15
+ let(:command) { find_command('echo hello') }
16
+
17
+ before(:each) { stop_all_commands }
18
+
19
+ it { expect(command).to be_successfully_executed }
20
+ it { expect(command.commandline).to eq 'echo hello' }
21
+ end
22
+ """
23
+ When I run `rspec`
24
+ Then the specs should all pass
25
+
26
+ Scenario: Non-Exising command
27
+ Given a file named "spec/run_spec.rb" with:
28
+ """ruby
29
+ require 'spec_helper'
30
+
31
+ RSpec.describe 'Run command', :type => :aruba do
32
+ let(:command) { find_command('echo hello') }
33
+
34
+ it { expect{ command }.to raise_error Aruba::CommandNotFoundError }
35
+ it { expect{ command.commandline }.to raise_error Aruba::CommandNotFoundError }
36
+ end
37
+ """
38
+ When I run `rspec`
39
+ Then the specs should all pass
40
+
41
+ Scenario: Multiple commands
42
+ Given a file named "spec/run_spec.rb" with:
43
+ """ruby
44
+ require 'spec_helper'
45
+
46
+ RSpec.describe 'Run command', :type => :aruba do
47
+ before(:each) { run('echo hello1') }
48
+ before(:each) { run('echo hello2') }
49
+ let(:command) { find_command('echo hello1') }
50
+
51
+ before(:each) { stop_all_commands }
52
+
53
+ it { expect(command).to be_successfully_executed }
54
+ it { expect(command.commandline).to eq 'echo hello1' }
55
+ end
56
+ """
57
+ When I run `rspec`
58
+ Then the specs should all pass
59
+
60
+ Scenario: Multiple commands with same commandline
61
+
62
+ If searches in reverse. So it finds the last command started with the given commandline.
63
+
64
+ Given a file named "spec/run_spec.rb" with:
65
+ """ruby
66
+ require 'spec_helper'
67
+
68
+ RSpec.describe 'Run command', :type => :aruba do
69
+ before(:each) { set_environment_variable 'ENV_VAR', '1' }
70
+ before(:each) { run('bash -c "echo -n $ENV_VAR"') }
71
+ before(:each) { set_environment_variable 'ENV_VAR', '2' }
72
+ before(:each) { run('bash -c "echo -n $ENV_VAR"') }
73
+
74
+ let(:command) { find_command('bash -c "echo -n $ENV_VAR"') }
75
+
76
+ before(:each) { stop_all_commands }
77
+
78
+ it { expect(command).to be_successfully_executed }
79
+ it { expect(command.stdout).to eq '2' }
80
+ end
81
+ """
82
+ When I run `rspec`
83
+ Then the specs should all pass
@@ -0,0 +1,50 @@
1
+ Feature: Return last command started
2
+
3
+ Background:
4
+ Given I use a fixture named "cli-app"
5
+
6
+ Scenario: A command has been started
7
+ Given a file named "spec/run_spec.rb" with:
8
+ """ruby
9
+ require 'spec_helper'
10
+
11
+ RSpec.describe 'Run command', :type => :aruba do
12
+ before(:each) { run('echo hello') }
13
+ before(:each) { stop_all_commands }
14
+
15
+ it { expect(last_command_started).to be_successfully_executed }
16
+ it { expect(last_command_started.commandline).to eq 'echo hello' }
17
+ end
18
+ """
19
+ When I run `rspec`
20
+ Then the specs should all pass
21
+
22
+ Scenario: Multiple commands have been started
23
+ Given a file named "spec/run_spec.rb" with:
24
+ """ruby
25
+ require 'spec_helper'
26
+
27
+ RSpec.describe 'Run command', :type => :aruba do
28
+ before(:each) { run('echo hello') }
29
+ before(:each) { run('echo world') }
30
+
31
+ before(:each) { stop_all_commands }
32
+
33
+ it { expect(last_command_started).to be_successfully_executed }
34
+ it { expect(last_command_started.commandline).to eq 'echo world' }
35
+ end
36
+ """
37
+ When I run `rspec`
38
+ Then the specs should all pass
39
+
40
+ Scenario: No command has been started
41
+ Given a file named "spec/run_spec.rb" with:
42
+ """ruby
43
+ require 'spec_helper'
44
+
45
+ RSpec.describe 'Run command', :type => :aruba do
46
+ it { expect{ last_command_started.commandline }.to raise_error Aruba::NoCommandHasBeenStartedError }
47
+ end
48
+ """
49
+ When I run `rspec`
50
+ Then the specs should all pass
@@ -0,0 +1,89 @@
1
+ Feature: Return last command stopped
2
+
3
+ Background:
4
+ Given I use a fixture named "cli-app"
5
+
6
+ Scenario: A command has been started
7
+ Given a file named "spec/run_spec.rb" with:
8
+ """ruby
9
+ require 'spec_helper'
10
+
11
+ RSpec.describe 'Run command', :type => :aruba do
12
+ before(:each) { run('echo hello') }
13
+ before(:each) { stop_all_commands }
14
+
15
+ it { expect(last_command_stopped).to be_successfully_executed }
16
+ it { expect(last_command_stopped.commandline).to eq 'echo hello' }
17
+ end
18
+ """
19
+ When I run `rspec`
20
+ Then the specs should all pass
21
+
22
+ Scenario: Multiple commands have been started and all are stopped
23
+ Given a file named "spec/run_spec.rb" with:
24
+ """ruby
25
+ require 'spec_helper'
26
+
27
+ RSpec.describe 'Run command', :type => :aruba do
28
+ before(:each) { run('echo hello') }
29
+ before(:each) { run('echo world') }
30
+
31
+ before(:each) { stop_all_commands }
32
+
33
+ it { expect(last_command_stopped).to be_successfully_executed }
34
+ it { expect(last_command_stopped.commandline).to eq 'echo world' }
35
+ end
36
+ """
37
+ When I run `rspec`
38
+ Then the specs should all pass
39
+
40
+ Scenario: Multiple commands have been started and a single one is stopped
41
+ Given a file named "spec/run_spec.rb" with:
42
+ """ruby
43
+ require 'spec_helper'
44
+
45
+ RSpec.describe 'Run command', :type => :aruba do
46
+ before(:each) { run('echo hello') }
47
+ before(:each) { find_command('echo hello').stop }
48
+ before(:each) { run('echo world') }
49
+
50
+ it { expect(last_command_stopped).to be_successfully_executed }
51
+ it { expect(last_command_stopped.commandline).to eq 'echo hello' }
52
+ end
53
+ """
54
+ When I run `rspec`
55
+ Then the specs should all pass
56
+
57
+
58
+ @requires-aruba-version-1
59
+ Scenario: No command has been started
60
+ Given a file named "spec/run_spec.rb" with:
61
+ """ruby
62
+ require 'spec_helper'
63
+
64
+ RSpec.describe 'Run command', :type => :aruba do
65
+ it { expect{ last_command_stopped.commandline }.to raise_error Aruba::NoCommandHasBeenStoppedError }
66
+ end
67
+ """
68
+ When I run `rspec`
69
+ Then the specs should all pass
70
+
71
+ @requires-aruba-version-1
72
+ Scenario: No command has been stopped
73
+ Given an executable named "bin/cli" with:
74
+ """bash
75
+ #!/bin/bash
76
+ while [ true ]; do sleep 1; done
77
+ """
78
+ And a file named "spec/run_spec.rb" with:
79
+ """ruby
80
+ require 'spec_helper'
81
+
82
+ RSpec.describe 'Run command', :type => :aruba do
83
+ before(:each) { run('cli') }
84
+
85
+ it { expect{ last_command_stopped.commandline }.to raise_error Aruba::NoCommandHasBeenStoppedError }
86
+ end
87
+ """
88
+ When I run `rspec`
89
+ Then the specs should all pass
@@ -153,3 +153,262 @@ Feature: Run command
153
153
  """
154
154
  When I run `rspec`
155
155
  Then the specs should all pass
156
+
157
+ Scenario: Mixing commands with long and short startup phase (deprecated)
158
+
159
+ If you commands with a long and short startup phases, you should consider
160
+ using the `startup_wait_time`-option local to the `#run`-call.
161
+
162
+ Given an executable named "bin/cli1" with:
163
+ """bash
164
+ #!/usr/bin/env bash
165
+
166
+ function initialize_script {
167
+ sleep 2
168
+ }
169
+
170
+ function do_some_work {
171
+ echo "Hello, Aruba is working"
172
+ }
173
+
174
+ function recurring_work {
175
+ echo "Hello, Aruba here"
176
+ }
177
+
178
+ function stop_script {
179
+ exit 0
180
+ }
181
+
182
+ trap recurring_work HUP
183
+ trap stop_script TERM
184
+
185
+ initialize_script
186
+ do_some_work
187
+
188
+ while [ true ]; do sleep 0.2; done
189
+ """
190
+ And an executable named "bin/cli2" with:
191
+ """bash
192
+ #!/usr/bin/env bash
193
+
194
+ function initialize_script {
195
+ sleep 0
196
+ }
197
+
198
+ function do_some_work {
199
+ echo "Hello, Aruba is working"
200
+ }
201
+
202
+ function recurring_work {
203
+ echo "Hello, Aruba here"
204
+ }
205
+
206
+ function stop_script {
207
+ exit 0
208
+ }
209
+
210
+ trap recurring_work HUP
211
+ trap stop_script TERM
212
+
213
+ initialize_script
214
+ do_some_work
215
+
216
+ while [ true ]; do sleep 0.2; done
217
+ """
218
+ And a file named "spec/run_spec.rb" with:
219
+ """ruby
220
+ require 'spec_helper'
221
+
222
+ RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1 do
223
+ before(:each) { run('cli1', 3, 0.1, 'TERM', 2) }
224
+ before(:each) { run('cli2', 3, 0.1, 'TERM', 1) }
225
+ before(:each) { last_command_started.send_signal 'HUP' }
226
+
227
+ it { expect(last_command_started).to be_successfully_executed }
228
+ it { expect(last_command_started).to have_output /Hello, Aruba is working/ }
229
+ it { expect(last_command_started).to have_output /Hello, Aruba here/ }
230
+
231
+ end
232
+ """
233
+ When I run `rspec`
234
+ Then the specs should all pass
235
+
236
+ Scenario: Mixing commands with long and short startup phase
237
+
238
+ If you commands with a long and short startup phases, you should consider
239
+ using the `startup_wait_time`-option local to the `#run`-call.
240
+
241
+ Given an executable named "bin/cli1" with:
242
+ """bash
243
+ #!/usr/bin/env bash
244
+
245
+ function initialize_script {
246
+ sleep 2
247
+ }
248
+
249
+ function do_some_work {
250
+ echo "Hello, Aruba is working"
251
+ }
252
+
253
+ function recurring_work {
254
+ echo "Hello, Aruba here"
255
+ }
256
+
257
+ function stop_script {
258
+ exit 0
259
+ }
260
+
261
+ trap recurring_work HUP
262
+ trap stop_script TERM
263
+
264
+ initialize_script
265
+ do_some_work
266
+
267
+ while [ true ]; do sleep 0.2; done
268
+ """
269
+ And an executable named "bin/cli2" with:
270
+ """bash
271
+ #!/usr/bin/env bash
272
+
273
+ function initialize_script {
274
+ sleep 0
275
+ }
276
+
277
+ function do_some_work {
278
+ echo "Hello, Aruba is working"
279
+ }
280
+
281
+ function recurring_work {
282
+ echo "Hello, Aruba here"
283
+ }
284
+
285
+ function stop_script {
286
+ exit 0
287
+ }
288
+
289
+ trap recurring_work HUP
290
+ trap stop_script TERM
291
+
292
+ initialize_script
293
+ do_some_work
294
+
295
+ while [ true ]; do sleep 0.2; done
296
+ """
297
+ And a file named "spec/run_spec.rb" with:
298
+ """ruby
299
+ require 'spec_helper'
300
+
301
+ RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1 do
302
+ before(:each) { run('cli1', :startup_wait_time => 2) }
303
+ before(:each) { run('cli2', :startup_wait_time => 1) }
304
+ before(:each) { last_command_started.send_signal 'HUP' }
305
+
306
+ it { expect(last_command_started).to be_successfully_executed }
307
+ it { expect(last_command_started).to have_output /Hello, Aruba is working/ }
308
+ it { expect(last_command_started).to have_output /Hello, Aruba here/ }
309
+
310
+ end
311
+ """
312
+ When I run `rspec`
313
+ Then the specs should all pass
314
+
315
+ Scenario: Mixing long and short running commands (deprecated)
316
+
317
+ If need to mix "long running" and "short running" commands, you should consider using the
318
+ `exit_timeout`-option local to the `#run`-method.
319
+
320
+ Given an executable named "bin/cli1" with:
321
+ """bash
322
+ #!/usr/bin/env bash
323
+
324
+ function do_some_work {
325
+ sleep 2
326
+ echo "Hello, Aruba here"
327
+ }
328
+
329
+ do_some_work
330
+ """
331
+ And an executable named "bin/cli2" with:
332
+ """bash
333
+ #!/usr/bin/env bash
334
+
335
+ function do_some_work {
336
+ echo "Hello, Aruba here"
337
+ }
338
+
339
+ do_some_work
340
+ """
341
+ And a file named "spec/run_spec.rb" with:
342
+ """ruby
343
+ require 'spec_helper'
344
+
345
+ RSpec.describe 'Run command', :type => :aruba do
346
+ before(:each) { run('cli1', 3) }
347
+ before(:each) { run('cli2', 1) }
348
+
349
+ it { expect(last_command_started).to be_successfully_executed }
350
+ it { expect(last_command_started).to have_output /Hello, Aruba here/ }
351
+ end
352
+ """
353
+ When I run `rspec`
354
+ Then the specs should all pass
355
+
356
+ Scenario: Mixing long and short running commands
357
+
358
+ If need to mix "long running" and "short running" commands, you should consider using the
359
+ `exit_timeout`-option local to the `#run`-method.
360
+
361
+ Given an executable named "bin/cli1" with:
362
+ """bash
363
+ #!/usr/bin/env bash
364
+
365
+ function do_some_work {
366
+ sleep 2
367
+ echo "Hello, Aruba here"
368
+ }
369
+
370
+ do_some_work
371
+ """
372
+ And an executable named "bin/cli2" with:
373
+ """bash
374
+ #!/usr/bin/env bash
375
+
376
+ function do_some_work {
377
+ echo "Hello, Aruba here"
378
+ }
379
+
380
+ do_some_work
381
+ """
382
+ And a file named "spec/run_spec.rb" with:
383
+ """ruby
384
+ require 'spec_helper'
385
+
386
+ RSpec.describe 'Run command', :type => :aruba do
387
+ before(:each) { run('cli1', :exit_timeout => 3) }
388
+ before(:each) { run('cli2', :exit_timeout => 1) }
389
+
390
+ it { expect(last_command_started).to be_successfully_executed }
391
+ it { expect(last_command_started).to have_output /Hello, Aruba here/ }
392
+ end
393
+ """
394
+ When I run `rspec`
395
+ Then the specs should all pass
396
+
397
+ Scenario: Starting command twice fails
398
+ Given an executable named "bin/cli" with:
399
+ """bash
400
+ #!/bin/bash
401
+ exit 0
402
+ """
403
+ And a file named "spec/run_spec.rb" with:
404
+ """ruby
405
+ require 'spec_helper'
406
+
407
+ RSpec.describe 'Run command', :type => :aruba do
408
+ before(:each) { run('cli') }
409
+ let!(:found_command) { find_command('cli') }
410
+ it { expect { found_command.start }.to raise_error Aruba::CommandAlreadyStartedError }
411
+ end
412
+ """
413
+ When I run `rspec`
414
+ Then the specs should all pass