Skip to content

Commit

Permalink
Merge pull request #585 from cucumber/issue-559-replace-run-methods
Browse files Browse the repository at this point in the history
Replace run methods
  • Loading branch information
mvz authored Jan 27, 2019
2 parents 406ca70 + 1284c68 commit 5ed690f
Show file tree
Hide file tree
Showing 33 changed files with 239 additions and 176 deletions.
10 changes: 5 additions & 5 deletions features/api/command/find_command.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: Find a started command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('echo hello') }
before(:each) { run_command('echo hello') }
let(:command) { find_command('echo hello') }
before(:each) { stop_all_commands }
Expand Down Expand Up @@ -44,8 +44,8 @@ Feature: Find a started command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('echo hello1') }
before(:each) { run('echo hello2') }
before(:each) { run_command('echo hello1') }
before(:each) { run_command('echo hello2') }
let(:command) { find_command('echo hello1') }
before(:each) { stop_all_commands }
Expand All @@ -67,9 +67,9 @@ Feature: Find a started command
RSpec.describe 'Run command', :type => :aruba do
before(:each) { set_environment_variable 'ENV_VAR', '1' }
before(:each) { run('bash -c "echo -n $ENV_VAR"') }
before(:each) { run_command('bash -c "echo -n $ENV_VAR"') }
before(:each) { set_environment_variable 'ENV_VAR', '2' }
before(:each) { run('bash -c "echo -n $ENV_VAR"') }
before(:each) { run_command('bash -c "echo -n $ENV_VAR"') }
let(:command) { find_command('bash -c "echo -n $ENV_VAR"') }
Expand Down
6 changes: 3 additions & 3 deletions features/api/command/last_command_started.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Return last command started
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('echo hello') }
before(:each) { run_command('echo hello') }
before(:each) { stop_all_commands }
it { expect(last_command_started).to be_successfully_executed }
Expand All @@ -25,8 +25,8 @@ Feature: Return last command started
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('echo hello') }
before(:each) { run('echo world') }
before(:each) { run_command('echo hello') }
before(:each) { run_command('echo world') }
before(:each) { stop_all_commands }
Expand Down
12 changes: 6 additions & 6 deletions features/api/command/last_command_stopped.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Return last command stopped
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('echo hello') }
before(:each) { run_command('echo hello') }
before(:each) { stop_all_commands }
it { expect(last_command_stopped).to be_successfully_executed }
Expand All @@ -25,8 +25,8 @@ Feature: Return last command stopped
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('echo hello') }
before(:each) { run('echo world') }
before(:each) { run_command('echo hello') }
before(:each) { run_command('echo world') }
before(:each) { stop_all_commands }
Expand All @@ -43,9 +43,9 @@ Feature: Return last command stopped
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('echo hello') }
before(:each) { run_command('echo hello') }
before(:each) { find_command('echo hello').stop }
before(:each) { run('echo world') }
before(:each) { run_command('echo world') }
it { expect(last_command_stopped).to be_successfully_executed }
it { expect(last_command_stopped.commandline).to eq 'echo hello' }
Expand Down Expand Up @@ -80,7 +80,7 @@ Feature: Return last command stopped
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('cli') }
before(:each) { run_command('cli') }
it { expect{ last_command_stopped.commandline }.to raise_error Aruba::NoCommandHasBeenStoppedError }
end
Expand Down
44 changes: 22 additions & 22 deletions features/api/command/run.feature
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Feature: Run command

To run a command use the `#run`-method. There are some configuration options
To run a command use the `#run_command`-method. There are some configuration options
which are relevant here:

- `startup_wait_time`:

Given this option `aruba` waits n seconds after it started the command.
This is most useful when using `#run()` and not really makes sense for
`#run_simple()`.
This is most useful when using `#run_command()` and not really makes sense for
`#run_command_and_stop()`.

You can use `#run()` + `startup_wait_time` to start background jobs.
You can use `#run_command()` + `startup_wait_time` to start background jobs.

- `exit_timeout`:

