aruba-win-fix 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +37 -0
- data/.rspec +3 -0
- data/.rubocop.yml +188 -0
- data/.simplecov +34 -0
- data/.travis.yml +47 -0
- data/.yardopts +8 -0
- data/CONTRIBUTING.md +71 -0
- data/Gemfile +83 -0
- data/History.md +579 -0
- data/LICENSE +20 -0
- data/README.md +226 -0
- data/Rakefile +49 -0
- data/TODO.md +13 -0
- data/appveyor.yml +32 -0
- data/aruba.gemspec +48 -0
- data/bin/aruba +7 -0
- data/config/.gitignore +1 -0
- data/cucumber.yml +26 -0
- data/features/.nav +72 -0
- data/features/api/command/find_command.feature +83 -0
- data/features/api/command/last_command_started.feature +50 -0
- data/features/api/command/last_command_stopped.feature +89 -0
- data/features/api/command/run.feature +414 -0
- data/features/api/command/run_simple.feature +242 -0
- data/features/api/command/send_signal.feature +53 -0
- data/features/api/command/stderr.feature +46 -0
- data/features/api/command/stdout.feature +46 -0
- data/features/api/command/stop.feature +131 -0
- data/features/api/command/stop_all_commands.feature +53 -0
- data/features/api/command/terminate_all_commands.feature +53 -0
- data/features/api/command/which.feature +37 -0
- data/features/api/core/expand_path.feature +88 -0
- data/features/api/environment/append_environment_variable.feature +128 -0
- data/features/api/environment/delete_environment_variable.feature +63 -0
- data/features/api/environment/prepend_environment_variable.feature +128 -0
- data/features/api/environment/set_environment_variable.feature +376 -0
- data/features/api/filesystem/cd.feature +184 -0
- data/features/api/filesystem/create_directory.feature +57 -0
- data/features/api/filesystem/disk_usage.feature +152 -0
- data/features/api/filesystem/does_exist.feature +62 -0
- data/features/api/filesystem/fixtures.feature +104 -0
- data/features/api/filesystem/is_absolute.feature +48 -0
- data/features/api/filesystem/is_directory.feature +53 -0
- data/features/api/filesystem/is_file.feature +54 -0
- data/features/api/filesystem/is_relative.feature +48 -0
- data/features/api/filesystem/move.feature +119 -0
- data/features/api/text/extract_text.feature +87 -0
- data/features/api/text/replace_variables.feature +45 -0
- data/features/api/text/sanitize_text.feature +228 -0
- data/features/api/text/unescape_text.feature +127 -0
- data/features/cli/console.feature +52 -0
- data/features/cli/init.feature +79 -0
- data/features/configuration/activate_announcer_on_command_failure.feature +38 -0
- data/features/configuration/command_runtime_environment.feature +129 -0
- data/features/configuration/console_history_file.feature +38 -0
- data/features/configuration/exit_timeout.feature +52 -0
- data/features/configuration/fixtures_directories.feature +38 -0
- data/features/configuration/fixtures_path_prefix.feature +23 -0
- data/features/configuration/home_directory.feature +80 -0
- data/features/configuration/io_timeout.feature +30 -0
- data/features/configuration/keep_ansi.feature +30 -0
- data/features/configuration/log_level.feature +38 -0
- data/features/configuration/physical_block_size.feature +53 -0
- data/features/configuration/remove_ansi_escape_sequences.feature +38 -0
- data/features/configuration/root_directory.feature +30 -0
- data/features/configuration/startup_wait_time.feature +48 -0
- data/features/configuration/usage.feature +159 -0
- data/features/configuration/working_directory.feature +33 -0
- data/features/development/build.feature +15 -0
- data/features/development/test.feature +24 -0
- data/features/getting_started/cleanup.feature +67 -0
- data/features/getting_started/install.feature +8 -0
- data/features/getting_started/run_commands.feature +177 -0
- data/features/getting_started/supported_testing_frameworks.feature +104 -0
- data/features/getting_started/writing_good_feature_tests.feature +38 -0
- data/features/hooks/after/command.feature +44 -0
- data/features/hooks/before/command.feature +71 -0
- data/features/matchers/collection/include_an_object.feature +72 -0
- data/features/matchers/directory/have_sub_directory.feature +110 -0
- data/features/matchers/file/be_a_command_found_in_path.feature +115 -0
- data/features/matchers/file/be_existing_executable.feature +88 -0
- data/features/matchers/file/be_existing_file.feature +82 -0
- data/features/matchers/file/have_file_content.feature +123 -0
- data/features/matchers/file/have_file_size.feature +107 -0
- data/features/matchers/path/be_an_absolute_path.feature +74 -0
- data/features/matchers/path/be_an_existing_path.feature +97 -0
- data/features/matchers/path/have_permissions.feature +118 -0
- data/features/matchers/timeouts.feature +48 -0
- data/features/platforms/jruby.feature +14 -0
- data/features/rspec/integration.feature +179 -0
- data/features/step_definitions/aruba_dev_steps.rb +56 -0
- data/features/step_definitions/hooks.rb +96 -0
- data/features/steps/command/debug.feature +92 -0
- data/features/steps/command/exit_statuses.feature +136 -0
- data/features/steps/command/in_process.feature +485 -0
- data/features/steps/command/interactive.feature +90 -0
- data/features/steps/command/output.feature +588 -0
- data/features/steps/command/run.feature +66 -0
- data/features/steps/command/send_signal.feature +104 -0
- data/features/steps/command/shell.feature +155 -0
- data/features/steps/command/stderr.feature +68 -0
- data/features/steps/command/stdout.feature +109 -0
- data/features/steps/command/stop.feature +313 -0
- data/features/steps/core/announce.feature +283 -0
- data/features/steps/environment/append_environment_variable.feature +52 -0
- data/features/steps/environment/home_variable.feature +62 -0
- data/features/steps/environment/prepend_environment_variable.feature +52 -0
- data/features/steps/environment/set_environment_variable.feature +49 -0
- data/features/steps/filesystem/append_to_file.feature +45 -0
- data/features/steps/filesystem/cd_to_directory.feature +33 -0
- data/features/steps/filesystem/check_file_content.feature +61 -0
- data/features/steps/filesystem/check_permissions_of_file.feature +39 -0
- data/features/steps/filesystem/compare_files.feature +42 -0
- data/features/steps/filesystem/copy.feature +45 -0
- data/features/steps/filesystem/create_directory.feature +57 -0
- data/features/steps/filesystem/create_file.feature +76 -0
- data/features/steps/filesystem/existence_of_directory.feature +57 -0
- data/features/steps/filesystem/existence_of_file.feature +43 -0
- data/features/steps/filesystem/file_content.feature +86 -0
- data/features/steps/filesystem/fixtures.feature +64 -0
- data/features/steps/filesystem/move.feature +45 -0
- data/features/steps/filesystem/non_existence_of_directory.feature +69 -0
- data/features/steps/filesystem/non_existence_of_file.feature +80 -0
- data/features/steps/filesystem/overwrite_file.feature +72 -0
- data/features/steps/filesystem/remove_directory.feature +38 -0
- data/features/steps/filesystem/remove_file.feature +38 -0
- data/features/steps/filesystem/use_fixture.feature +77 -0
- data/features/steps/overview.feature +60 -0
- data/features/support/aruba.rb +7 -0
- data/features/support/env.rb +33 -0
- data/features/support/jruby.rb +5 -0
- data/features/support/simplecov_setup.rb +8 -0
- data/fixtures/cli-app/.gitignore +9 -0
- data/fixtures/cli-app/.rspec +2 -0
- data/fixtures/cli-app/README.md +39 -0
- data/fixtures/cli-app/Rakefile +1 -0
- data/fixtures/cli-app/bin/cli +6 -0
- data/fixtures/cli-app/cli-app.gemspec +26 -0
- data/fixtures/cli-app/features/support/env.rb +1 -0
- data/fixtures/cli-app/lib/cli/app.rb +13 -0
- data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +15 -0
- data/fixtures/cli-app/lib/cli/app/version.rb +5 -0
- data/fixtures/cli-app/script/console +14 -0
- data/fixtures/cli-app/spec/spec_helper.rb +9 -0
- data/fixtures/cli-app/spec/support/aruba.rb +1 -0
- data/fixtures/copy/file.txt +1 -0
- data/fixtures/empty-app/.gitignore +9 -0
- data/fixtures/empty-app/.rspec +2 -0
- data/fixtures/empty-app/README.md +24 -0
- data/fixtures/empty-app/Rakefile +1 -0
- data/fixtures/empty-app/cli-app.gemspec +26 -0
- data/fixtures/empty-app/lib/cli/app.rb +13 -0
- data/fixtures/empty-app/lib/cli/app/version.rb +5 -0
- data/fixtures/getting-started-app/.gitignore +4 -0
- data/fixtures/getting-started-app/Gemfile +4 -0
- data/fixtures/getting-started-app/README.md +3 -0
- data/fixtures/getting-started-app/features/support/env.rb +1 -0
- data/fixtures/spawn_process/stderr.sh +3 -0
- data/lib/aruba.rb +1 -0
- data/lib/aruba/api.rb +34 -0
- data/lib/aruba/api/command.rb +307 -0
- data/lib/aruba/api/core.rb +191 -0
- data/lib/aruba/api/deprecated.rb +897 -0
- data/lib/aruba/api/environment.rb +89 -0
- data/lib/aruba/api/filesystem.rb +392 -0
- data/lib/aruba/api/rvm.rb +44 -0
- data/lib/aruba/api/text.rb +56 -0
- data/lib/aruba/aruba_path.rb +133 -0
- data/lib/aruba/basic_configuration.rb +240 -0
- data/lib/aruba/basic_configuration/option.rb +32 -0
- data/lib/aruba/cli.rb +26 -0
- data/lib/aruba/colorizer.rb +108 -0
- data/lib/aruba/command.rb +74 -0
- data/lib/aruba/config.rb +108 -0
- data/lib/aruba/config/jruby.rb +17 -0
- data/lib/aruba/config_wrapper.rb +58 -0
- data/lib/aruba/console.rb +70 -0
- data/lib/aruba/console/help.rb +35 -0
- data/lib/aruba/contracts/absolute_path.rb +20 -0
- data/lib/aruba/contracts/enum.rb +26 -0
- data/lib/aruba/contracts/is_power_of_two.rb +22 -0
- data/lib/aruba/contracts/relative_path.rb +20 -0
- data/lib/aruba/cucumber.rb +13 -0
- data/lib/aruba/cucumber/command.rb +422 -0
- data/lib/aruba/cucumber/core.rb +5 -0
- data/lib/aruba/cucumber/environment.rb +42 -0
- data/lib/aruba/cucumber/file.rb +201 -0
- data/lib/aruba/cucumber/hooks.rb +160 -0
- data/lib/aruba/cucumber/rvm.rb +3 -0
- data/lib/aruba/cucumber/testing_frameworks.rb +95 -0
- data/lib/aruba/errors.rb +37 -0
- data/lib/aruba/event_bus.rb +59 -0
- data/lib/aruba/event_bus/name_resolver.rb +168 -0
- data/lib/aruba/events.rb +39 -0
- data/lib/aruba/extensions/string/strip.rb +25 -0
- data/lib/aruba/file_size.rb +63 -0
- data/lib/aruba/generators/script_file.rb +46 -0
- data/lib/aruba/hooks.rb +56 -0
- data/lib/aruba/in_config_wrapper.rb +24 -0
- data/lib/aruba/in_process.rb +14 -0
- data/lib/aruba/initializer.rb +222 -0
- data/lib/aruba/jruby.rb +4 -0
- data/lib/aruba/matchers/base/base_matcher.rb +96 -0
- data/lib/aruba/matchers/base/object_formatter.rb +114 -0
- data/lib/aruba/matchers/collection.rb +1 -0
- data/lib/aruba/matchers/collection/all.rb +11 -0
- data/lib/aruba/matchers/collection/include_an_object.rb +122 -0
- data/lib/aruba/matchers/command.rb +1 -0
- data/lib/aruba/matchers/command/be_successfully_executed.rb +34 -0
- data/lib/aruba/matchers/command/have_exit_status.rb +38 -0
- data/lib/aruba/matchers/command/have_finished_in_time.rb +37 -0
- data/lib/aruba/matchers/command/have_output.rb +36 -0
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +32 -0
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +32 -0
- data/lib/aruba/matchers/command/have_output_size.rb +28 -0
- data/lib/aruba/matchers/directory.rb +1 -0
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +38 -0
- data/lib/aruba/matchers/directory/have_sub_directory.rb +53 -0
- data/lib/aruba/matchers/environment.rb +1 -0
- data/lib/aruba/matchers/file.rb +1 -0
- data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +36 -0
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +37 -0
- data/lib/aruba/matchers/file/be_an_existing_file.rb +38 -0
- data/lib/aruba/matchers/file/have_file_content.rb +62 -0
- data/lib/aruba/matchers/file/have_file_size.rb +47 -0
- data/lib/aruba/matchers/file/have_same_file_content.rb +48 -0
- data/lib/aruba/matchers/path.rb +1 -0
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +25 -0
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +36 -0
- data/lib/aruba/matchers/path/be_an_existing_path.rb +37 -0
- data/lib/aruba/matchers/path/have_permissions.rb +64 -0
- data/lib/aruba/matchers/path/match_path_pattern.rb +41 -0
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +25 -0
- data/lib/aruba/matchers/string.rb +1 -0
- data/lib/aruba/matchers/string/include_output_string.rb +36 -0
- data/lib/aruba/matchers/string/match_output_string.rb +37 -0
- data/lib/aruba/matchers/string/output_string_eq.rb +35 -0
- data/lib/aruba/platform.rb +25 -0
- data/lib/aruba/platforms/announcer.rb +232 -0
- data/lib/aruba/platforms/aruba_file_creator.rb +35 -0
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +35 -0
- data/lib/aruba/platforms/aruba_logger.rb +81 -0
- data/lib/aruba/platforms/command_monitor.rb +229 -0
- data/lib/aruba/platforms/determine_disk_usage.rb +28 -0
- data/lib/aruba/platforms/determine_file_size.rb +22 -0
- data/lib/aruba/platforms/disk_usage_calculator.rb +20 -0
- data/lib/aruba/platforms/filesystem_status.rb +68 -0
- data/lib/aruba/platforms/local_environment.rb +29 -0
- data/lib/aruba/platforms/simple_table.rb +54 -0
- data/lib/aruba/platforms/unix_command_string.rb +27 -0
- data/lib/aruba/platforms/unix_environment_variables.rb +220 -0
- data/lib/aruba/platforms/unix_platform.rb +276 -0
- data/lib/aruba/platforms/unix_which.rb +85 -0
- data/lib/aruba/platforms/windows_command_string.rb +31 -0
- data/lib/aruba/platforms/windows_environment_variables.rb +89 -0
- data/lib/aruba/platforms/windows_platform.rb +42 -0
- data/lib/aruba/platforms/windows_which.rb +106 -0
- data/lib/aruba/processes/basic_process.rb +143 -0
- data/lib/aruba/processes/debug_process.rb +69 -0
- data/lib/aruba/processes/in_process.rb +125 -0
- data/lib/aruba/processes/spawn_process.rb +278 -0
- data/lib/aruba/reporting.rb +126 -0
- data/lib/aruba/rspec.rb +107 -0
- data/lib/aruba/runtime.rb +96 -0
- data/lib/aruba/setup.rb +90 -0
- data/lib/aruba/spawn_process.rb +11 -0
- data/lib/aruba/version.rb +3 -0
- data/script/bootstrap +28 -0
- data/script/console +16 -0
- data/script/test +3 -0
- data/spec/aruba/api/environment/restore_env_spec.rb +65 -0
- data/spec/aruba/api/environment/set_env_spec.rb +42 -0
- data/spec/aruba/api/filesystem/file_size_spec.rb +28 -0
- data/spec/aruba/api/runtime_spec.rb +28 -0
- data/spec/aruba/api_spec.rb +1209 -0
- data/spec/aruba/aruba_path_spec.rb +103 -0
- data/spec/aruba/basic_configuration_spec.rb +5 -0
- data/spec/aruba/configuration_spec.rb +5 -0
- data/spec/aruba/hooks_spec.rb +17 -0
- data/spec/aruba/in_config_wrapper_spec.rb +25 -0
- data/spec/aruba/jruby_spec.rb +55 -0
- data/spec/aruba/matchers/command/have_output_size_spec.rb +25 -0
- data/spec/aruba/matchers/command_spec.rb +174 -0
- data/spec/aruba/matchers/directory_spec.rb +57 -0
- data/spec/aruba/matchers/file_spec.rb +127 -0
- data/spec/aruba/matchers/path_spec.rb +88 -0
- data/spec/aruba/platform/simple_table_spec.rb +23 -0
- data/spec/aruba/platform/windows_environment_variables_spec.rb +500 -0
- data/spec/aruba/rspec_spec.rb +15 -0
- data/spec/aruba/runtime_spec.rb +29 -0
- data/spec/aruba/spawn_process_spec.rb +60 -0
- data/spec/event_bus/name_resolver_spec.rb +68 -0
- data/spec/event_bus_spec.rb +160 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/configs/.keep +0 -0
- data/spec/support/configs/aruba.rb +5 -0
- data/spec/support/configs/pry.rb +3 -0
- data/spec/support/configs/rspec.rb +15 -0
- data/spec/support/helpers/.keep +0 -0
- data/spec/support/helpers/reporting.rb +44 -0
- data/spec/support/matchers/.keep +0 -0
- data/spec/support/matchers/option.rb +35 -0
- data/spec/support/shared_contexts/.keep +0 -0
- data/spec/support/shared_contexts/aruba.rb +48 -0
- data/spec/support/shared_examples/.keep +0 -0
- data/spec/support/shared_examples/configuration.rb +116 -0
- data/spec/support/shared_examples/directory.rb +7 -0
- data/spec/support/shared_examples/file.rb +7 -0
- data/templates/css/console.css +24 -0
- data/templates/css/filesystem.css +42 -0
- data/templates/css/pygments-autumn.css +59 -0
- data/templates/files.erb +14 -0
- data/templates/images/LICENSE +22 -0
- data/templates/images/folder.png +0 -0
- data/templates/images/page_white.png +0 -0
- data/templates/images/page_white_gherkin.png +0 -0
- data/templates/images/page_white_ruby.png +0 -0
- data/templates/index.erb +20 -0
- data/templates/js/filesystem.js +5 -0
- data/templates/js/jquery-1.11.3.min.js +5 -0
- data/templates/main.erb +34 -0
- metadata +629 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'aruba/api'
|
2
|
+
|
3
|
+
# Aruba
|
4
|
+
module Aruba
|
5
|
+
# Consule
|
6
|
+
class Console
|
7
|
+
# Helpers for Aruba::Console
|
8
|
+
module Help
|
9
|
+
# Output help information
|
10
|
+
def aruba_help
|
11
|
+
puts 'Aruba Version: ' + Aruba::VERSION
|
12
|
+
puts 'Issue Tracker: ' + 'https://github.com/cucumber/aruba/issues'
|
13
|
+
puts "Documentation:\n" + %w(http://www.rubydoc.info/gems/aruba).map { |d| format('* %s', d) }.join("\n")
|
14
|
+
puts
|
15
|
+
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
19
|
+
# List available methods in aruba
|
20
|
+
def aruba_methods
|
21
|
+
ms = if RUBY_VERSION < '1.9'
|
22
|
+
# rubocop:disable Style/EachWithObject
|
23
|
+
(Aruba::Api.instance_methods - Module.instance_methods).inject([]) { |a, e| a << format("* %s", e); a }.sort
|
24
|
+
# rubocop:enable Style/EachWithObject
|
25
|
+
else
|
26
|
+
(Aruba::Api.instance_methods - Module.instance_methods).each_with_object([]) { |e, a| a << format("* %s", e) }.sort
|
27
|
+
end
|
28
|
+
|
29
|
+
puts "Available Methods:\n" + ms.join("\n")
|
30
|
+
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'aruba/aruba_path'
|
2
|
+
|
3
|
+
# Aruba
|
4
|
+
module Aruba
|
5
|
+
# Contracts
|
6
|
+
module Contracts
|
7
|
+
# Check if path is absolute
|
8
|
+
class AbsolutePath
|
9
|
+
# Check
|
10
|
+
#
|
11
|
+
# @param [Object] value
|
12
|
+
# The value to be checked
|
13
|
+
def self.valid?(value)
|
14
|
+
ArubaPath.new(value).absolute?
|
15
|
+
rescue
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'contracts'
|
2
|
+
|
3
|
+
# Aruba
|
4
|
+
module Aruba
|
5
|
+
# Contracts
|
6
|
+
module Contracts
|
7
|
+
# Enum
|
8
|
+
class Enum < ::Contracts::CallableClass
|
9
|
+
private
|
10
|
+
|
11
|
+
attr_reader :vals
|
12
|
+
|
13
|
+
public
|
14
|
+
|
15
|
+
# Create contract
|
16
|
+
def initialize(*vals)
|
17
|
+
@vals = vals
|
18
|
+
end
|
19
|
+
|
20
|
+
# Check if value is part of array
|
21
|
+
def valid?(val)
|
22
|
+
vals.include? val
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'aruba/aruba_path'
|
2
|
+
|
3
|
+
# Aruba
|
4
|
+
module Aruba
|
5
|
+
# Contracts
|
6
|
+
module Contracts
|
7
|
+
# Is value power of two
|
8
|
+
class IsPowerOfTwo
|
9
|
+
# Check value
|
10
|
+
#
|
11
|
+
# @param [Integer] value
|
12
|
+
# The value to be checked
|
13
|
+
def self.valid?(value)
|
14
|
+
# explanation for algorithm can be found here:
|
15
|
+
# http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/
|
16
|
+
value != 0 && (value & (value - 1)) == 0 ? true : false
|
17
|
+
rescue
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'aruba/aruba_path'
|
2
|
+
|
3
|
+
# Aruba
|
4
|
+
module Aruba
|
5
|
+
# Contracts
|
6
|
+
module Contracts
|
7
|
+
# Is value relative path
|
8
|
+
class RelativePath
|
9
|
+
# Check
|
10
|
+
#
|
11
|
+
# @param [String] value
|
12
|
+
# The path to be checked
|
13
|
+
def self.valid?(value)
|
14
|
+
ArubaPath.new(value).relative?
|
15
|
+
rescue
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'aruba/version'
|
2
|
+
|
3
|
+
require 'aruba/api'
|
4
|
+
World(Aruba::Api)
|
5
|
+
|
6
|
+
require 'aruba/cucumber/hooks'
|
7
|
+
require 'aruba/cucumber/command'
|
8
|
+
require 'aruba/cucumber/core'
|
9
|
+
require 'aruba/cucumber/environment'
|
10
|
+
require 'aruba/cucumber/file'
|
11
|
+
require 'aruba/cucumber/testing_frameworks'
|
12
|
+
require 'aruba/cucumber/rvm'
|
13
|
+
require 'aruba/reporting'
|
@@ -0,0 +1,422 @@
|
|
1
|
+
if Aruba::VERSION < '1.0.0'
|
2
|
+
require 'aruba/cucumber/core'
|
3
|
+
end
|
4
|
+
require 'aruba/generators/script_file'
|
5
|
+
|
6
|
+
When(/^I run "(.*)"$/)do |cmd|
|
7
|
+
warn(%{\e[35m The /^I run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
|
8
|
+
|
9
|
+
cmd = sanitize_text(cmd)
|
10
|
+
run_simple(cmd, false)
|
11
|
+
end
|
12
|
+
|
13
|
+
When(/^I run `([^`]*)`$/)do |cmd|
|
14
|
+
cmd = sanitize_text(cmd)
|
15
|
+
run_simple(cmd, :fail_on_error => false)
|
16
|
+
end
|
17
|
+
|
18
|
+
When(/^I successfully run "(.*)"$/)do |cmd|
|
19
|
+
warn(%{\e[35m The /^I successfully run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
|
20
|
+
|
21
|
+
cmd = sanitize_text(cmd)
|
22
|
+
run_simple(cmd)
|
23
|
+
end
|
24
|
+
|
25
|
+
## I successfully run `echo -n "Hello"`
|
26
|
+
## I successfully run `sleep 29` for up to 30 seconds
|
27
|
+
When(/^I successfully run `(.*?)`(?: for up to (\d+) seconds)?$/)do |cmd, secs|
|
28
|
+
cmd = sanitize_text(cmd)
|
29
|
+
run_simple(cmd, :fail_on_error => true, :exit_timeout => secs && secs.to_i)
|
30
|
+
end
|
31
|
+
|
32
|
+
When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) do |shell, commands|
|
33
|
+
prepend_environment_variable('PATH', expand_path('bin') + File::PATH_SEPARATOR)
|
34
|
+
|
35
|
+
Aruba.platform.mkdir(expand_path('bin'))
|
36
|
+
shell ||= Aruba.platform.default_shell
|
37
|
+
|
38
|
+
Aruba::ScriptFile.new(:interpreter => shell, :content => commands,
|
39
|
+
:path => expand_path('bin/myscript')).call
|
40
|
+
step 'I run `myscript`'
|
41
|
+
end
|
42
|
+
|
43
|
+
When(/^I run "([^"]*)" interactively$/) do |cmd|
|
44
|
+
Aruba.platform.deprecated(%{\e[35m The /^I run "([^"]*)" interactively$/ step definition is deprecated. Please use the `backticks` version\e[0m})
|
45
|
+
|
46
|
+
step %(I run `#{cmd}` interactively)
|
47
|
+
end
|
48
|
+
|
49
|
+
When(/^I run `([^`]*)` interactively$/)do |cmd|
|
50
|
+
cmd = sanitize_text(cmd)
|
51
|
+
@interactive = run(cmd)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Merge interactive and background after refactoring with event queue
|
55
|
+
When(/^I run `([^`]*)` in background$/)do |cmd|
|
56
|
+
run(sanitize_text(cmd))
|
57
|
+
end
|
58
|
+
|
59
|
+
When(/^I type "([^"]*)"$/) do |input|
|
60
|
+
type(unescape_text(input))
|
61
|
+
end
|
62
|
+
|
63
|
+
When(/^I close the stdin stream$/) do
|
64
|
+
close_input
|
65
|
+
end
|
66
|
+
|
67
|
+
When(/^I pipe in (?:a|the) file(?: named)? "([^"]*)"$/) do |file|
|
68
|
+
pipe_in_file(file)
|
69
|
+
|
70
|
+
close_input
|
71
|
+
end
|
72
|
+
|
73
|
+
When(/^I (terminate|stop) the command (?:"([^"]*)"|(?:started last))$/) do |signal, command|
|
74
|
+
if command
|
75
|
+
cmd = all_commands.find { |c| c.commandline == command }
|
76
|
+
fail ArgumentError, %(No command "#{command}" found) if cmd.nil?
|
77
|
+
|
78
|
+
if signal == 'terminate'
|
79
|
+
# last_command_started.terminate
|
80
|
+
process_monitor.terminate_process!(process_monitor.get_process(command))
|
81
|
+
else
|
82
|
+
# last_command_started.stop
|
83
|
+
process_monitor.stop_process(process_monitor.get_process(command))
|
84
|
+
end
|
85
|
+
else
|
86
|
+
if signal == 'terminate'
|
87
|
+
# last_command_started.terminate
|
88
|
+
process_monitor.terminate_process!(last_command_started)
|
89
|
+
else
|
90
|
+
# last_command_started.stop
|
91
|
+
process_monitor.stop_process(last_command_started)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$/) do |channel, expected|
|
97
|
+
fail %(Invalid output channel "#{channel}" chosen. Please choose one of "output, stdout or stderr") unless %w(output stdout stderr).include? channel
|
98
|
+
|
99
|
+
begin
|
100
|
+
Timeout.timeout(aruba.config.exit_timeout) do
|
101
|
+
loop do
|
102
|
+
output = if RUBY_VERSION < '1.9.3'
|
103
|
+
last_command_started.send channel.to_sym, :wait_for_io => 0
|
104
|
+
else
|
105
|
+
last_command_started.public_send channel.to_sym, :wait_for_io => 0
|
106
|
+
end
|
107
|
+
|
108
|
+
output = sanitize_text(output)
|
109
|
+
expected = sanitize_text(expected)
|
110
|
+
|
111
|
+
if output.include? expected
|
112
|
+
last_command_started.terminate
|
113
|
+
|
114
|
+
break
|
115
|
+
end
|
116
|
+
|
117
|
+
sleep 0.1
|
118
|
+
end
|
119
|
+
end
|
120
|
+
rescue ChildProcess::TimeoutError, TimeoutError
|
121
|
+
last_command_started.terminate
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
When(/^I wait for (?:output|stdout) to contain:$/) do |expected|
|
126
|
+
Timeout.timeout(aruba.config.exit_timeout) do
|
127
|
+
loop do
|
128
|
+
begin
|
129
|
+
expect(last_command_started).to have_output an_output_string_including(expected)
|
130
|
+
rescue ExpectationError
|
131
|
+
sleep 0.1
|
132
|
+
retry
|
133
|
+
end
|
134
|
+
|
135
|
+
break
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
When(/^I wait for (?:output|stdout) to contain "([^"]*)"$/) do |expected|
|
141
|
+
Timeout.timeout(aruba.config.exit_timeout) do
|
142
|
+
loop do
|
143
|
+
begin
|
144
|
+
expect(last_command_started).to have_output an_output_string_including(expected)
|
145
|
+
rescue ExpectationError
|
146
|
+
sleep 0.1
|
147
|
+
retry
|
148
|
+
end
|
149
|
+
|
150
|
+
break
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
Then(/^the output should be (\d+) bytes long$/) do |size|
|
156
|
+
expect(all_output).to have_output_size size.to_i
|
157
|
+
end
|
158
|
+
|
159
|
+
Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain( exactly)? "([^"]*)"$/) do |channel, cmd, negated, exactly, expected|
|
160
|
+
matcher = case channel.to_sym
|
161
|
+
when :output
|
162
|
+
:have_output
|
163
|
+
when :stderr
|
164
|
+
:have_output_on_stderr
|
165
|
+
when :stdout
|
166
|
+
:have_output_on_stdout
|
167
|
+
end
|
168
|
+
|
169
|
+
commands = if cmd
|
170
|
+
[aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))]
|
171
|
+
else
|
172
|
+
all_commands
|
173
|
+
end
|
174
|
+
|
175
|
+
output_string_matcher = if exactly
|
176
|
+
:an_output_string_being_eq
|
177
|
+
else
|
178
|
+
:an_output_string_including
|
179
|
+
end
|
180
|
+
|
181
|
+
if Aruba::VERSION < '1.0'
|
182
|
+
combined_output = commands.map do |c|
|
183
|
+
c.stop
|
184
|
+
c.send(channel.to_sym).chomp
|
185
|
+
end.join("\n")
|
186
|
+
|
187
|
+
if negated
|
188
|
+
expect(combined_output).not_to send(output_string_matcher, expected)
|
189
|
+
else
|
190
|
+
expect(combined_output).to send(output_string_matcher, expected)
|
191
|
+
end
|
192
|
+
else
|
193
|
+
if negated
|
194
|
+
expect(commands).not_to include_an_object send(matcher, send(output_string_matcher, expected))
|
195
|
+
else
|
196
|
+
expect(commands).to include_an_object send(matcher, send(output_string_matcher, expected))
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
## the stderr should contain "hello"
|
202
|
+
## the stderr from "echo -n 'Hello'" should contain "hello"
|
203
|
+
## the stderr should contain exactly:
|
204
|
+
## the stderr from "echo -n 'Hello'" should contain exactly:
|
205
|
+
Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain( exactly)?:$/) do |channel, cmd, negated, exactly, expected|
|
206
|
+
matcher = case channel.to_sym
|
207
|
+
when :output
|
208
|
+
:have_output
|
209
|
+
when :stderr
|
210
|
+
:have_output_on_stderr
|
211
|
+
when :stdout
|
212
|
+
:have_output_on_stdout
|
213
|
+
else
|
214
|
+
fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stderr" or "stdout" are allowed.)
|
215
|
+
end
|
216
|
+
|
217
|
+
commands = if cmd
|
218
|
+
[aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))]
|
219
|
+
else
|
220
|
+
all_commands
|
221
|
+
end
|
222
|
+
|
223
|
+
output_string_matcher = if exactly
|
224
|
+
:an_output_string_being_eq
|
225
|
+
else
|
226
|
+
:an_output_string_including
|
227
|
+
end
|
228
|
+
|
229
|
+
if Aruba::VERSION < '1.0'
|
230
|
+
combined_output = commands.map do |c|
|
231
|
+
c.stop
|
232
|
+
c.send(channel.to_sym).chomp
|
233
|
+
end.join("\n")
|
234
|
+
|
235
|
+
if negated
|
236
|
+
expect(combined_output).not_to send(output_string_matcher, expected)
|
237
|
+
else
|
238
|
+
expect(combined_output).to send(output_string_matcher, expected)
|
239
|
+
end
|
240
|
+
else
|
241
|
+
if negated
|
242
|
+
expect(commands).not_to include_an_object send(matcher, send(output_string_matcher, expected))
|
243
|
+
else
|
244
|
+
expect(commands).to include_an_object send(matcher, send(output_string_matcher, expected))
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
# "the output should match" allows regex in the partial_output, if
|
250
|
+
# you don't need regex, use "the output should contain" instead since
|
251
|
+
# that way, you don't have to escape regex characters that
|
252
|
+
# appear naturally in the output
|
253
|
+
Then(/^the output should( not)? match \/([^\/]*)\/$/) do |negated, expected|
|
254
|
+
if negated
|
255
|
+
expect(all_commands).not_to include_an_object have_output an_output_string_matching(expected)
|
256
|
+
else
|
257
|
+
expect(all_commands).to include_an_object have_output an_output_string_matching(expected)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
Then(/^the output should( not)? match %r<([^>]*)>$/) do |negated, expected|
|
262
|
+
if negated
|
263
|
+
expect(all_commands).not_to include_an_object have_output an_output_string_matching(expected)
|
264
|
+
else
|
265
|
+
expect(all_commands).to include_an_object have_output an_output_string_matching(expected)
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
Then(/^the output should( not)? match:$/) do |negated, expected|
|
270
|
+
if negated
|
271
|
+
expect(all_commands).not_to include_an_object have_output an_output_string_matching(expected)
|
272
|
+
else
|
273
|
+
expect(all_commands).to include_an_object have_output an_output_string_matching(expected)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
|
278
|
+
if negated
|
279
|
+
expect(last_command_stopped).not_to have_exit_status exit_status.to_i
|
280
|
+
else
|
281
|
+
expect(last_command_stopped).to have_exit_status exit_status.to_i
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
Then(/^it should( not)? (pass|fail) with "(.*?)"$/) do |negated, pass_fail, expected|
|
286
|
+
if pass_fail == 'pass'
|
287
|
+
expect(last_command_stopped).to be_successfully_executed
|
288
|
+
else
|
289
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
290
|
+
end
|
291
|
+
|
292
|
+
if negated
|
293
|
+
expect(last_command_stopped).not_to have_output an_output_string_including(expected)
|
294
|
+
else
|
295
|
+
expect(last_command_stopped).to have_output an_output_string_including(expected)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
Then(/^it should( not)? (pass|fail) with:$/) do |negated, pass_fail, expected|
|
300
|
+
if pass_fail == 'pass'
|
301
|
+
expect(last_command_stopped).to be_successfully_executed
|
302
|
+
else
|
303
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
304
|
+
end
|
305
|
+
|
306
|
+
if negated
|
307
|
+
expect(last_command_stopped).not_to have_output an_output_string_including(expected)
|
308
|
+
else
|
309
|
+
expect(last_command_stopped).to have_output an_output_string_including(expected)
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
Then(/^it should( not)? (pass|fail) with exactly:$/) do |negated, pass_fail, expected|
|
314
|
+
if pass_fail == 'pass'
|
315
|
+
expect(last_command_stopped).to be_successfully_executed
|
316
|
+
else
|
317
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
318
|
+
end
|
319
|
+
|
320
|
+
if negated
|
321
|
+
expect(last_command_stopped).not_to have_output an_output_string_eq(expected)
|
322
|
+
else
|
323
|
+
expect(last_command_stopped).to have_output an_output_string_being_eq(expected)
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
Then(/^it should( not)? (pass|fail) (?:with regexp?|matching):$/) do |negated, pass_fail, expected|
|
328
|
+
if pass_fail == 'pass'
|
329
|
+
expect(last_command_stopped).to be_successfully_executed
|
330
|
+
else
|
331
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
332
|
+
end
|
333
|
+
|
334
|
+
if negated
|
335
|
+
expect(last_command_stopped).not_to have_output an_output_string_matching(expected)
|
336
|
+
else
|
337
|
+
expect(last_command_stopped).to have_output an_output_string_matching(expected)
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channel|
|
342
|
+
matcher = case channel.to_sym
|
343
|
+
when :output
|
344
|
+
:have_output
|
345
|
+
when :stderr
|
346
|
+
:have_output_on_stderr
|
347
|
+
when :stdout
|
348
|
+
:have_output_on_stdout
|
349
|
+
else
|
350
|
+
fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stdout" and "stderr" are supported.)
|
351
|
+
end
|
352
|
+
|
353
|
+
expect(all_commands).to include_an_object send(matcher, be_nil.or(be_empty))
|
354
|
+
end
|
355
|
+
|
356
|
+
Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) do |channel, negated, table|
|
357
|
+
table.raw.flatten.each do |expected|
|
358
|
+
matcher = case channel.to_sym
|
359
|
+
when :output
|
360
|
+
:have_output
|
361
|
+
when :stderr
|
362
|
+
:have_output_on_stderr
|
363
|
+
when :stdout
|
364
|
+
:have_output_on_stdout
|
365
|
+
else
|
366
|
+
fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stdout" and "stderr" are supported.)
|
367
|
+
end
|
368
|
+
|
369
|
+
if negated
|
370
|
+
expect(all_commands).not_to include_an_object have_output an_output_string_including(expected)
|
371
|
+
else
|
372
|
+
expect(all_commands).to include_an_object have_output an_output_string_including(expected)
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
Given(/the default aruba timeout is (\d+) seconds/) do |seconds|
|
378
|
+
# rubocop:disable Metrics/LineLength
|
379
|
+
Aruba.platform.deprecated(%{The /^the default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
|
380
|
+
# rubocop:enable Metrics/LineLength
|
381
|
+
|
382
|
+
aruba.config.exit_timeout = seconds.to_i
|
383
|
+
end
|
384
|
+
|
385
|
+
Given(/The default aruba timeout is (\d+) seconds/) do |seconds|
|
386
|
+
# rubocop:disable Metrics/LineLength
|
387
|
+
Aruba.platform.deprecated(%{The /^The default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
|
388
|
+
# rubocop:enable Metrics/LineLength
|
389
|
+
|
390
|
+
aruba.config.exit_timeout = seconds.to_i
|
391
|
+
end
|
392
|
+
|
393
|
+
Given(/^the (?:default )?aruba io wait timeout is (\d+) seconds?$/) do |seconds|
|
394
|
+
aruba.config.io_wait_timeout = seconds.to_i
|
395
|
+
end
|
396
|
+
|
397
|
+
Given(/^the (?:default )?aruba exit timeout is (\d+) seconds?$/) do |seconds|
|
398
|
+
aruba.config.exit_timeout = seconds.to_i
|
399
|
+
end
|
400
|
+
|
401
|
+
Given(/^the (?:default )?aruba stop signal is "([^"]*)"$/) do |signal|
|
402
|
+
aruba.config.stop_signal = signal
|
403
|
+
end
|
404
|
+
|
405
|
+
Given(/^I wait (\d+) seconds? for (?:a|the) command to start up$/) do |seconds|
|
406
|
+
aruba.config.startup_wait_time = seconds.to_i
|
407
|
+
end
|
408
|
+
|
409
|
+
When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))$/) do |signal, command|
|
410
|
+
if command
|
411
|
+
cmd = all_commands.find { |c| c.commandline == command }
|
412
|
+
fail ArgumentError, %(No command "#{command}" found) if cmd.nil?
|
413
|
+
|
414
|
+
cmd.send_signal signal
|
415
|
+
else
|
416
|
+
last_command_started.send_signal signal
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
Given(/^I look for executables in "(.*)" within the current directory$/) do |directory|
|
421
|
+
prepend_environment_variable 'PATH', expand_path(directory) + File::PATH_SEPARATOR
|
422
|
+
end
|