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,41 @@
|
|
1
|
+
# @!method match_path_pattern(pattern)
|
2
|
+
# This matchers checks if <files>/directories match <pattern>
|
3
|
+
#
|
4
|
+
# @param [String, Regexp] pattern
|
5
|
+
# The pattern to use.
|
6
|
+
#
|
7
|
+
# @return [TrueClass, FalseClass] The result
|
8
|
+
#
|
9
|
+
# false:
|
10
|
+
# * if there are no files/directories which match the pattern
|
11
|
+
# true:
|
12
|
+
# * if there are files/directories which match the pattern
|
13
|
+
#
|
14
|
+
# @example Use matcher with regex
|
15
|
+
#
|
16
|
+
# RSpec.describe do
|
17
|
+
# it { expect(Dir.glob(**/*)).to match_file_pattern(/.txt$/) }
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# @example Use matcher with string
|
21
|
+
#
|
22
|
+
# RSpec.describe do
|
23
|
+
# it { expect(Dir.glob(**/*)).to match_file_pattern('.txt$') }
|
24
|
+
# end
|
25
|
+
RSpec::Matchers.define :match_path_pattern do |_|
|
26
|
+
match do |actual|
|
27
|
+
Aruba.platform.deprecated('The use of `expect().to match_path_pattern` is deprecated. Please use `expect().to include pattern /regex/` instead.')
|
28
|
+
|
29
|
+
next !actual.select { |a| a == expected }.empty? if expected.is_a? String
|
30
|
+
|
31
|
+
!actual.grep(expected).empty?
|
32
|
+
end
|
33
|
+
|
34
|
+
failure_message do |actual|
|
35
|
+
format("expected that path \"%s\" matches pattern \"%s\".", actual.join(", "), expected)
|
36
|
+
end
|
37
|
+
|
38
|
+
failure_message_when_negated do |actual|
|
39
|
+
format("expected that path \"%s\" does not match pattern \"%s\".", actual.join(", "), expected)
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# @!method include_regexp(regexp)
|
2
|
+
# This matchers checks if items of an <array> matches regexp
|
3
|
+
#
|
4
|
+
# @param [Regexp] regexp
|
5
|
+
# The regular expression to use
|
6
|
+
#
|
7
|
+
# @return [TrueClass, FalseClass] The result
|
8
|
+
#
|
9
|
+
# false:
|
10
|
+
# * if regexp does not match
|
11
|
+
# true:
|
12
|
+
# * if regexp matches
|
13
|
+
#
|
14
|
+
# @example Use matcher
|
15
|
+
#
|
16
|
+
# RSpec.describe do
|
17
|
+
# it { expect(%w(asdf qwert)).to include_regexp(/asdf/) }
|
18
|
+
# end
|
19
|
+
RSpec::Matchers.define :include_regexp do |expected|
|
20
|
+
match do |actual|
|
21
|
+
Aruba.platform.deprecated('The use of "include_regexp"-matchers is deprecated. It will be removed soon.')
|
22
|
+
|
23
|
+
!actual.grep(expected).empty?
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Aruba.platform.require_matching_files('../string/**/*.rb', __FILE__)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# @!method include_output_string(string)
|
2
|
+
# This matchers checks if the output string of a command includes string.
|
3
|
+
#
|
4
|
+
# @param [Integer] status
|
5
|
+
# The value of the exit status
|
6
|
+
#
|
7
|
+
# @return [TrueClass, FalseClass] The result
|
8
|
+
#
|
9
|
+
# false:
|
10
|
+
# * if the output string does not include string
|
11
|
+
# true:
|
12
|
+
# * if the output string includes string
|
13
|
+
#
|
14
|
+
# @example Use matcher
|
15
|
+
#
|
16
|
+
# RSpec.describe do
|
17
|
+
# it { expect(last_command_started).to have_output an_output_string_including string) }
|
18
|
+
# it { expect(last_command_started).to have_output include_output_string string) }
|
19
|
+
# end
|
20
|
+
RSpec::Matchers.define :include_output_string do |expected|
|
21
|
+
match do |actual|
|
22
|
+
@expected = Regexp.new(Regexp.escape(sanitize_text(expected.to_s)), Regexp::MULTILINE)
|
23
|
+
@actual = sanitize_text(actual)
|
24
|
+
|
25
|
+
values_match? @expected, @actual
|
26
|
+
end
|
27
|
+
|
28
|
+
diffable
|
29
|
+
|
30
|
+
description { "string includes: #{description_of expected}" }
|
31
|
+
end
|
32
|
+
|
33
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
34
|
+
RSpec::Matchers.alias_matcher :an_output_string_including, :include_output_string
|
35
|
+
RSpec::Matchers.alias_matcher :file_content_including, :include_output_string
|
36
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# @!method match_output_string(string)
|
2
|
+
# This matchers checks if the output string of a command matches regular expression.
|
3
|
+
#
|
4
|
+
# @param [Integer] status
|
5
|
+
# The value of the exit status
|
6
|
+
#
|
7
|
+
# @return [TrueClass, FalseClass] The result
|
8
|
+
#
|
9
|
+
# false:
|
10
|
+
# * if the output string does not match regex
|
11
|
+
# true:
|
12
|
+
# * if the output string matches regex
|
13
|
+
#
|
14
|
+
# @example Use matcher
|
15
|
+
#
|
16
|
+
# RSpec.describe do
|
17
|
+
# it { expect(last_command_started).to have_output an_output_string_matching regex) }
|
18
|
+
# it { expect(last_command_started).to have_output match_output_string regex) }
|
19
|
+
# end
|
20
|
+
RSpec::Matchers.define :match_output_string do |expected|
|
21
|
+
match do |actual|
|
22
|
+
@expected = Regexp.new(unescape_text(expected), Regexp::MULTILINE)
|
23
|
+
@actual = sanitize_text(actual)
|
24
|
+
|
25
|
+
values_match? @expected, @actual
|
26
|
+
end
|
27
|
+
|
28
|
+
diffable
|
29
|
+
|
30
|
+
description { "output string matches: #{description_of expected}" }
|
31
|
+
end
|
32
|
+
|
33
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
34
|
+
RSpec::Matchers.alias_matcher :an_output_string_matching, :match_output_string
|
35
|
+
RSpec::Matchers.alias_matcher :a_file_name_matching, :match_output_string
|
36
|
+
RSpec::Matchers.alias_matcher :file_content_matching, :match_output_string
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# @!method output_string_eq(string)
|
2
|
+
# This matchers checks if the output string of a command includes string.
|
3
|
+
#
|
4
|
+
# @param [Integer] status
|
5
|
+
# The value of the exit status
|
6
|
+
#
|
7
|
+
# @return [TrueClass, FalseClass] The result
|
8
|
+
#
|
9
|
+
# false:
|
10
|
+
# * if the output string does not include string
|
11
|
+
# true:
|
12
|
+
# * if the output string includes string
|
13
|
+
#
|
14
|
+
# @example Use matcher
|
15
|
+
#
|
16
|
+
# RSpec.describe do
|
17
|
+
# it { expect(last_command_started).to have_output output_string_eq string) }
|
18
|
+
# it { expect(last_command_started).to have_output an_output_string_begin_eq string) }
|
19
|
+
# end
|
20
|
+
RSpec::Matchers.define :output_string_eq do |expected|
|
21
|
+
match do |actual|
|
22
|
+
@expected = sanitize_text(expected.to_s)
|
23
|
+
@actual = sanitize_text(actual.to_s)
|
24
|
+
|
25
|
+
values_match? @expected, @actual
|
26
|
+
end
|
27
|
+
|
28
|
+
diffable
|
29
|
+
|
30
|
+
description { "output string is eq: #{description_of expected}" }
|
31
|
+
end
|
32
|
+
|
33
|
+
if RSpec::Expectations::Version::STRING >= '3.0'
|
34
|
+
RSpec::Matchers.alias_matcher :an_output_string_being_eq, :output_string_eq
|
35
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'thread'
|
2
|
+
require 'aruba/platforms/unix_platform'
|
3
|
+
require 'aruba/platforms/windows_platform'
|
4
|
+
|
5
|
+
# Aruba
|
6
|
+
module Aruba
|
7
|
+
PLATFORM_MUTEX = Mutex.new
|
8
|
+
end
|
9
|
+
|
10
|
+
# Aruba
|
11
|
+
module Aruba
|
12
|
+
# Platform
|
13
|
+
Platform = [Platforms::WindowsPlatform, Platforms::UnixPlatform].find(&:match?)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Aruba
|
17
|
+
module Aruba
|
18
|
+
PLATFORM_MUTEX.synchronize do
|
19
|
+
@platform = Platform.new
|
20
|
+
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
attr_reader :platform
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,232 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
require 'aruba/colorizer'
|
3
|
+
|
4
|
+
Aruba::AnsiColor.coloring = false if !STDOUT.tty? && !ENV.key?("AUTOTEST")
|
5
|
+
|
6
|
+
# Aruba
|
7
|
+
module Aruba
|
8
|
+
# Platforms
|
9
|
+
module Platforms
|
10
|
+
# Announcer
|
11
|
+
#
|
12
|
+
# @private
|
13
|
+
#
|
14
|
+
# @example Activate your you own channel in cucumber
|
15
|
+
#
|
16
|
+
# Before('@announce-my-channel') do
|
17
|
+
# aruba.announcer.activate :my_channel
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# @example Activate your you own channel in rspec > 3
|
21
|
+
#
|
22
|
+
# before do
|
23
|
+
# current_example = context.example
|
24
|
+
# aruba.announcer.activate :my_channel if current_example.metadata[:announce_my_channel]
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# Aruba.announcer.announce(:my_channel, 'my message')
|
28
|
+
#
|
29
|
+
class Announcer
|
30
|
+
# Announcer using Kernel.puts
|
31
|
+
class KernelPutsAnnouncer
|
32
|
+
def announce(message)
|
33
|
+
Kernel.puts message
|
34
|
+
end
|
35
|
+
|
36
|
+
def mode?(m)
|
37
|
+
:kernel_puts == m
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Announcer using Main#puts
|
42
|
+
class PutsAnnouncer
|
43
|
+
def announce(message)
|
44
|
+
puts message
|
45
|
+
end
|
46
|
+
|
47
|
+
def mode?(m)
|
48
|
+
:puts == m
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
attr_reader :announcers, :announcer, :channels, :output_formats, :colorizer
|
55
|
+
|
56
|
+
public
|
57
|
+
|
58
|
+
def initialize(*args)
|
59
|
+
@announcers = []
|
60
|
+
@announcers << PutsAnnouncer.new
|
61
|
+
@announcers << KernelPutsAnnouncer.new
|
62
|
+
|
63
|
+
@colorizer = Aruba::Colorizer.new
|
64
|
+
|
65
|
+
@announcer = @announcers.first
|
66
|
+
@channels = {}
|
67
|
+
@output_formats = {}
|
68
|
+
|
69
|
+
@options = args[1] || {}
|
70
|
+
|
71
|
+
after_init
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
# rubocop:disable Metrics/MethodLength
|
77
|
+
def after_init
|
78
|
+
output_format :changed_configuration, proc { |n, v| format('# %s = %s', n, v) }
|
79
|
+
output_format :changed_environment, proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
|
80
|
+
output_format :command, '$ %s'
|
81
|
+
output_format :directory, '$ cd %s'
|
82
|
+
output_format :environment, proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
|
83
|
+
output_format :full_environment, proc { |h| format("<<-ENVIRONMENT\n%s\nENVIRONMENT", Aruba.platform.simple_table(h)) }
|
84
|
+
output_format :modified_environment, proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
|
85
|
+
output_format :stderr, "<<-STDERR\n%s\nSTDERR"
|
86
|
+
output_format :stdout, "<<-STDOUT\n%s\nSTDOUT"
|
87
|
+
output_format :command_content, "<<-COMMAND\n%s\nCOMMAND"
|
88
|
+
output_format :stop_signal, proc { |p, s| format('Command will be stopped with `kill -%s %s`', s, p) }
|
89
|
+
output_format :timeout, '# %s-timeout: %s seconds'
|
90
|
+
output_format :wait_time, '# %s: %s seconds'
|
91
|
+
# rubocop:disable Metrics/LineLength
|
92
|
+
output_format :command_filesystem_status, proc { |status| format("<<-COMMAND FILESYSTEM STATUS\n%s\nCOMMAND FILESYSTEM STATUS", Aruba.platform.simple_table(status.to_h, :sort => false)) }
|
93
|
+
# rubocop:enable Metrics/LineLength
|
94
|
+
|
95
|
+
# rubocop:disable Metrics/LineLength
|
96
|
+
if @options[:stdout]
|
97
|
+
warn('The use of "@announce_stdout-instance" variable and "options[:stdout] = true" for Announcer.new is deprecated. Please use "announcer.activate(:stdout)" instead.')
|
98
|
+
activate :stdout
|
99
|
+
end
|
100
|
+
if @options[:stderr]
|
101
|
+
warn('The use of "@announce_stderr-instance" variable and "options[:stderr] = true" for Announcer.new is deprecated. Please use "announcer.activate(:stderr)" instead.')
|
102
|
+
activate :stderr
|
103
|
+
end
|
104
|
+
if @options[:dir]
|
105
|
+
warn('The use of "@announce_dir-instance" variable and "options[:dir] = true" for Announcer.new is deprecated. Please use "announcer.activate(:directory)" instead.')
|
106
|
+
activate :directory
|
107
|
+
end
|
108
|
+
if @options[:cmd]
|
109
|
+
warn('The use of "@announce_cmd-instance" variable and "options[:cmd] = true" for Announcer.new is deprecated. Please use "announcer.activate(:command)" instead.')
|
110
|
+
activate :command
|
111
|
+
end
|
112
|
+
if @options[:env]
|
113
|
+
warn('The use of "@announce_env-instance" variable and "options[:env] = true" for Announcer.new is deprecated. Please use "announcer.activate(:modified_environment)" instead.')
|
114
|
+
activate :modified_enviroment
|
115
|
+
end
|
116
|
+
# rubocop:enable Metrics/LineLength
|
117
|
+
end
|
118
|
+
# rubocop:enable Metrics/MethodLength
|
119
|
+
|
120
|
+
def output_format(channel, string = '%s', &block)
|
121
|
+
output_formats[channel.to_sym] = if block_given?
|
122
|
+
block
|
123
|
+
elsif string.is_a?(Proc)
|
124
|
+
string
|
125
|
+
else
|
126
|
+
proc { |*args| format(string, *args) }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
public
|
131
|
+
|
132
|
+
# Reset announcer
|
133
|
+
def reset
|
134
|
+
@announcer = @announcers.first
|
135
|
+
end
|
136
|
+
|
137
|
+
# Change mode of announcer
|
138
|
+
#
|
139
|
+
# @param [Symbol] m
|
140
|
+
# The mode to set
|
141
|
+
def mode=(m)
|
142
|
+
@announcer = @announcers.find { |a| f.mode? m.to_sym }
|
143
|
+
|
144
|
+
self
|
145
|
+
end
|
146
|
+
|
147
|
+
# Check if channel is activated
|
148
|
+
#
|
149
|
+
# @param [Symbol] channel
|
150
|
+
# The name of the channel to check
|
151
|
+
def activated?(channel)
|
152
|
+
channels[channel.to_sym] == true
|
153
|
+
end
|
154
|
+
|
155
|
+
# Activate a channel
|
156
|
+
#
|
157
|
+
# @param [Symbol] channel
|
158
|
+
# The name of the channel to activate
|
159
|
+
def activate(*chns)
|
160
|
+
chns.flatten.each { |c| channels[c.to_sym] = true }
|
161
|
+
|
162
|
+
self
|
163
|
+
end
|
164
|
+
|
165
|
+
# Announce information to channel
|
166
|
+
#
|
167
|
+
# @param [Symbol] channel
|
168
|
+
# The name of the channel to check
|
169
|
+
#
|
170
|
+
# @param [Array] args
|
171
|
+
# Arguments
|
172
|
+
#
|
173
|
+
# @yield
|
174
|
+
# If block is given, that one is called and the return value is used as
|
175
|
+
# message to be announced.
|
176
|
+
def announce(channel, *args, &block)
|
177
|
+
channel = channel.to_sym
|
178
|
+
|
179
|
+
the_output_format = if output_formats.key? channel
|
180
|
+
output_formats[channel]
|
181
|
+
else
|
182
|
+
proc { |v| format('%s', v) }
|
183
|
+
end
|
184
|
+
|
185
|
+
return unless activated?(channel)
|
186
|
+
|
187
|
+
message = if block_given?
|
188
|
+
the_output_format.call(yield)
|
189
|
+
else
|
190
|
+
the_output_format.call(*args)
|
191
|
+
end
|
192
|
+
message += "\n"
|
193
|
+
message = colorizer.cyan(message)
|
194
|
+
|
195
|
+
announcer.announce(message)
|
196
|
+
|
197
|
+
nil
|
198
|
+
end
|
199
|
+
|
200
|
+
# @deprecated
|
201
|
+
def stdout(content)
|
202
|
+
warn('The announcer now has a new api to activate channels. Please use this one: announce(:stdout, message)')
|
203
|
+
announce :stdout, content
|
204
|
+
end
|
205
|
+
|
206
|
+
# @deprecated
|
207
|
+
def stderr(content)
|
208
|
+
warn('The announcer now has a new api to activate channels. Please use this one: announce(:stderr, message)')
|
209
|
+
announce :stderr, content
|
210
|
+
end
|
211
|
+
|
212
|
+
# @deprecated
|
213
|
+
def dir(dir)
|
214
|
+
warn('The announcer now has a new api to activate channels. Please use this one announce(:directory, message)')
|
215
|
+
announce :directory, dir
|
216
|
+
end
|
217
|
+
|
218
|
+
# @deprecated
|
219
|
+
def cmd(cmd)
|
220
|
+
warn('The announcer now has a new api to activate channels. Please use this one announce(:command, message)')
|
221
|
+
announce :command, cmd
|
222
|
+
end
|
223
|
+
|
224
|
+
# @deprecated
|
225
|
+
def env(name, value)
|
226
|
+
warn('The announcer now has a new api to activate channels. Please use this one: announce(:changed_environment, key, value)')
|
227
|
+
|
228
|
+
announce :changed_environment, name, value
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Aruba
|
2
|
+
module Aruba
|
3
|
+
# Platforms
|
4
|
+
module Platforms
|
5
|
+
# Normal File Creator
|
6
|
+
# This class is not meant to be used directly by users.
|
7
|
+
#
|
8
|
+
# @private
|
9
|
+
class ArubaFileCreator
|
10
|
+
# Write File
|
11
|
+
#
|
12
|
+
# @param [String] path
|
13
|
+
# The path to write content to
|
14
|
+
#
|
15
|
+
# @param [Object] content
|
16
|
+
# The content of the file
|
17
|
+
#
|
18
|
+
# @param [TrueClass, FalseClass] check_presence (false)
|
19
|
+
# Check if file exist
|
20
|
+
def call(path, content, check_presence = false)
|
21
|
+
fail "Expected #{path} to be present" if check_presence && !Aruba.platform.file?(path)
|
22
|
+
|
23
|
+
Aruba.platform.mkdir(File.dirname(path))
|
24
|
+
|
25
|
+
if RUBY_VERSION < '1.9.3'
|
26
|
+
File.open(path, 'w') { |f| f << content }
|
27
|
+
else
|
28
|
+
File.write(path, content)
|
29
|
+
end
|
30
|
+
|
31
|
+
self
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|