Expand All @@ -34,7 +34,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('cli') }
before(:each) { run_command('cli') }
it { expect(last_command_started).to be_successfully_executed }
end
"""
Expand All @@ -52,7 +52,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('bin/cli') }
before(:each) { run_command('bin/cli') }
it { expect(last_command_started).to be_successfully_executed }
end
"""
Expand All @@ -66,7 +66,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Find path for command', :type => :aruba do
it { expect { run('cli') }.to raise_error Aruba::LaunchError, /Command "cli" not found in PATH-variable/ }
it { expect { run_command('cli') }.to raise_error Aruba::LaunchError, /Command "cli" not found in PATH-variable/ }
end
"""
When I run `rspec`
Expand Down Expand Up @@ -112,7 +112,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1, :startup_wait_time => 2 do
before(:each) { run('cli') }
before(:each) { run_command('cli') }
before(:each) { last_command_started.send_signal 'HUP' }
it { expect(last_command_started).to be_successfully_executed }
Expand Down Expand Up @@ -145,7 +145,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 3 do
before(:each) { run('cli') }
before(:each) { run_command('cli') }
it { expect(last_command_started).to be_successfully_executed }
it { expect(last_command_started).to have_output /Hello, Aruba here/ }
Expand All @@ -157,7 +157,7 @@ Feature: Run command
Scenario: Mixing commands with long and short startup phase (deprecated)

If you commands with a long and short startup phases, you should consider
using the `startup_wait_time`-option local to the `#run`-call.
using the `startup_wait_time`-option local to the `#run_command`-call.

Given an executable named "bin/cli1" with:
"""bash
Expand Down Expand Up @@ -220,8 +220,8 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1 do
before(:each) { run('cli1', 3, 0.1, 'TERM', 2) }
before(:each) { run('cli2', 3, 0.1, 'TERM', 1) }
before(:each) { run_command('cli1', 3, 0.1, 'TERM', 2) }
before(:each) { run_command('cli2', 3, 0.1, 'TERM', 1) }
before(:each) { last_command_started.send_signal 'HUP' }
it { expect(last_command_started).to be_successfully_executed }
Expand All @@ -236,7 +236,7 @@ Feature: Run command
Scenario: Mixing commands with long and short startup phase

If you commands with a long and short startup phases, you should consider
using the `startup_wait_time`-option local to the `#run`-call.
using the `startup_wait_time`-option local to the `#run_command`-call.

Given an executable named "bin/cli1" with:
"""bash
Expand Down Expand Up @@ -299,8 +299,8 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1 do
before(:each) { run('cli1', :startup_wait_time => 2) }
before(:each) { run('cli2', :startup_wait_time => 1) }
before(:each) { run_command('cli1', :startup_wait_time => 2) }
before(:each) { run_command('cli2', :startup_wait_time => 1) }
before(:each) { last_command_started.send_signal 'HUP' }
it { expect(last_command_started).to be_successfully_executed }
Expand All @@ -315,7 +315,7 @@ Feature: Run command
Scenario: Mixing long and short running commands (deprecated)

If need to mix "long running" and "short running" commands, you should consider using the
`exit_timeout`-option local to the `#run`-method.
`exit_timeout`-option local to the `#run_command`-method.

Given an executable named "bin/cli1" with:
"""bash
Expand Down Expand Up @@ -343,8 +343,8 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('cli1', 3) }
before(:each) { run('cli2', 1) }
before(:each) { run_command('cli1', 3) }
before(:each) { run_command('cli2', 1) }
it { expect(last_command_started).to be_successfully_executed }
it { expect(last_command_started).to have_output /Hello, Aruba here/ }
Expand All @@ -356,7 +356,7 @@ Feature: Run command
Scenario: Mixing long and short running commands

If need to mix "long running" and "short running" commands, you should consider using the
`exit_timeout`-option local to the `#run`-method.
`exit_timeout`-option local to the `#run_command`-method.

