[DRE-commits] [ruby-aruba] 42/74: Fixed bugs in new code
Hideki Yamane
henrich at moszumanska.debian.org
Sat Nov 28 01:16:39 UTC 2015
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch debian/sid
in repository ruby-aruba.
commit 3c46eecb32b9768a014b29f2b925510e8b0c9074
Author: Dennis Günnewig <dg1 at ratiodata.de>
Date: Thu Nov 26 10:10:34 2015 +0100
Fixed bugs in new code
---
History.md | 22 +-
features/api/command/find_command.feature | 53 ++++-
features/api/command/run.feature | 259 +++++++++++++++++++++
features/api/command/stop.feature | 54 ++++-
features/api/text/replace_variables.feature | 2 +-
features/getting_started/run_commands.feature | 58 ++---
fixtures/getting-started-app/Gemfile | 2 +-
lib/aruba/api.rb | 2 +
lib/aruba/api/command.rb | 97 ++++++--
lib/aruba/api/core.rb | 2 +
lib/aruba/api/deprecated.rb | 5 +
lib/aruba/api/environment.rb | 8 +-
lib/aruba/api/filesystem.rb | 3 +
lib/aruba/api/rvm.rb | 5 +
lib/aruba/api/text.rb | 6 +
lib/aruba/aruba_path.rb | 6 +
lib/aruba/basic_configuration.rb | 33 ++-
lib/aruba/basic_configuration/option.rb | 7 +
lib/aruba/cli.rb | 4 +
lib/aruba/command.rb | 11 +
lib/aruba/config.rb | 15 +-
lib/aruba/config_wrapper.rb | 12 +-
lib/aruba/console.rb | 4 +
lib/aruba/console/help.rb | 2 +
lib/aruba/contracts/absolute_path.rb | 7 +
lib/aruba/contracts/enum.rb | 5 +
lib/aruba/contracts/is_power_of_two.rb | 11 +-
lib/aruba/contracts/relative_path.rb | 7 +
lib/aruba/cucumber/command.rb | 4 +-
lib/aruba/errors.rb | 11 +-
lib/aruba/events.rb | 30 ++-
lib/aruba/events/basic_event.rb | 11 -
lib/aruba/events/command_stopped.rb | 5 -
lib/aruba/extensions/string/strip.rb | 1 +
lib/aruba/file_size.rb | 11 +
lib/aruba/hooks.rb | 2 +
lib/aruba/in_config_wrapper.rb | 7 +
lib/aruba/in_process.rb | 2 +
lib/aruba/initializer.rb | 37 +++
lib/aruba/matchers/base/base_matcher.rb | 2 +
lib/aruba/matchers/base/object_formatter.rb | 4 +
lib/aruba/matchers/collection/all.rb | 2 +
lib/aruba/matchers/collection/include_an_object.rb | 2 +
lib/aruba/matchers/rspec.rb | 0
lib/aruba/platform.rb | 4 +
lib/aruba/platforms/announcer.rb | 4 +
lib/aruba/platforms/aruba_file_creator.rb | 4 +
.../platforms/aruba_fixed_size_file_creator.rb | 4 +
lib/aruba/platforms/aruba_logger.rb | 4 +
lib/aruba/platforms/command_monitor.rb | 35 +--
lib/aruba/platforms/determine_disk_usage.rb | 5 +
lib/aruba/platforms/determine_file_size.rb | 9 +
lib/aruba/platforms/disk_usage_calculator.rb | 9 +
lib/aruba/platforms/local_environment.rb | 12 +
lib/aruba/platforms/simple_table.rb | 11 +
lib/aruba/platforms/unix_command_string.rb | 3 +
lib/aruba/platforms/unix_environment_variables.rb | 3 +
lib/aruba/platforms/unix_platform.rb | 3 +
lib/aruba/platforms/unix_which.rb | 4 +
lib/aruba/platforms/windows_command_string.rb | 7 +
.../platforms/windows_environment_variables.rb | 2 +
lib/aruba/platforms/windows_platform.rb | 3 +
lib/aruba/platforms/windows_which.rb | 4 +
lib/aruba/processes/basic_process.rb | 17 +-
lib/aruba/processes/debug_process.rb | 4 +-
lib/aruba/processes/in_process.rb | 18 +-
lib/aruba/processes/spawn_process.rb | 14 +-
lib/aruba/rspec.rb | 3 +
lib/aruba/runtime.rb | 34 ++-
lib/aruba/setup.rb | 1 +
spec/aruba/api_spec.rb | 2 +-
71 files changed, 936 insertions(+), 120 deletions(-)
diff --git a/History.md b/History.md
index fa495b6..e3d1954 100644
--- a/History.md
+++ b/History.md
@@ -14,12 +14,14 @@
* Added announce formatter for time spans, e.g. `startup_wait_time`
* All `*Process`-classes e.g. `BasicProcess`, `SpawnProcess` etc. are marked as
private. Users should use `#run('cmd')` and don't use the classes directly.
+* `rvm`-methods are deprecated. They too ruby specific.
+
+# Old releases
## [v0.10.2](https://github.com/cucumber/aruba/compare/v0.10.1...v0.10.2)
* Fixed problem in regex after merge of step definitions
-# Old releases
## [v0.10.1](https://github.com/cucumber/aruba/compare/v0.10.0...v0.10.1)
@@ -445,6 +447,24 @@
# Upcoming un-released versions
+## [v0.11.0.pre2](https://github.com/cucumber/aruba/compare/v0.11.pre2...v0.11.0.pre2)
+
+* Integrate `EventBus` to decouple announcers from starting, stopping commands
+ etc. This uses nearly the same implementation like `cucumber`. (PR #309)
+* Starting/Stopping a command directly (`command.start`, `command.stop`) is now
+ reported to the command monitor and `last_command_stopped` is updated
+ correctly
+* Added `#restart` to `Command` to make it possible to restart a command
+* Added check to prevent a command which has already been started, to be
+ started again. Otherwise you've got hidden commands which are not stopped
+ after a cucumber/rspec/minitest run.
+* Adding alot of documentation to `aruba`
+* Refactored `#run`: Now it wants you to pass a `Hash` containing the options.
+ The old syntax is still supported, but is deprecated.
+* Added `#find_command` as experimental feature. It searches the started
+ commands from last to first.
+* Added `be_an_executable` matcher
+
## [v1.0.0](https://github.com/cucumber/aruba/compare/v0.11.0...v1.0.0)
* Support for rubies older than 1.9.3 is discontinued - e.g 1.8.7 and 1.9.2
diff --git a/features/api/command/find_command.feature b/features/api/command/find_command.feature
index ccdeb5d..8cd19c8 100644
--- a/features/api/command/find_command.feature
+++ b/features/api/command/find_command.feature
@@ -1,5 +1,10 @@
Feature: Find a started command
+ This feature is experimental and may change without further notice.
+
+ Background:
+ Given I use a fixture named "cli-app"
+
Scenario: Exising command
Given a file named "spec/run_spec.rb" with:
"""ruby
@@ -26,8 +31,52 @@ Feature: Find a started command
RSpec.describe 'Run command', :type => :aruba do
let(:command) { find_command('echo hello') }
- it { expect{ command }.to raise_error Aruba::CommandNotFound }
- it { expect{ command.commandline }.to raise_error Aruba::CommandNotFound }
+ it { expect{ command }.to raise_error Aruba::CommandNotFoundError }
+ it { expect{ command.commandline }.to raise_error Aruba::CommandNotFoundError }
+ end
+ """
+ When I run `rspec`
+ Then the specs should all pass
+
+ Scenario: Multiple commands
+ Given a file named "spec/run_spec.rb" with:
+ """ruby
+ require 'spec_helper'
+
+ RSpec.describe 'Run command', :type => :aruba do
+ before(:each) { run('echo hello1') }
+ before(:each) { run('echo hello2') }
+ let(:command) { find_command('echo hello1') }
+
+ before(:each) { stop_all_commands }
+
+ it { expect(command).to be_successfully_executed }
+ it { expect(command.commandline).to eq 'echo hello1' }
+ end
+ """
+ When I run `rspec`
+ Then the specs should all pass
+
+ Scenario: Multiple commands with same commandline
+
+ If searches in reverse. So it finds the last command started with the given commandline.
+
+ Given a file named "spec/run_spec.rb" with:
+ """ruby
+ require 'spec_helper'
+
+ 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) { set_environment_variable 'ENV_VAR', '2' }
+ before(:each) { run('bash -c "echo -n $ENV_VAR"') }
+
+ let(:command) { find_command('bash -c "echo -n $ENV_VAR"') }
+
+ before(:each) { stop_all_commands }
+
+ it { expect(command).to be_successfully_executed }
+ it { expect(command.stdout).to eq '2' }
end
"""
When I run `rspec`
diff --git a/features/api/command/run.feature b/features/api/command/run.feature
index 2433937..9ae8cf4 100644
--- a/features/api/command/run.feature
+++ b/features/api/command/run.feature
@@ -153,3 +153,262 @@ Feature: Run command
"""
When I run `rspec`
Then the specs should all pass
+
+ 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.
+
+ Given an executable named "bin/cli1" with:
+ """bash
+ #!/usr/bin/env bash
+
+ function initialize_script {
+ sleep 2
+ }
+
+ function do_some_work {
+ echo "Hello, Aruba is working"
+ }
+
+ function recurring_work {
+ echo "Hello, Aruba here"
+ }
+
+ function stop_script {
+ exit 0
+ }
+
+ trap recurring_work HUP
+ trap stop_script TERM
+
+ initialize_script
+ do_some_work
+
+ while [ true ]; do sleep 0.2; done
+ """
+ And an executable named "bin/cli2" with:
+ """bash
+ #!/usr/bin/env bash
+
+ function initialize_script {
+ sleep 0
+ }
+
+ function do_some_work {
+ echo "Hello, Aruba is working"
+ }
+
+ function recurring_work {
+ echo "Hello, Aruba here"
+ }
+
+ function stop_script {
+ exit 0
+ }
+
+ trap recurring_work HUP
+ trap stop_script TERM
+
+ initialize_script
+ do_some_work
+
+ while [ true ]; do sleep 0.2; done
+ """
+ And a file named "spec/run_spec.rb" with:
+ """ruby
+ 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) { last_command_started.send_signal 'HUP' }
+
+ it { expect(last_command_started).to be_successfully_executed }
+ it { expect(last_command_started).to have_output /Hello, Aruba is working/ }
+ it { expect(last_command_started).to have_output /Hello, Aruba here/ }
+
+ end
+ """
+ When I run `rspec`
+ Then the specs should all pass
+
+ 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.
+
+ Given an executable named "bin/cli1" with:
+ """bash
+ #!/usr/bin/env bash
+
+ function initialize_script {
+ sleep 2
+ }
+
+ function do_some_work {
+ echo "Hello, Aruba is working"
+ }
+
+ function recurring_work {
+ echo "Hello, Aruba here"
+ }
+
+ function stop_script {
+ exit 0
+ }
+
+ trap recurring_work HUP
+ trap stop_script TERM
+
+ initialize_script
+ do_some_work
+
+ while [ true ]; do sleep 0.2; done
+ """
+ And an executable named "bin/cli2" with:
+ """bash
+ #!/usr/bin/env bash
+
+ function initialize_script {
+ sleep 0
+ }
+
+ function do_some_work {
+ echo "Hello, Aruba is working"
+ }
+
+ function recurring_work {
+ echo "Hello, Aruba here"
+ }
+
+ function stop_script {
+ exit 0
+ }
+
+ trap recurring_work HUP
+ trap stop_script TERM
+
+ initialize_script
+ do_some_work
+
+ while [ true ]; do sleep 0.2; done
+ """
+ And a file named "spec/run_spec.rb" with:
+ """ruby
+ 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) { last_command_started.send_signal 'HUP' }
+
+ it { expect(last_command_started).to be_successfully_executed }
+ it { expect(last_command_started).to have_output /Hello, Aruba is working/ }
+ it { expect(last_command_started).to have_output /Hello, Aruba here/ }
+
+ end
+ """
+ When I run `rspec`
+ Then the specs should all pass
+
+ 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.
+
+ Given an executable named "bin/cli1" with:
+ """bash
+ #!/usr/bin/env bash
+
+ function do_some_work {
+ sleep 2
+ echo "Hello, Aruba here"
+ }
+
+ do_some_work
+ """
+ And an executable named "bin/cli2" with:
+ """bash
+ #!/usr/bin/env bash
+
+ function do_some_work {
+ echo "Hello, Aruba here"
+ }
+
+ do_some_work
+ """
+ And a file named "spec/run_spec.rb" with:
+ """ruby
+ require 'spec_helper'
+
+ RSpec.describe 'Run command', :type => :aruba do
+ before(:each) { run('cli1', 3) }
+ before(:each) { run('cli2', 1) }
+
+ it { expect(last_command_started).to be_successfully_executed }
+ it { expect(last_command_started).to have_output /Hello, Aruba here/ }
+ end
+ """
+ When I run `rspec`
+ Then the specs should all pass
+
+ 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.
+
+ Given an executable named "bin/cli1" with:
+ """bash
+ #!/usr/bin/env bash
+
+ function do_some_work {
+ sleep 2
+ echo "Hello, Aruba here"
+ }
+
+ do_some_work
+ """
+ And an executable named "bin/cli2" with:
+ """bash
+ #!/usr/bin/env bash
+
+ function do_some_work {
+ echo "Hello, Aruba here"
+ }
+
+ do_some_work
+ """
+ And a file named "spec/run_spec.rb" with:
+ """ruby
+ require 'spec_helper'
+
+ RSpec.describe 'Run command', :type => :aruba do
+ before(:each) { run('cli1', :exit_timeout => 3) }
+ before(:each) { run('cli2', :exit_timeout => 1) }
+
+ it { expect(last_command_started).to be_successfully_executed }
+ it { expect(last_command_started).to have_output /Hello, Aruba here/ }
+ end
+ """
+ When I run `rspec`
+ Then the specs should all pass
+
+ Scenario: Starting command twice fails
+ Given an executable named "bin/cli" with:
+ """bash
+ #!/bin/bash
+ exit 0
+ """
+ And a file named "spec/run_spec.rb" with:
+ """ruby
+ require 'spec_helper'
+
+ RSpec.describe 'Run command', :type => :aruba do
+ before(:each) { run('cli') }
+ let!(:found_command) { find_command('cli') }
+ it { expect { found_command.start }.to raise_error Aruba::CommandAlreadyStartedError }
+ end
+ """
+ When I run `rspec`
+ Then the specs should all pass
diff --git a/features/api/command/stop.feature b/features/api/command/stop.feature
index 58b8ccf..ec633c7 100644
--- a/features/api/command/stop.feature
+++ b/features/api/command/stop.feature
@@ -3,11 +3,63 @@ Feature: Stop command
To stop commands via API you can do the following:
- `last_command_started.stop`
- - `stop_all_commands`
+ - `find_command('command').stop`
+
+ But normally there's no need to stop a command manually. All matchers
+ handling commands make sure, that they stop ALL command before check actual
+ against expected.
Background:
Given I use a fixture named "cli-app"
+ Scenario: Stop command started last
+ Given an executable named "bin/cli" with:
+ """bash
+ #!/bin/bash
+ function term {
+ exit 0
+ }
+
+ trap term TERM
+ while [ true ]; do sleep 1; done
+ """
+ And a file named "spec/run_spec.rb" with:
+ """ruby
+ require 'spec_helper'
+
+ RSpec.describe 'Run command', :type => :aruba do
+ before(:each) { run('cli') }
+ before(:each) { last_command_started.stop }
+ it { expect(last_command_started).to be_successfully_executed }
+ end
+ """
+ When I run `rspec`
+ Then the specs should all pass
+
+ Scenario: Find and stop command
+ Given an executable named "bin/cli" with:
+ """bash
+ #!/bin/bash
+ function term {
+ exit 0
+ }
+
+ trap term TERM
+ while [ true ]; do sleep 1; done
+ """
+ And a file named "spec/run_spec.rb" with:
+ """ruby
+ require 'spec_helper'
+
+ RSpec.describe 'Run command', :type => :aruba do
+ before(:each) { run('cli') }
+ before(:each) { find_command('cli').stop }
+ it { expect(last_command_started).to be_successfully_executed }
+ end
+ """
+ When I run `rspec`
+ Then the specs should all pass
+
Scenario: Stop successful command with configured signal
Given an executable named "bin/cli" with:
"""bash
diff --git a/features/api/text/replace_variables.feature b/features/api/text/replace_variables.feature
index c570e44..dae4d86 100644
--- a/features/api/text/replace_variables.feature
+++ b/features/api/text/replace_variables.feature
@@ -37,7 +37,7 @@ Feature: Replace variables
require 'spec_helper'
RSpec.describe 'Run command', :type => :aruba do
- it { expect { replace_variables('<pid-last-command-started>') }.to raise_error Aruba::NoCommandHasBeenStoppedError }
+ it { expect { replace_variables('<pid-last-command-started>') }.to raise_error Aruba::NoCommandHasBeenStartedError }
end
"""
When I run `rspec`
diff --git a/features/getting_started/run_commands.feature b/features/getting_started/run_commands.feature
index c7da2f8..8efd6df 100644
--- a/features/getting_started/run_commands.feature
+++ b/features/getting_started/run_commands.feature
@@ -33,26 +33,16 @@ Feature: Run commands with Aruba
When I successfully run `cucumber`
Then the features should all pass
- Scenario: Ruby Program
- Given an executable named "bin/cli" with:
- """ruby
- #!/usr/bin/env ruby
-
- puts "Hello, Aruba!"
- """
- When I successfully run `cucumber`
- Then the features should all pass
-
Scenario: Bash Program run via bash
- Given a file named "tmp/aruba/bin/cli.sh" with:
- """bash
- echo "Hello, Aruba!"
- """
- And a file named "features/hello_aruba.feature" with:
+ Given a file named "features/hello_aruba.feature" with:
"""
Feature: Getting Started With Aruba
Scenario: First Run of Command
- Given I successfully run `bash bin/cli.sh`
+ Given a file named "cli.sh" with:
+ \"\"\"
+ echo "Hello, Aruba!"
+ \"\"\"
+ When I successfully run `bash ./cli.sh`
Then the output should contain:
\"\"\"
Hello, Aruba!
@@ -72,15 +62,15 @@ Feature: Run commands with Aruba
Then the features should all pass
Scenario: Ruby Program via "ruby"
- Given an executable named "bin/cli.rb" with:
- """ruby
- puts "Hello, Aruba!"
- """
- And a file named "features/hello_aruba.feature" with:
+ Given a file named "features/hello_aruba.feature" with:
"""
Feature: Getting Started With Aruba
Scenario: First Run of Command
- Given I successfully run `ruby bin/cli.rb`
+ Given a file named "cli.rb" with:
+ \"\"\"
+ puts "Hello, Aruba!"
+ \"\"\"
+ When I successfully run `ruby ./cli.rb`
Then the output should contain:
\"\"\"
Hello, Aruba!
@@ -100,15 +90,15 @@ Feature: Run commands with Aruba
Then the features should all pass
Scenario: Python Program via "python"
- Given a file named "bin/cli.py" with:
- """python
- print("Hello, Aruba!")
- """
- And a file named "features/hello_aruba.feature" with:
+ Given a file named "features/hello_aruba.feature" with:
"""
Feature: Getting Started With Aruba
Scenario: First Run of Command
- Given I successfully run `python bin/cli.py`
+ Given a file named "cli.py" with:
+ \"\"\"
+ print("Hello, Aruba!")
+ \"\"\"
+ When I successfully run `python ./cli.py`
Then the output should contain:
\"\"\"
Hello, Aruba!
@@ -128,15 +118,15 @@ Feature: Run commands with Aruba
Then the features should all pass
Scenario: Perl Program via "perl"
- Given an executable named "bin/cli.pl" with:
- """perl
- print "Hello, Aruba!\n";
- """
- And a file named "features/hello_aruba.feature" with:
+ Given a file named "features/hello_aruba.feature" with:
"""
Feature: Getting Started With Aruba
Scenario: First Run of Command
- Given I successfully run `perl bin/cli.pl`
+ Given a file named "cli.pl" with:
+ \"\"\"perl
+ print "Hello, Aruba!\n";
+ \"\"\"
+ When I successfully run `perl ./cli.pl`
Then the output should contain:
\"\"\"
Hello, Aruba!
diff --git a/fixtures/getting-started-app/Gemfile b/fixtures/getting-started-app/Gemfile
index 8e7e0b5..a534a95 100644
--- a/fixtures/getting-started-app/Gemfile
+++ b/fixtures/getting-started-app/Gemfile
@@ -1,4 +1,4 @@
source 'https://rubygems.org'
gem 'cucumber'
-gem 'aruba'
+gem 'aruba', path: File.expand_path('../../../../', __FILE__)
diff --git a/lib/aruba/api.rb b/lib/aruba/api.rb
index a341f66..692546d 100644
--- a/lib/aruba/api.rb
+++ b/lib/aruba/api.rb
@@ -19,7 +19,9 @@ require 'aruba/api/rvm'
Aruba.platform.require_matching_files('../matchers/**/*.rb', __FILE__)
+# Aruba
module Aruba
+ # Api
module Api
include Aruba::Api::Core
include Aruba::Api::Commands
diff --git a/lib/aruba/api/command.rb b/lib/aruba/api/command.rb
index b1d00a9..17edb46 100644
--- a/lib/aruba/api/command.rb
+++ b/lib/aruba/api/command.rb
@@ -5,6 +5,7 @@ require 'aruba/command'
# require 'win32/file' if File::ALT_SEPARATOR
+# Aruba
module Aruba
class << self
# @deprecated
@@ -15,8 +16,11 @@ module Aruba
# self.process = Aruba::Processes::SpawnProcess
end
+# Aruba
module Aruba
+ # Api
module Api
+ # Command module
module Commands
# Resolve path for command using the PATH-environment variable
#
@@ -112,22 +116,48 @@ module Aruba
# @param [String] cmd
# The command which should be executed
#
- # @param [Integer] timeout
+ # @param [Hash] opts
+ # Options
+ #
+ # @option [Integer] exit_timeout
# If the timeout is reached the command will be killed
#
- # @param [String] stop_signal
- # Use signal to stop command (Private)
+ # @option [Integer] io_wait_timeout
+ # Wait for IO to finish
+ #
+ # @option [Integer] startup_wait_time
+ # Wait for a command to start
+ #
+ # @option [String] stop_signal
+ # Use signal to stop command
#
# @yield [SpawnProcess]
# Run block with process
#
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/CyclomaticComplexity
- def run(cmd, exit_timeout = nil, io_wait_timeout = nil, stop_signal = nil, startup_wait_time = nil)
- exit_timeout ||= aruba.config.exit_timeout
- io_wait_timeout ||= aruba.config.io_wait_timeout
- stop_signal ||= aruba.config.stop_signal
- startup_wait_time ||= aruba.config.startup_wait_time
+ def run(*args)
+ fail ArgumentError, 'Please pass at least a command as first argument.' if args.size < 1
+
+ cmd = args.shift
+
+ if args.last.is_a? Hash
+ opts = args.pop
+
+ exit_timeout = opts.fetch(:exit_timeout, aruba.config.exit_timeout)
+ io_wait_timeout = opts.fetch(:io_wait_timeout, aruba.config.io_wait_timeout)
+ stop_signal = opts.fetch(:stop_signal, aruba.config.stop_signal)
+ startup_wait_time = opts.fetch(:startup_wait_time, aruba.config.startup_wait_time)
+ else
+ if args.size > 1
+ Aruba.platform.deprecated("Please pass options to `#run` as named parameters/hash and don\'t use the old style, e.g. `#run('cmd', :exit_timeout => 5)`.")
+ end
+
+ exit_timeout = args[0] || aruba.config.exit_timeout
+ io_wait_timeout = args[1] || aruba.config.io_wait_timeout
+ stop_signal = args[2] || aruba.config.stop_signal
+ startup_wait_time = args[3] || aruba.config.startup_wait_time
+ end
cmd = replace_variables(cmd)
@@ -136,6 +166,7 @@ module Aruba
environment = aruba.environment.to_h
working_directory = expand_path('.')
+ event_bus = aruba.event_bus
aruba.announcer.announce(:full_environment, environment)
aruba.announcer.announce(:timeout, 'exit', exit_timeout)
@@ -145,7 +176,7 @@ module Aruba
aruba.announcer.announce(:directory, working_directory)
aruba.announcer.announce(:command, cmd)
- cmd = Aruba.platform.detect_ruby(cmd)
+ cmd = Aruba.platform.detect_ruby(cmd)
mode = if Aruba.process
# rubocop:disable Metrics/LineLength
@@ -165,7 +196,7 @@ module Aruba
aruba.config.main_class
end
- aruba.command_monitor.start_command(
+ command = Command.new(
cmd,
:mode => mode,
:exit_timeout => exit_timeout,
@@ -174,11 +205,10 @@ module Aruba
:environment => environment,
:main_class => main_class,
:stop_signal => stop_signal,
- :startup_wait_time => startup_wait_time
+ :startup_wait_time => startup_wait_time,
+ :event_bus => event_bus
)
- command = aruba.command_monitor.find(cmd)
-
if aruba.config.before? :cmd
# rubocop:disable Metrics/LineLength
Aruba.platform.deprecated('The use of "before"-hook" ":cmd" is deprecated. Use ":command" instead. Please be aware that this hook gets the command passed in not the cmdline itself. To get the commandline use "#cmd.commandline"')
@@ -206,13 +236,44 @@ module Aruba
# @param [String] cmd
# The command to be executed
#
- # @param [TrueClass,FalseClass] fail_on_error
+ # @param [Hash] options
+ # Options for aruba
+ #
+ # @option [TrueClass,FalseClass] fail_on_error
# Should aruba fail on error?
#
- # @param [Integer] timeout
+ # @option [Integer] exit_timeout
# Timeout for execution
- def run_simple(cmd, fail_on_error = true, exit_timeout = nil, io_wait_timeout = nil)
- command = run(cmd, exit_timeout, io_wait_timeout)
+ #
+ # @option [Integer] io_wait_timeout
+ # Timeout for IO - STDERR, STDOUT
+ #
+ # rubocop:disable Metrics/CyclomaticComplexity
+ # rubocop:disable Metrics/MethodLength
+ def run_simple(*args)
+ fail ArgumentError, 'Please pass at least a command as first argument.' if args.size < 1
+
+ cmd = args.shift
+
+ if args.last.is_a? Hash
+ opts = args.pop
+
+ fail_on_error = opts.fetch(:fail_on_error, false) || false
+ exit_timeout = opts.fetch(:exit_timeout, aruba.config.exit_timeout) || aruba.config.exit_timeout
+ io_wait_timeout = opts.fetch(:io_wait_timeout, aruba.config.io_wait_timeout) || aruba.config.io_wait_timeout
+ else
+ if args.size > 1
+ # rubocop:disable Metrics/LineLength
+ Aruba.platform.deprecated("Please pass options to `#run_simple` as named parameters/hash and don\'t use the old style with positional parameters, NEW: e.g. `#run_simple('cmd', :exit_timeout => 5)`.")
+ # rubocop:enable Metrics/LineLength
+ end
+
+ fail_on_error = args[0] || true
+ exit_timeout = args[1] || aruba.config.exit_timeout
+ io_wait_timeout = args[2] || aruba.config.io_wait_timeout
+ end
+
+ command = run(cmd, :exit_timeout => exit_timeout, :io_wait_timeout => io_wait_timeout)
command.stop
if Aruba::VERSION < '1'
@@ -225,6 +286,8 @@ module Aruba
expect(command).to be_successfully_executed
end
end
+ # rubocop:enable Metrics/CyclomaticComplexity
+ # rubocop:enable Metrics/MethodLength
# Provide data to command via stdin
#
diff --git a/lib/aruba/api/core.rb b/lib/aruba/api/core.rb
index 2104123..da74f13 100644
--- a/lib/aruba/api/core.rb
+++ b/lib/aruba/api/core.rb
@@ -5,7 +5,9 @@ require 'aruba/setup'
require 'aruba/config/jruby'
+# Aruba
module Aruba
+ # Api
module Api
# Core methods of aruba
#
diff --git a/lib/aruba/api/deprecated.rb b/lib/aruba/api/deprecated.rb
index 623a26c..628a2d4 100644
--- a/lib/aruba/api/deprecated.rb
+++ b/lib/aruba/api/deprecated.rb
@@ -1,7 +1,10 @@
require 'aruba/platforms/announcer'
+# Aruba
module Aruba
+ # Api
module Api
+ # Deprecated
module Deprecated
# @deprecated
# The path to the directory which should contain all your test data
@@ -897,6 +900,7 @@ module Aruba
end
# @private
+ # @deprecated
def process_monitor
Aruba.platform.deprecated('The use of "#process_monitor" is deprecated.')
@@ -904,6 +908,7 @@ module Aruba
end
# @private
+ # @deprecated
def processes
Aruba.platform.deprecated('The use of "#process_monitor" is deprecated. Please use "#all_commands" instead.')
diff --git a/lib/aruba/api/environment.rb b/lib/aruba/api/environment.rb
index 6bfd3fd..b45cfd6 100644
--- a/lib/aruba/api/environment.rb
+++ b/lib/aruba/api/environment.rb
@@ -1,6 +1,8 @@
require 'aruba/platform'
+# Aruba
module Aruba
+ # Api
module Api
# Environment methods of aruba
module Environment
@@ -74,9 +76,11 @@ module Aruba
def delete_environment_variable(name)
name = name.to_s
- aruba.event_bus.notify Events::DeletedEnvironmentVariable.new(:old => old_environment, :new => new_environment, :changed => { :name => name, :value => '' })
-
+ old_environment = aruba.environment.to_h
aruba.environment.delete name
+ new_environment = aruba.environment.to_h
+
+ aruba.event_bus.notify Events::DeletedEnvironmentVariable.new(:old => old_environment, :new => new_environment, :changed => { :name => name, :value => '' })
self
end
diff --git a/lib/aruba/api/filesystem.rb b/lib/aruba/api/filesystem.rb
index 905e810..f0d6906 100644
--- a/lib/aruba/api/filesystem.rb
+++ b/lib/aruba/api/filesystem.rb
@@ -8,8 +8,11 @@ Aruba.platform.require_matching_files('../matchers/file/*.rb', __FILE__)
Aruba.platform.require_matching_files('../matchers/directory/*.rb', __FILE__)
Aruba.platform.require_matching_files('../matchers/path/*.rb', __FILE__)
+# Aruba
module Aruba
+ # Api
module Api
+ # Filesystem methods
module Filesystem
# Check if file or directory exist
#
diff --git a/lib/aruba/api/rvm.rb b/lib/aruba/api/rvm.rb
index 47d90f3..ffea6a1 100644
--- a/lib/aruba/api/rvm.rb
+++ b/lib/aruba/api/rvm.rb
@@ -1,8 +1,13 @@
require 'aruba/api/environment'
require 'aruba/api/command'
+# Aruba
module Aruba
+ # Api
module Api
+ # RVM
+ #
+ # @deprecated
module Rvm
# Use a clean rvm gemset
#
diff --git a/lib/aruba/api/text.rb b/lib/aruba/api/text.rb
index 1ddb62b..9567283 100644
--- a/lib/aruba/api/text.rb
+++ b/lib/aruba/api/text.rb
@@ -1,5 +1,8 @@
+# Aruba
module Aruba
+ # Api
module Api
+ # Text manipulation
module Text
# Unescape text
#
@@ -40,6 +43,9 @@ module Aruba
# @experimental
#
# Replace variables in command string
+ #
+ # @param [#to_s] text
+ # The text to parse
def replace_variables(text)
text = text.gsub(/<pid-last-command-started>/, last_command_started.pid.to_s) if text.include? '<pid-last-command-started>'
diff --git a/lib/aruba/aruba_path.rb b/lib/aruba/aruba_path.rb
index 73e978e..56bcacd 100644
--- a/lib/aruba/aruba_path.rb
+++ b/lib/aruba/aruba_path.rb
@@ -3,7 +3,11 @@ require 'delegate'
require 'aruba/file_size'
+# Aruba
module Aruba
+ # Pathname for aruba files and directories
+ #
+ # @private
class ArubaPath < Delegator
def initialize(path)
obj = [path.to_s].flatten
@@ -13,10 +17,12 @@ module Aruba
@delegate_sd_obj = obj
end
+ # Get path
def __getobj__
::Pathname.new(::File.join(*@delegate_sd_obj))
end
+ # Set path
def __setobj__(obj)
@delegate_sd_obj = [obj.to_s].flatten
end
diff --git a/lib/aruba/basic_configuration.rb b/lib/aruba/basic_configuration.rb
index 79cbe72..3c09e03 100644
--- a/lib/aruba/basic_configuration.rb
+++ b/lib/aruba/basic_configuration.rb
@@ -2,8 +2,11 @@ require 'contracts'
require 'aruba/basic_configuration/option'
require 'aruba/in_config_wrapper'
+# Aruba
module Aruba
- # Basic configuration for ProxyPacRb
+ # Basic configuration for Aruba
+ #
+ # @private
class BasicConfiguration
include Contracts
@@ -12,6 +15,19 @@ module Aruba
@known_options ||= {}
end
+ # Define an option reader
+ #
+ # @param [Symbol] name
+ # The name of the reader
+ #
+ # @param [Hash] opts
+ # Options
+ #
+ # @option [Class, Module] contract
+ # The contract for the option
+ #
+ # @option [Object] default
+ # The default value
def option_reader(name, opts = {})
contract = opts[:contract]
default = opts[:default]
@@ -27,6 +43,20 @@ module Aruba
self
end
+ # Define an option reader and writer
+ #
+ # @param [Symbol] name
+ # The name of the reader
+ #
+ # @param [Hash] opts
+ # Options
+ #
+ # @option [Class, Module] contract
+ # The contract for the option
+ #
+ # @option [Object] default
+ # The default value
+ #
# rubocop:disable Metrics/CyclomaticComplexity
def option_accessor(name, opts = {})
contract = opts[:contract]
@@ -67,6 +97,7 @@ module Aruba
public
+ # Create configuration
def initialize
initialize_configuration
end
diff --git a/lib/aruba/basic_configuration/option.rb b/lib/aruba/basic_configuration/option.rb
index 11f5f04..a32e742 100644
--- a/lib/aruba/basic_configuration/option.rb
+++ b/lib/aruba/basic_configuration/option.rb
@@ -1,10 +1,16 @@
+# Aruba
module Aruba
+ # Basic Configuration
+ #
class BasicConfiguration
# A configuration option
+ #
+ # @private
class Option
attr_accessor :name, :value
attr_reader :default_value
+ # Create option
def initialize(opts = {})
name = opts[:name]
value = opts[:value]
@@ -17,6 +23,7 @@ module Aruba
@default_value = value
end
+ # Compare option
def ==(other)
name == other.name && value == other.value
end
diff --git a/lib/aruba/cli.rb b/lib/aruba/cli.rb
index 6cb322a..370954d 100644
--- a/lib/aruba/cli.rb
+++ b/lib/aruba/cli.rb
@@ -2,7 +2,11 @@ require 'thor'
require 'aruba/console'
require 'aruba/initializer'
+# Aruba
module Aruba
+ # Command line Interface
+ #
+ # @private
class Cli < Thor
def self.exit_on_failure?
true
diff --git a/lib/aruba/command.rb b/lib/aruba/command.rb
index 7a1ecbe..352722a 100644
--- a/lib/aruba/command.rb
+++ b/lib/aruba/command.rb
@@ -3,7 +3,18 @@ require 'aruba/processes/spawn_process'
require 'aruba/processes/in_process'
require 'aruba/processes/debug_process'
+# Aruba
module Aruba
+ # Command
+ #
+ # This class is not meant for direct use - Command.new, though it's API is
+ # public. As it is just a wrapper class, have a look at `BasicProcess` and
+ # the like for the public API.
+ #
+ # @see BasicProcess
+ # @see SpawnProcess
+ #
+ # @private
class Command < SimpleDelegator
private
diff --git a/lib/aruba/config.rb b/lib/aruba/config.rb
index eb92bc7..caef3e5 100644
--- a/lib/aruba/config.rb
+++ b/lib/aruba/config.rb
@@ -11,8 +11,11 @@ require 'aruba/contracts/enum'
require 'aruba/contracts/is_power_of_two'
+# Aruba
module Aruba
# Aruba Configuration
+ #
+ # This defines the configuration options of aruba
class Configuration < BasicConfiguration
if Aruba::VERSION >= '1.0.0'
option_reader :root_directory, :contract => { None => String }, :default => Dir.getwd
@@ -64,13 +67,21 @@ module Aruba
end
end
-# Main Module
+# Aruba
module Aruba
@config = Configuration.new
class << self
attr_reader :config
+ # Configure aruba
+ #
+ # @example How to configure aruba
+ #
+ # Aruba.configure do |config|
+ # config.<option> = <value>
+ # end
+ #
def configure(&block)
@config.configure(&block)
@@ -79,10 +90,12 @@ module Aruba
end
end
+# Aruba
module Aruba
# Old Config
#
# @private
+ # @deprecated
class Config < Configuration
def initialize(*args)
warn('The use of "Aruba::Config" is deprecated. Use "Aruba::Configuration" instead.')
diff --git a/lib/aruba/config_wrapper.rb b/lib/aruba/config_wrapper.rb
index 59cc100..8698b8b 100644
--- a/lib/aruba/config_wrapper.rb
+++ b/lib/aruba/config_wrapper.rb
@@ -1,6 +1,11 @@
module Aruba
# This wraps the current runtime configuration of aruba.
# If an option is changed, it notifies the event queue.
+ #
+ # This class is not meant for direct use - ConfigWrapper.new - by normal
+ # users.
+ #
+ # @private
class ConfigWrapper
private
@@ -35,7 +40,12 @@ module Aruba
config.respond_to? name
end
- # Compare
+ # Compare two configs
+ #
+ # The comparism is done based on their values. No hooks are compared.
+ #
+ # Somehow `#respond_to_missing?`, `method_missing?` and `respond_to?` don't
+ # help here.
def ==(other)
config == other
end
diff --git a/lib/aruba/console.rb b/lib/aruba/console.rb
index 39ec7e3..5881e3c 100644
--- a/lib/aruba/console.rb
+++ b/lib/aruba/console.rb
@@ -3,8 +3,12 @@ require 'irb'
require 'aruba/api'
require 'aruba/console/help'
+# Aruba
module Aruba
+ # Consule
class Console
+ # Start the aruba console
+ #
# rubocop:disable Metrics/MethodLength
def start
# Start IRB with current context:
diff --git a/lib/aruba/console/help.rb b/lib/aruba/console/help.rb
index 210f0f2..4d654e6 100644
--- a/lib/aruba/console/help.rb
+++ b/lib/aruba/console/help.rb
@@ -1,6 +1,8 @@
require 'aruba/api'
+# Aruba
module Aruba
+ # Consule
class Console
# Helpers for Aruba::Console
module Help
diff --git a/lib/aruba/contracts/absolute_path.rb b/lib/aruba/contracts/absolute_path.rb
index 7b291e2..a22f8a5 100644
--- a/lib/aruba/contracts/absolute_path.rb
+++ b/lib/aruba/contracts/absolute_path.rb
@@ -1,8 +1,15 @@
require 'aruba/aruba_path'
+# Aruba
module Aruba
+ # Contracts
module Contracts
+ # Check if path is absolute
class AbsolutePath
+ # Check
+ #
+ # @param [Object] value
+ # The value to be checked
def self.valid?(value)
ArubaPath.new(value).absolute?
rescue
diff --git a/lib/aruba/contracts/enum.rb b/lib/aruba/contracts/enum.rb
index 3f1ae15..9e72896 100644
--- a/lib/aruba/contracts/enum.rb
+++ b/lib/aruba/contracts/enum.rb
@@ -1,7 +1,10 @@
require 'contracts'
+# Aruba
module Aruba
+ # Contracts
module Contracts
+ # Enum
class Enum < ::Contracts::CallableClass
private
@@ -9,10 +12,12 @@ module Aruba
public
+ # Create contract
def initialize(*vals)
@vals = vals
end
+ # Check if value is part of array
def valid?(val)
vals.include? val
end
diff --git a/lib/aruba/contracts/is_power_of_two.rb b/lib/aruba/contracts/is_power_of_two.rb
index 55dd20f..dfa98e1 100644
--- a/lib/aruba/contracts/is_power_of_two.rb
+++ b/lib/aruba/contracts/is_power_of_two.rb
@@ -1,12 +1,19 @@
require 'aruba/aruba_path'
+# Aruba
module Aruba
+ # Contracts
module Contracts
+ # Is value power of two
class IsPowerOfTwo
- def self.valid?(x)
+ # Check value
+ #
+ # @param [Integer] value
+ # The value to be checked
+ def self.valid?(value)
# explanation for algorithm can be found here:
# http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/
- x != 0 && (x & (x - 1)) == 0 ? true : false
+ value != 0 && (value & (value - 1)) == 0 ? true : false
rescue
false
end
diff --git a/lib/aruba/contracts/relative_path.rb b/lib/aruba/contracts/relative_path.rb
index dcec601..27f0711 100644
--- a/lib/aruba/contracts/relative_path.rb
+++ b/lib/aruba/contracts/relative_path.rb
@@ -1,8 +1,15 @@
require 'aruba/aruba_path'
+# Aruba
module Aruba
+ # Contracts
module Contracts
+ # Is value relative path
class RelativePath
+ # Check
+ #
+ # @param [String] value
+ # The path to be checked
def self.valid?(value)
ArubaPath.new(value).relative?
rescue
diff --git a/lib/aruba/cucumber/command.rb b/lib/aruba/cucumber/command.rb
index 99af54a..1ce7298 100644
--- a/lib/aruba/cucumber/command.rb
+++ b/lib/aruba/cucumber/command.rb
@@ -11,7 +11,7 @@ end
When(/^I run `([^`]*)`$/)do |cmd|
cmd = sanitize_text(cmd)
- run_simple(cmd, false)
+ run_simple(cmd, fail_on_error: false)
end
When(/^I successfully run "(.*)"$/)do |cmd|
@@ -25,7 +25,7 @@ end
## I successfully run `sleep 29` for up to 30 seconds
When(/^I successfully run `(.*?)`(?: for up to (\d+) seconds)?$/)do |cmd, secs|
cmd = sanitize_text(cmd)
- run_simple(cmd, true, secs && secs.to_i)
+ run_simple(cmd, fail_on_error: true, exit_timeout: secs && secs.to_i)
end
When(/^I run "([^"]*)" interactively$/) do |cmd|
diff --git a/lib/aruba/errors.rb b/lib/aruba/errors.rb
index 2e2c6d9..10d9cde 100644
--- a/lib/aruba/errors.rb
+++ b/lib/aruba/errors.rb
@@ -16,9 +16,16 @@ module Aruba
# Raised if one tries to access last command started, but no command
# has been started
- class NoCommandHasBeenStartedError < StandardError; end
+ class NoCommandHasBeenStartedError < Error; end
# Raised if one tries to access last command stopped, but no command
# has been stopped
- class NoCommandHasBeenStoppedError < StandardError; end
+ class NoCommandHasBeenStoppedError < Error; end
+
+ # Raised if one looked for a command, but no matching was found
+ class CommandNotFoundError < ArgumentError; end
+
+ # Raised if command was already started, otherwise aruba forgets about the
+ # previous pid and you've got hidden commands run
+ class CommandAlreadyStartedError < Error; end
end
diff --git a/lib/aruba/events.rb b/lib/aruba/events.rb
index ff111bd..5ea34f9 100644
--- a/lib/aruba/events.rb
+++ b/lib/aruba/events.rb
@@ -1,13 +1,39 @@
-require 'aruba/events/basic_event'
-
+# Aruba
module Aruba
+ # Events
module Events
+ # Basic event
+ #
+ # This is not meant for direct use - BasicEvent.new - by users. It is inherited by normal events
+ #
+ # @private
+ class BasicEvent
+ attr_reader :entity
+
+ def initialize(entity)
+ @entity = entity
+ end
+ end
+
+ # Command was stopped
class CommandStopped < BasicEvent; end
+
+ # Command was started
class CommandStarted < BasicEvent; end
+
+ # An environment variable was changed
class ChangedEnvironmentVariable < BasicEvent; end
+
+ # An environment variable was added
class AddedEnvironmentVariable < BasicEvent; end
+
+ # An environment variable was deleted
class DeletedEnvironmentVariable < BasicEvent; end
+
+ # The working directory has changed
class ChangedWorkingDirectory < BasicEvent; end
+
+ # The configuration was changed
class ChangedConfiguration < BasicEvent; end
end
end
diff --git a/lib/aruba/events/basic_event.rb b/lib/aruba/events/basic_event.rb
deleted file mode 100644
index ed2b61f..0000000
--- a/lib/aruba/events/basic_event.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-module Aruba
- module Events
- class BasicEvent
- attr_reader :entity
-
- def initialize(entity)
- @entity = entity
- end
- end
- end
-end
diff --git a/lib/aruba/events/command_stopped.rb b/lib/aruba/events/command_stopped.rb
deleted file mode 100644
index bba306f..0000000
--- a/lib/aruba/events/command_stopped.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module Aruba
- module Events
- class CommandStopped < BasicEvent; end
- end
-end
diff --git a/lib/aruba/extensions/string/strip.rb b/lib/aruba/extensions/string/strip.rb
index 95a5094..d15a6eb 100644
--- a/lib/aruba/extensions/string/strip.rb
+++ b/lib/aruba/extensions/string/strip.rb
@@ -1,3 +1,4 @@
+# String
class String
# Strips indentation in heredocs.
#
diff --git a/lib/aruba/file_size.rb b/lib/aruba/file_size.rb
index ed734e9..0c7d07d 100644
--- a/lib/aruba/file_size.rb
+++ b/lib/aruba/file_size.rb
@@ -1,6 +1,8 @@
require 'delegate'
+# Aruba
module Aruba
+ # File Size
class FileSize
include Comparable
@@ -10,41 +12,50 @@ module Aruba
public
+ # Create file size object
def initialize(bytes)
@bytes = bytes
@divisor = 1024
end
+ # Convert to bytes
def to_byte
bytes
end
alias_method :to_i, :to_byte
+ # Convert to float
def to_f
to_i.to_f
end
+ # Convert to string
def to_s
to_i.to_s
end
alias_method :inspect, :to_s
+ # Move to other
def coerce(other)
[bytes, other]
end
+ # Convert to kibi byte
def to_kibi_byte
to_byte.to_f / divisor
end
+ # Convert to mebi byte
def to_mebi_byte
to_kibi_byte.to_f / divisor
end
+ # Convert to gibi byte
def to_gibi_byte
to_mebi_byte.to_f / divisor
end
+ # Compare size with other size
def <=>(other)
to_i <=> other.to_i
end
diff --git a/lib/aruba/hooks.rb b/lib/aruba/hooks.rb
index c807865..ca73ce3 100644
--- a/lib/aruba/hooks.rb
+++ b/lib/aruba/hooks.rb
@@ -1,3 +1,4 @@
+# Aruba
module Aruba
# Aruba Hooks
class Hooks
@@ -7,6 +8,7 @@ module Aruba
public
+ # Create store
def initialize
@store = {}
end
diff --git a/lib/aruba/in_config_wrapper.rb b/lib/aruba/in_config_wrapper.rb
index 05217fb..3fcd935 100644
--- a/lib/aruba/in_config_wrapper.rb
+++ b/lib/aruba/in_config_wrapper.rb
@@ -1,4 +1,11 @@
+# Aruba
module Aruba
+ # In config wrapper
+ #
+ # Used to make the configuration read only if one needs to access an
+ # configuration option from with `Aruba::Config`.
+ #
+ # @private
class InConfigWrapper
attr_reader :config
private :config
diff --git a/lib/aruba/in_process.rb b/lib/aruba/in_process.rb
index cb0f8dc..93737a7 100644
--- a/lib/aruba/in_process.rb
+++ b/lib/aruba/in_process.rb
@@ -1,7 +1,9 @@
require 'aruba/processes/in_process'
require 'aruba/platform'
+# Aruba
module Aruba
+ # @deprecated
class InProcess < Aruba::Processes::InProcess
def initialize(*args)
Aruba.platform.deprecated('The use of "Aruba::InProcess" is deprecated. Use "Aruba::Processes::InProcess" instead.')
diff --git a/lib/aruba/initializer.rb b/lib/aruba/initializer.rb
index 830603c..a073824 100644
--- a/lib/aruba/initializer.rb
+++ b/lib/aruba/initializer.rb
@@ -1,11 +1,19 @@
require 'thor/group'
require 'thor/actions'
+# Aruba
module Aruba
+ # Initializers
+ #
+ # Initialize project with aruba configuration files
module Initializers
+ # Common initializer
+ #
+ # @private
class CommonInitializer < Thor::Group
include Thor::Actions
+ # Add gem to gemfile
def add_gem
file = 'Gemfile'
creator = if File.exist? file
@@ -25,8 +33,15 @@ module Aruba
end
end
+# Aruba
module Aruba
+ # Initializers
module Initializers
+ # Default Initializer
+ #
+ # This handles invalid values for initializer.
+ #
+ # @private
class FailingInitializer
class << self
def match?(*)
@@ -41,8 +56,13 @@ module Aruba
end
end
+# Aruba
module Aruba
+ # Initializer
module Initializers
+ # Add aruba + rspec to project
+ #
+ # @private
class RSpecInitializer < Thor::Group
include Thor::Actions
@@ -82,8 +102,13 @@ EOS
end
end
+# Aruba
module Aruba
+ # Initializer
module Initializers
+ # Add aruba + aruba to project
+ #
+ # @private
class CucumberInitializer < Thor::Group
include Thor::Actions
@@ -102,8 +127,13 @@ EOS
end
end
+# Aruba
module Aruba
+ # Initializer
module Initializers
+ # Add aruba + minitest to project
+ #
+ # @private
class MiniTestInitializer < Thor::Group
include Thor::Actions
@@ -155,7 +185,13 @@ EOS
end
end
+# Aruba
module Aruba
+ # The whole initializer
+ #
+ # This one uses the specific initializers to generate the needed files.
+ #
+ # @private
class Initializer
private
@@ -171,6 +207,7 @@ module Aruba
@initializers << Initializers::FailingInitializer
end
+ # Create files etc.
def call(test_framework)
begin
initializers.find { |i| i.match? test_framework }.start [], {}
diff --git a/lib/aruba/matchers/base/base_matcher.rb b/lib/aruba/matchers/base/base_matcher.rb
index e0106bf..f0bf9c2 100644
--- a/lib/aruba/matchers/base/base_matcher.rb
+++ b/lib/aruba/matchers/base/base_matcher.rb
@@ -1,6 +1,8 @@
require 'aruba/matchers/base/object_formatter'
+# Aruba
module Aruba
+ # Matchers
module Matchers
# Base Matcher
class BaseMatcher
diff --git a/lib/aruba/matchers/base/object_formatter.rb b/lib/aruba/matchers/base/object_formatter.rb
index 72868cf..8f2602b 100644
--- a/lib/aruba/matchers/base/object_formatter.rb
+++ b/lib/aruba/matchers/base/object_formatter.rb
@@ -1,7 +1,11 @@
+# Aruba
module Aruba
+ # Matchers
module Matchers
# Provide additional output details beyond what `inspect` provides when
# printing Time, DateTime, or BigDecimal
+ #
+ # @private
module ObjectFormatter
# @api private
def self.format(object)
diff --git a/lib/aruba/matchers/collection/all.rb b/lib/aruba/matchers/collection/all.rb
index 6f10959..e9e05ad 100644
--- a/lib/aruba/matchers/collection/all.rb
+++ b/lib/aruba/matchers/collection/all.rb
@@ -1,6 +1,8 @@
require 'rspec/expectations'
+# Aruba
module Aruba
+ # Matchers
module Matchers
include ::RSpec::Matchers
diff --git a/lib/aruba/matchers/collection/include_an_object.rb b/lib/aruba/matchers/collection/include_an_object.rb
index 8324b8d..dfdfbe5 100644
--- a/lib/aruba/matchers/collection/include_an_object.rb
+++ b/lib/aruba/matchers/collection/include_an_object.rb
@@ -1,6 +1,8 @@
require 'aruba/matchers/base/base_matcher'
+# Aruba
module Aruba
+ # Matchers
module Matchers
# @api private
# Provides the implementation for `include_an_object`.
diff --git a/lib/aruba/matchers/rspec.rb b/lib/aruba/matchers/rspec.rb
deleted file mode 100644
index e69de29..0000000
diff --git a/lib/aruba/platform.rb b/lib/aruba/platform.rb
index bd794b9..8b1a753 100644
--- a/lib/aruba/platform.rb
+++ b/lib/aruba/platform.rb
@@ -2,14 +2,18 @@ require 'thread'
require 'aruba/platforms/unix_platform'
require 'aruba/platforms/windows_platform'
+# Aruba
module Aruba
PLATFORM_MUTEX = Mutex.new
end
+# Aruba
module Aruba
+ # Platform
Platform = [Platforms::WindowsPlatform, Platforms::UnixPlatform].find(&:match?)
end
+# Aruba
module Aruba
PLATFORM_MUTEX.synchronize do
@platform = Platform.new
diff --git a/lib/aruba/platforms/announcer.rb b/lib/aruba/platforms/announcer.rb
index 15118c8..1c0105f 100644
--- a/lib/aruba/platforms/announcer.rb
+++ b/lib/aruba/platforms/announcer.rb
@@ -1,9 +1,13 @@
require 'shellwords'
+# Aruba
module Aruba
+ # Platforms
module Platforms
# Announcer
#
+ # @private
+ #
# @example Activate your you own channel in cucumber
#
# Before('@announce-my-channel') do
diff --git a/lib/aruba/platforms/aruba_file_creator.rb b/lib/aruba/platforms/aruba_file_creator.rb
index c15fa3d..12a6223 100644
--- a/lib/aruba/platforms/aruba_file_creator.rb
+++ b/lib/aruba/platforms/aruba_file_creator.rb
@@ -1,7 +1,11 @@
+# Aruba
module Aruba
+ # Platforms
module Platforms
# Normal File Creator
# This class is not meant to be used directly by users.
+ #
+ # @private
class ArubaFileCreator
# Write File
#
diff --git a/lib/aruba/platforms/aruba_fixed_size_file_creator.rb b/lib/aruba/platforms/aruba_fixed_size_file_creator.rb
index 714f94a..faf03fa 100644
--- a/lib/aruba/platforms/aruba_fixed_size_file_creator.rb
+++ b/lib/aruba/platforms/aruba_fixed_size_file_creator.rb
@@ -1,4 +1,6 @@
+# Aruba
module Aruba
+ # Platforms
module Platforms
# Create files with fixed size
#
@@ -6,6 +8,8 @@ module Aruba
#
# It uses a single null byte as content and really creates so called sparse
# files.
+ #
+ # @private
class ArubaFixedSizeFileCreator
# Write File
#
diff --git a/lib/aruba/platforms/aruba_logger.rb b/lib/aruba/platforms/aruba_logger.rb
index bea69d7..2bb9ff6 100644
--- a/lib/aruba/platforms/aruba_logger.rb
+++ b/lib/aruba/platforms/aruba_logger.rb
@@ -1,6 +1,10 @@
require 'logger'
+# Aruba
module Aruba
+ # Logger
+ #
+ # @private
class ArubaLogger
attr_reader :mode
diff --git a/lib/aruba/platforms/command_monitor.rb b/lib/aruba/platforms/command_monitor.rb
index 5b102c3..644972b 100644
--- a/lib/aruba/platforms/command_monitor.rb
+++ b/lib/aruba/platforms/command_monitor.rb
@@ -1,11 +1,14 @@
require 'aruba/errors'
+# Aruba
module Aruba
# The command monitor is part of the private API of Aruba.
+ #
+ # @private
class CommandMonitor
private
- attr_reader :event_bus, :announcer
+ attr_reader :announcer
public
@@ -17,7 +20,7 @@ module Aruba
end
def method_missing(*)
- fail NoCommandHasBeenStartedError, 'No last command stopped available'
+ fail NoCommandHasBeenStoppedError, 'No last command stopped available'
end
end
@@ -27,18 +30,18 @@ module Aruba
end
def method_missing(*)
- fail NoCommandHasBeenStoppedError, 'No last command started available'
+ fail NoCommandHasBeenStartedError, 'No last command started available'
end
end
# rubocop:disable Metrics/MethodLength
def initialize(opts = {})
@registered_commands = []
- @event_bus = opts.fetch(:event_bus)
@announcer = opts.fetch(:announcer)
@last_command_stopped = DefaultLastCommandStopped.new
@last_command_started = DefaultLastCommandStarted.new
+
rescue KeyError => e
raise ArgumentError, e.message
end
@@ -56,22 +59,6 @@ module Aruba
attr_reader :last_command_stopped
end
- # Start given command
- #
- # @param [String] cmd
- # The commandline of the command
- # @param [Numeric] timeout
- # The time to wait for the command to stop
- def start_command(cmd, opts = {})
- opts[:event_bus] = event_bus
- command = Command.new(cmd, opts)
- register_command(command)
-
- command.start
-
- self
- end
-
# Set last command started
#
# @param [String] cmd
@@ -94,9 +81,9 @@ module Aruba
# This yields the found command
def find(cmd)
cmd = cmd.commandline if cmd.respond_to? :commandline
- command = registered_commands.find { |c| c.commandline == cmd }
+ command = registered_commands.reverse.find { |c| c.commandline == cmd }
- fail ArgumentError, "No command named '#{cmd}' has been started" if command.nil?
+ fail CommandNotFoundError, "No command named '#{cmd}' has been started" if command.nil?
command
end
@@ -232,9 +219,7 @@ module Aruba
command
end
- private
-
- # Register
+ # Register command to monitor
def register_command(cmd)
registered_commands << cmd
diff --git a/lib/aruba/platforms/determine_disk_usage.rb b/lib/aruba/platforms/determine_disk_usage.rb
index 74e88d8..4d35950 100644
--- a/lib/aruba/platforms/determine_disk_usage.rb
+++ b/lib/aruba/platforms/determine_disk_usage.rb
@@ -1,7 +1,12 @@
require 'aruba/platforms/disk_usage_calculator'
+# Aruba
module Aruba
+ # Platforms
module Platforms
+ # Determinate disk usage
+ #
+ # @private
class DetermineDiskUsage
def call(*args)
args = args.flatten
diff --git a/lib/aruba/platforms/determine_file_size.rb b/lib/aruba/platforms/determine_file_size.rb
index db21d6b..e9d2c63 100644
--- a/lib/aruba/platforms/determine_file_size.rb
+++ b/lib/aruba/platforms/determine_file_size.rb
@@ -1,5 +1,14 @@
+# Aruba
module Aruba
+ # Platforms
module Platforms
+ # Determine size of a file
+ #
+ # @param [String] path
+ # The path to file
+ #
+ # @return [Integer]
+ # Returns size if exists. Returns -1 if path does not exist
class DetermineFileSize
def call(path)
return -1 unless File.file? path
diff --git a/lib/aruba/platforms/disk_usage_calculator.rb b/lib/aruba/platforms/disk_usage_calculator.rb
index fe60e40..6098a86 100644
--- a/lib/aruba/platforms/disk_usage_calculator.rb
+++ b/lib/aruba/platforms/disk_usage_calculator.rb
@@ -1,8 +1,17 @@
require 'aruba/file_size'
+# Aruba
module Aruba
+ # Platforms
module Platforms
+ # Calculate disk usage
class DiskUsageCalculator
+ # Calc
+ #
+ # @param [Integer] blocks
+ # Count of blocks
+ # @param [Integer] block_size
+ # The size of a single block
def call(blocks, block_size)
Aruba::FileSize.new(blocks * block_size)
end
diff --git a/lib/aruba/platforms/local_environment.rb b/lib/aruba/platforms/local_environment.rb
index 5dfeda1..31cbec2 100644
--- a/lib/aruba/platforms/local_environment.rb
+++ b/lib/aruba/platforms/local_environment.rb
@@ -1,6 +1,18 @@
+# Aruba
module Aruba
+ # Platforms
module Platforms
+ # Local environemnt
+ #
+ # Wraps logic to make enviroment local and restorable
class LocalEnvironment
+ # Run in environment
+ #
+ # @param [Hash] env
+ # The environment
+ #
+ # @yield
+ # The block of code which should with local ENV
def call(env, &block)
old_env = ENV.to_hash.dup
diff --git a/lib/aruba/platforms/simple_table.rb b/lib/aruba/platforms/simple_table.rb
index b5c88e7..5168cc9 100644
--- a/lib/aruba/platforms/simple_table.rb
+++ b/lib/aruba/platforms/simple_table.rb
@@ -1,5 +1,8 @@
+# Aruba
module Aruba
+ # Platforms
module Platforms
+ # Generate simple table
class SimpleTable
private
@@ -7,10 +10,18 @@ module Aruba
public
+ # Create
+ #
+ # @param [Hash] hash
+ # Input
def initialize(hash)
@hash = hash
end
+ # Generate table
+ #
+ # @return [String]
+ # The table
def to_s
longest_key = hash.keys.map(&:to_s).max_by(&:length)
return [] if longest_key.nil?
diff --git a/lib/aruba/platforms/unix_command_string.rb b/lib/aruba/platforms/unix_command_string.rb
index 4c864b9..3fca29c 100644
--- a/lib/aruba/platforms/unix_command_string.rb
+++ b/lib/aruba/platforms/unix_command_string.rb
@@ -1,7 +1,9 @@
require 'delegate'
require 'shellwords'
+# Aruba
module Aruba
+ # Platforms
module Platforms
# This is a command which should be run
class UnixCommandString < SimpleDelegator
@@ -9,6 +11,7 @@ module Aruba
__setobj__ cmd
end
+ # Convert to array
def to_a
Shellwords.split __getobj__
end
diff --git a/lib/aruba/platforms/unix_environment_variables.rb b/lib/aruba/platforms/unix_environment_variables.rb
index 4f8286d..e619af2 100644
--- a/lib/aruba/platforms/unix_environment_variables.rb
+++ b/lib/aruba/platforms/unix_environment_variables.rb
@@ -1,5 +1,8 @@
+# Aruba
module Aruba
+ # Platforms
module Platforms
+ # Abstract environment variables
class UnixEnvironmentVariables
# We need to use this, because `nil` is a valid value as default
UNDEFINED = Object.new.freeze
diff --git a/lib/aruba/platforms/unix_platform.rb b/lib/aruba/platforms/unix_platform.rb
index 6f5d88a..48d94fb 100644
--- a/lib/aruba/platforms/unix_platform.rb
+++ b/lib/aruba/platforms/unix_platform.rb
@@ -15,6 +15,7 @@ require 'aruba/platforms/aruba_logger'
require 'aruba/platforms/announcer'
require 'aruba/platforms/command_monitor'
+# Aruba
module Aruba
# This abstracts OS-specific things
module Platforms
@@ -25,6 +26,8 @@ module Aruba
# any further notice.
#
# This includes all methods for the UNIX platform
+ #
+ # @private
class UnixPlatform
def self.match?
!FFI::Platform.windows?
diff --git a/lib/aruba/platforms/unix_which.rb b/lib/aruba/platforms/unix_which.rb
index eff34fd..b9899d6 100644
--- a/lib/aruba/platforms/unix_which.rb
+++ b/lib/aruba/platforms/unix_which.rb
@@ -1,8 +1,12 @@
require 'aruba/platform'
+# Aruba
module Aruba
+ # Platforms
module Platforms
# Implement `which(command)` for UNIX/Linux
+ #
+ # @private
class UnixWhich
# Bail out because this should never be reached
class DefaultWhich
diff --git a/lib/aruba/platforms/windows_command_string.rb b/lib/aruba/platforms/windows_command_string.rb
index 2298194..4b13a8c 100644
--- a/lib/aruba/platforms/windows_command_string.rb
+++ b/lib/aruba/platforms/windows_command_string.rb
@@ -1,13 +1,20 @@
require 'delegate'
+# Aruba
module Aruba
+ # Platforms
module Platforms
# This is a command which should be run
+ #
+ # This adds `cmd.exec` in front of commmand
+ #
+ # @private
class WindowsCommandString < SimpleDelegator
def initialize(cmd)
__setobj__ format('%s /c "%s"', Aruba.platform.which('cmd.exe'), cmd)
end
+ # Convert to array
def to_a
Shellwords.split __getobj__
end
diff --git a/lib/aruba/platforms/windows_environment_variables.rb b/lib/aruba/platforms/windows_environment_variables.rb
index 7a81da5..c2247c7 100644
--- a/lib/aruba/platforms/windows_environment_variables.rb
+++ b/lib/aruba/platforms/windows_environment_variables.rb
@@ -1,6 +1,8 @@
require 'aruba/platforms/unix_environment_variables'
+# Aruba
module Aruba
+ # Platforms
module Platforms
# Windows is case-insensitive when it accesses its environment variables.
# That means that at the Windows command line:
diff --git a/lib/aruba/platforms/windows_platform.rb b/lib/aruba/platforms/windows_platform.rb
index bd4f55b..cf8bc8c 100644
--- a/lib/aruba/platforms/windows_platform.rb
+++ b/lib/aruba/platforms/windows_platform.rb
@@ -5,6 +5,7 @@ require 'aruba/platforms/windows_command_string'
require 'aruba/platforms/windows_environment_variables'
require 'aruba/platforms/windows_which'
+# Aruba
module Aruba
# This abstracts OS-specific things
module Platforms
@@ -15,6 +16,8 @@ module Aruba
# any further notice.
#
# This includes all methods for the Windows platform
+ #
+ # @private
class WindowsPlatform < UnixPlatform
def self.match?
FFI::Platform.windows?
diff --git a/lib/aruba/platforms/windows_which.rb b/lib/aruba/platforms/windows_which.rb
index 272c1ba..3986ecf 100644
--- a/lib/aruba/platforms/windows_which.rb
+++ b/lib/aruba/platforms/windows_which.rb
@@ -1,8 +1,12 @@
require 'aruba/platform'
+# Aruba
module Aruba
+ # Platforms
module Platforms
# Implement `which(command)` for windows
+ #
+ # @private
class WindowsWhich
# Bail out because this should never be reached
class DefaultWhich
diff --git a/lib/aruba/processes/basic_process.rb b/lib/aruba/processes/basic_process.rb
index dfd28a9..f607e91 100644
--- a/lib/aruba/processes/basic_process.rb
+++ b/lib/aruba/processes/basic_process.rb
@@ -1,7 +1,9 @@
require 'aruba/platform'
require 'shellwords'
+# Aruba
module Aruba
+ # Processes
module Processes
# Basic Process
#
@@ -22,6 +24,8 @@ module Aruba
@exit_timeout = exit_timeout
@io_wait_timeout = io_wait_timeout
+
+ @started = false
end
# Return command line
@@ -67,9 +71,20 @@ module Aruba
NotImplementedError
end
+ # Restart a command
+ def restart
+ stop
+ start
+ end
+
# Was process already stopped
def stopped?
- @stopped == true
+ @started == false
+ end
+
+ # Was process already started
+ def started?
+ @started == true
end
# Does the process failed to stop in time
diff --git a/lib/aruba/processes/debug_process.rb b/lib/aruba/processes/debug_process.rb
index afb7cc9..2be85d4 100644
--- a/lib/aruba/processes/debug_process.rb
+++ b/lib/aruba/processes/debug_process.rb
@@ -1,6 +1,8 @@
require 'aruba/processes/spawn_process'
+# Aruba
module Aruba
+ # Processes
module Processes
# Run your command in `systemd()` to make debugging it easier
#
@@ -57,7 +59,7 @@ module Aruba
# Stop process
def stop(*)
- @stopped = true
+ @started = false
@exit_status
end
diff --git a/lib/aruba/processes/in_process.rb b/lib/aruba/processes/in_process.rb
index d8c1104..6b250bb 100644
--- a/lib/aruba/processes/in_process.rb
+++ b/lib/aruba/processes/in_process.rb
@@ -3,7 +3,9 @@ require 'stringio'
require 'aruba/processes/basic_process'
require 'aruba/platform'
+# Aruba
module Aruba
+ # Platforms
module Processes
# Run command in your ruby process
#
@@ -20,6 +22,9 @@ module Aruba
attr_reader :exit_status
+ # Fake Kernel module of ruby
+ #
+ # @private
class FakeKernel
attr_reader :exitstatus
@@ -51,6 +56,7 @@ module Aruba
super
end
+ # Start command
def start
fail "You need to call aruba.config.main_class = YourMainClass" unless main_class
@@ -67,33 +73,43 @@ module Aruba
end
end
+ # Stop command
def stop(*)
- @stopped = true
+ @started = false
@exit_status = @kernel.exitstatus
end
+ # Access stdin
def stdin
@stdin.string
end
+ # Access stdout
def stdout(*)
@stdout.string
end
+ # Access stderr
def stderr(*)
@stderr.string
end
+ # Write strint to stdin
+ #
+ # @param [String] input
+ # Write string to stdin in
def write(input)
@stdin.write input
end
+ # Close io
def close_io(name)
fail ArgumentError, 'Only stdin stdout and stderr are allowed to close' unless [:stdin, :stdout, :stderr].include? name
get_instance_variable(name.to_sym).close
end
+ # Terminate program
def terminate
stop
end
diff --git a/lib/aruba/processes/spawn_process.rb b/lib/aruba/processes/spawn_process.rb
index b3e86f5..33ec7d9 100644
--- a/lib/aruba/processes/spawn_process.rb
+++ b/lib/aruba/processes/spawn_process.rb
@@ -6,7 +6,9 @@ require 'aruba/errors'
require 'aruba/processes/basic_process'
require 'aruba/platform'
+# Aruba
module Aruba
+ # Platforms
module Processes
# Spawn a process for command
#
@@ -50,6 +52,12 @@ module Aruba
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/CyclomaticComplexity
def start
+ # rubocop:disable Metrics/LineLength
+ fail CommandAlreadyStartedError, %(Command "#{commandline}" has already been started. Please `#stop` the command first and `#start` it again. Alternatively use `#restart`.\n#{caller.join("\n")}) if started?
+ # rubocop:enable Metrics/LineLength
+
+ @started = true
+
# gather fully qualified path
cmd = Aruba.platform.which(command, environment['PATH'])
@@ -157,6 +165,7 @@ module Aruba
self
end
+ # Close io
def close_io(name)
return if stopped?
@@ -167,7 +176,7 @@ module Aruba
end
end
- # rubocop:disable Metrics/MethodLength
+ # Stop command
def stop(*)
return @exit_status if stopped?
@@ -179,7 +188,6 @@ module Aruba
terminate
end
- # rubocop:enable Metrics/MethodLength
# Wait for command to finish
def wait
@@ -209,7 +217,7 @@ module Aruba
# @stdout_file = nil
# @stderr_file = nil
- @stopped = true
+ @started = false
@exit_status
end
diff --git a/lib/aruba/rspec.rb b/lib/aruba/rspec.rb
index ca5ca90..6b13352 100644
--- a/lib/aruba/rspec.rb
+++ b/lib/aruba/rspec.rb
@@ -21,6 +21,9 @@ RSpec.configure do |config|
end
example.run
+
+ next unless self.class.include? Aruba::Api
+ stop_all_commands
end
if Aruba::VERSION >= '1.0.0'
diff --git a/lib/aruba/runtime.rb b/lib/aruba/runtime.rb
index 2b3ae15..e87216c 100644
--- a/lib/aruba/runtime.rb
+++ b/lib/aruba/runtime.rb
@@ -5,8 +5,38 @@ require 'aruba/events'
require 'event/bus'
module Aruba
+ # Runtime of aruba
+ #
+ # Most methods are considered private. Please look for `(private)` in the
+ # attribute descriptions. Only a few like `#current_directory`,
+ # '#root_directory` and `#config` are considered to be part of the public
+ # API.
class Runtime
+ # @!attribute [r] current_directory
+ # Returns the current working directory
+ #
+ # @!attribute [r] root_directory
+ # Returns the root directory of aruba
attr_reader :current_directory, :root_directory
+
+ # @!attribute [r] config
+ # Access configuration of aruba
+ #
+ # @!attribute [r] environment
+ # Access environment of aruba (private)
+ #
+ # @!attribute [r] logger
+ # Logger of aruba (private)
+ #
+ # @!attribute [r] command_monitor
+ # Handler started commands (private)
+ #
+ # @!attribute [r] announcer
+ # Announce information
+ #
+ # @!attribute [r] event_bus
+ # Handle events (private)
+ #
attr_accessor :config, :environment, :logger, :command_monitor, :announcer, :event_bus
def initialize(opts = {})
@@ -19,9 +49,9 @@ module Aruba
@root_directory = ArubaPath.new(@config.root_directory)
if Aruba::VERSION < '1'
- @command_monitor = opts.fetch(:command_monitor, Aruba.platform.command_monitor.new(event_bus: @event_bus, announcer: @announcer))
+ @command_monitor = opts.fetch(:command_monitor, Aruba.platform.command_monitor.new(:announcer => @announcer))
else
- @command_monitor = opts.fetch(:command_monitor, Aruba.platform.command_monitor.new(event_bus: @event_bus))
+ @command_monitor = opts.fetch(:command_monitor, Aruba.platform.command_monitor.new)
end
@logger = opts.fetch(:logger, Aruba.platform.logger.new)
diff --git a/lib/aruba/setup.rb b/lib/aruba/setup.rb
index 18ea633..df9e917 100644
--- a/lib/aruba/setup.rb
+++ b/lib/aruba/setup.rb
@@ -44,6 +44,7 @@ module Aruba
runtime.event_bus.register(
:command_started,
->(event) do
+ runtime.command_monitor.register_command event.entity
runtime.command_monitor.last_command_started = event.entity
end
)
diff --git a/spec/aruba/api_spec.rb b/spec/aruba/api_spec.rb
index de4753f..1d5910a 100644
--- a/spec/aruba/api_spec.rb
+++ b/spec/aruba/api_spec.rb
@@ -1151,7 +1151,7 @@ describe Aruba::Api do
end
it "raises a descriptive exception" do
- expect { @aruba.get_process("false") }.to raise_error ArgumentError, "No command named 'false' has been started"
+ expect { @aruba.get_process("false") }.to raise_error CommandNotFoundError, "No command named 'false' has been started"
end
end
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-aruba.git
More information about the Pkg-ruby-extras-commits
mailing list