Given an executable named "bin/cli1" with:
"""bash
Expand Down Expand Up @@ -384,8 +384,8 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('cli1', :exit_timeout => 3) }
before(:each) { run('cli2', :exit_timeout => 1) }
before(:each) { run_command('cli1', :exit_timeout => 3) }
before(:each) { run_command('cli2', :exit_timeout => 1) }
it { expect(last_command_started).to be_successfully_executed }
it { expect(last_command_started).to have_output /Hello, Aruba here/ }
Expand All @@ -405,7 +405,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('cli') }
before(:each) { run_command('cli') }
let!(:found_command) { find_command('cli') }
it { expect { found_command.start }.to raise_error Aruba::CommandAlreadyStartedError }
end
Expand Down
24 changes: 12 additions & 12 deletions features/api/command/run_simple.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: Run command

To run a command use the `#run`-method. There are some configuration options
To run a command use the `#run_command_and_stop`-method. There are some configuration options
which are relevant here:

- `fail_on_error`:
Expand All @@ -23,7 +23,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
it { expect { run_simple('cli') }.to raise_error RSpec::Expectations::ExpectationNotMetError }
it { expect { run_command_and_stop('cli') }.to raise_error RSpec::Expectations::ExpectationNotMetError }
end
"""
When I run `rspec`
Expand All @@ -40,7 +40,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
it { expect { run_simple('cli', :fail_on_error => true) }.to raise_error }
it { expect { run_command_and_stop('cli', :fail_on_error => true) }.to raise_error }
end
"""
When I run `rspec`
Expand All @@ -57,7 +57,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
it { expect { run_simple('cli', true) }.to raise_error }
it { expect { run_command_and_stop('cli', true) }.to raise_error }
end
"""
When I run `rspec`
Expand All @@ -74,7 +74,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
it { expect { run_simple('cli', :fail_on_error => false) }.not_to raise_error }
it { expect { run_command_and_stop('cli', :fail_on_error => false) }.not_to raise_error }
end
"""
When I run `rspec`
Expand All @@ -91,7 +91,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
it { expect { run_simple('cli', false) }.not_to raise_error }
it { expect { run_command_and_stop('cli', false) }.not_to raise_error }
end
"""
When I run `rspec`
Expand Down Expand Up @@ -126,7 +126,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1, :startup_wait_time => 2 do
before(:each) { run_simple('cli') }
before(:each) { run_command_and_stop('cli') }
it { expect(last_command_started).to be_successfully_executed }
it { expect(last_command_started).to have_output /Hello, Aruba is working/ }
Expand Down Expand Up @@ -156,7 +156,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 3 do
before(:each) { run_simple('cli') }
before(:each) { run_command_and_stop('cli') }
it { expect(last_command_started).to be_successfully_executed }
it { expect(last_command_started).to have_output /Hello, Aruba here/ }
Expand All @@ -165,10 +165,10 @@ Feature: Run command
When I run `rspec`
Then the specs should all pass

Scenario: Sending signals to commands started with `#run_simple()`
Scenario: Sending signals to commands started with `#run_command_and_stop()`

Sending signals to a command which is started by
`#run_simple()` does not make sense. The command is stopped internally when
`#run_command_and_stop()` does not make sense. The command is stopped internally when
its exit status is checked.

Given an executable named "bin/cli" with:
Expand Down Expand Up @@ -199,7 +199,7 @@ Feature: Run command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 2, :startup_wait_time => 1 do
before(:each) { run_simple('cli') }
before(:each) { run_command_and_stop('cli') }
it { expect { last_command_started.send_signal 'HUP' }.to raise_error Aruba::CommandAlreadyStoppedError }
end
"""
Expand All @@ -224,7 +224,7 @@ Feature: Run command
end
RSpec.describe 'Run command', :type => :aruba do
it { expect { run_simple('cli', :fail_on_error => true) }.to_not raise_error }
it { expect { run_command_and_stop('cli', :fail_on_error => true) }.to_not raise_error }
end
"""
When I run `rspec`
Expand Down
4 changes: 2 additions & 2 deletions features/api/command/send_signal.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Feature: Send running command a signal
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1, :startup_wait_time => 5 do
before(:each) { run('cli') }
before(:each) { run_command('cli') }
before(:each) { last_command_started.send_signal 'HUP' }
it { expect(last_command_started).to have_output /Exit/ }
end
Expand All @@ -45,7 +45,7 @@ Feature: Send running command a signal
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1, :startup_wait_time => 5 do
before(:each) { run('cli') }
before(:each) { run_command('cli') }
it { expect { last_command_started.send_signal 'HUP' }.to raise_error Aruba::CommandAlreadyStoppedError, /Command "cli" with PID/ }
end
"""
Expand Down
4 changes: 2 additions & 2 deletions features/api/command/stderr.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Access STDERR of command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
before(:each) { run('cli') }
before(:each) { run_command('cli') }
before(:each) { stop_all_commands }
it { expect(last_command_started.stderr).to start_with 'Hello' }
end
Expand All @@ -38,7 +38,7 @@ Feature: Access STDERR of command
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba, :io_wait_timeout => 2 do
before(:each) { run('cli') }
before(:each) { run_command('cli') }
it { expect(last_command_started.stderr).to start_with 'Hello' }
end
"""
Expand Down
Loading

0 comments on commit 5ed690f

Please sign in to comment.