aruba 0.14.14 → 1.0.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.cucumberproignore +3 -0
- data/.github/ISSUE_TEMPLATE.md +48 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +39 -0
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.rubocop.yml +1 -5
- data/.travis.yml +35 -27
- data/CONTRIBUTING.md +131 -29
- data/Dockerfile +67 -0
- data/Gemfile +33 -80
- data/History.md +602 -0
- data/README.md +24 -196
- data/Rakefile +87 -27
- data/appveyor.yml +0 -1
- data/aruba.gemspec +30 -40
- data/bin/bootstrap +34 -0
- data/bin/build +3 -0
- data/{script → bin}/console +0 -0
- data/bin/release +3 -0
- data/bin/test +9 -0
- data/cucumber.yml +1 -3
- data/docker-compose.yml +26 -0
- data/{bin → exec}/aruba +0 -0
- data/fixtures/cli-app/README.md +1 -1
- data/fixtures/cli-app/features/support/aruba.rb +1 -0
- data/fixtures/cli-app/features/support/env.rb +1 -1
- data/fixtures/cli-app/lib/cli/app.rb +1 -5
- data/fixtures/cli-app/spec/spec_helper.rb +1 -6
- data/fixtures/empty-app/lib/cli/app.rb +2 -0
- data/lib/aruba/api.rb +3 -3
- data/lib/aruba/api/{commands.rb → command.rb} +4 -30
- data/lib/aruba/api/core.rb +8 -25
- data/lib/aruba/api/deprecated.rb +150 -408
- data/lib/aruba/api/filesystem.rb +17 -2
- data/lib/aruba/api/rvm.rb +44 -0
- data/lib/aruba/aruba_path.rb +56 -32
- data/lib/aruba/basic_configuration.rb +3 -5
- data/lib/aruba/colorizer.rb +99 -10
- data/lib/aruba/command.rb +0 -2
- data/lib/aruba/config.rb +5 -5
- data/lib/aruba/config/jruby.rb +5 -15
- data/lib/aruba/console.rb +2 -0
- data/lib/aruba/console/help.rb +1 -7
- data/lib/aruba/cucumber.rb +0 -2
- data/lib/aruba/cucumber/command.rb +98 -72
- data/lib/aruba/cucumber/file.rb +15 -3
- data/lib/aruba/cucumber/hooks.rb +71 -10
- data/lib/aruba/event_bus/name_resolver.rb +2 -10
- data/lib/aruba/generators/script_file.rb +1 -1
- data/lib/aruba/in_process.rb +0 -2
- data/lib/aruba/initializer.rb +4 -14
- data/lib/aruba/matchers/base/object_formatter.rb +0 -5
- data/lib/aruba/matchers/file/have_same_file_content.rb +5 -5
- data/lib/aruba/matchers/string/output_string_eq.rb +1 -1
- data/lib/aruba/platforms/announcer.rb +11 -16
- data/lib/aruba/platforms/aruba_file_creator.rb +1 -5
- data/lib/aruba/platforms/aruba_logger.rb +1 -5
- data/lib/aruba/platforms/command_monitor.rb +10 -14
- data/lib/aruba/platforms/determine_disk_usage.rb +8 -3
- data/lib/aruba/platforms/filesystem_status.rb +1 -5
- data/lib/aruba/platforms/unix_command_string.rb +1 -8
- data/lib/aruba/platforms/unix_environment_variables.rb +6 -8
- data/lib/aruba/platforms/unix_platform.rb +9 -22
- data/lib/aruba/platforms/unix_which.rb +4 -0
- data/lib/aruba/platforms/windows_command_string.rb +6 -14
- data/lib/aruba/platforms/windows_environment_variables.rb +4 -16
- data/lib/aruba/platforms/windows_which.rb +4 -0
- data/lib/aruba/processes/basic_process.rb +22 -18
- data/lib/aruba/processes/spawn_process.rb +12 -35
- data/lib/aruba/rspec.rb +1 -0
- data/lib/aruba/runtime.rb +3 -4
- data/lib/aruba/setup.rb +9 -11
- data/lib/aruba/spawn_process.rb +1 -4
- data/lib/aruba/tasks/docker_helpers.rb +158 -0
- data/lib/aruba/version.rb +1 -1
- metadata +62 -230
- data/CHANGELOG.md +0 -991
- data/features/.nav +0 -72
- data/features/01_getting_started_with_aruba/cleanup_working_directory.feature +0 -57
- data/features/01_getting_started_with_aruba/run_commands.feature +0 -217
- data/features/01_getting_started_with_aruba/supported_testing_frameworks.feature +0 -88
- data/features/02_configure_aruba/activate_announcer_on_command_failure.feature +0 -38
- data/features/02_configure_aruba/basics.feature +0 -151
- data/features/02_configure_aruba/command_runtime_environment.feature +0 -129
- data/features/02_configure_aruba/console_history_file.feature +0 -38
- data/features/02_configure_aruba/exit_timeout.feature +0 -60
- data/features/02_configure_aruba/fixtures_directories.feature +0 -38
- data/features/02_configure_aruba/fixtures_path_prefix.feature +0 -23
- data/features/02_configure_aruba/home_directory.feature +0 -80
- data/features/02_configure_aruba/io_timeout.feature +0 -30
- data/features/02_configure_aruba/keep_ansi.feature +0 -30
- data/features/02_configure_aruba/log_level.feature +0 -38
- data/features/02_configure_aruba/physical_block_size.feature +0 -53
- data/features/02_configure_aruba/remove_ansi_escape_sequences.feature +0 -38
- data/features/02_configure_aruba/root_directory.feature +0 -30
- data/features/02_configure_aruba/startup_wait_time.feature +0 -48
- data/features/02_configure_aruba/working_directory.feature +0 -38
- data/features/03_testing_frameworks/cucumber/announce_information_for_troubleshooting.feature +0 -306
- data/features/03_testing_frameworks/cucumber/disable_bunder.feature +0 -18
- data/features/03_testing_frameworks/cucumber/steps/command/check_for_exit_statuses.feature +0 -136
- data/features/03_testing_frameworks/cucumber/steps/command/check_output_of_command.feature +0 -514
- data/features/03_testing_frameworks/cucumber/steps/command/check_stderr_of_command.feature +0 -68
- data/features/03_testing_frameworks/cucumber/steps/command/check_stdout_of_command.feature +0 -109
- data/features/03_testing_frameworks/cucumber/steps/command/debug_your_command_in_aruba.feature +0 -118
- data/features/03_testing_frameworks/cucumber/steps/command/run_a_command.feature +0 -66
- data/features/03_testing_frameworks/cucumber/steps/command/run_command_in_process.feature +0 -485
- data/features/03_testing_frameworks/cucumber/steps/command/run_command_interactively.feature +0 -90
- data/features/03_testing_frameworks/cucumber/steps/command/run_commands_which_require_a_shell.feature +0 -79
- data/features/03_testing_frameworks/cucumber/steps/command/send_signal_to_command.feature +0 -83
- data/features/03_testing_frameworks/cucumber/steps/command/stop_command.feature +0 -285
- data/features/03_testing_frameworks/cucumber/steps/environment/append_environment_variable.feature +0 -52
- data/features/03_testing_frameworks/cucumber/steps/environment/modify_home_variable_for_testing.feature +0 -62
- data/features/03_testing_frameworks/cucumber/steps/environment/prepend_environment_variable.feature +0 -52
- data/features/03_testing_frameworks/cucumber/steps/environment/set_environment_variable.feature +0 -49
- data/features/03_testing_frameworks/cucumber/steps/filesystem/append_to_file.feature +0 -45
- data/features/03_testing_frameworks/cucumber/steps/filesystem/cd_to_directory.feature +0 -33
- data/features/03_testing_frameworks/cucumber/steps/filesystem/check_existence_of_directory.feature +0 -57
- data/features/03_testing_frameworks/cucumber/steps/filesystem/check_existence_of_file.feature +0 -43
- data/features/03_testing_frameworks/cucumber/steps/filesystem/check_file_content.feature +0 -143
- data/features/03_testing_frameworks/cucumber/steps/filesystem/check_non_existence_of_directory.feature +0 -69
- data/features/03_testing_frameworks/cucumber/steps/filesystem/check_non_existence_of_file.feature +0 -80
- data/features/03_testing_frameworks/cucumber/steps/filesystem/check_permissions_of_file.feature +0 -39
- data/features/03_testing_frameworks/cucumber/steps/filesystem/compare_files.feature +0 -42
- data/features/03_testing_frameworks/cucumber/steps/filesystem/copy_file_or_directory.feature +0 -45
- data/features/03_testing_frameworks/cucumber/steps/filesystem/create_directory.feature +0 -57
- data/features/03_testing_frameworks/cucumber/steps/filesystem/create_file.feature +0 -76
- data/features/03_testing_frameworks/cucumber/steps/filesystem/move_file_or_directory.feature +0 -44
- data/features/03_testing_frameworks/cucumber/steps/filesystem/overwrite_file.feature +0 -72
- data/features/03_testing_frameworks/cucumber/steps/filesystem/remove_directory.feature +0 -38
- data/features/03_testing_frameworks/cucumber/steps/filesystem/remove_file.feature +0 -38
- data/features/03_testing_frameworks/cucumber/steps/filesystem/use_fixtures_for_setup_test.feature +0 -77
- data/features/03_testing_frameworks/rspec/hooks/define_after_hook_for_commands.feature +0 -43
- data/features/03_testing_frameworks/rspec/hooks/define_before_hook_for_commands.feature +0 -71
- data/features/03_testing_frameworks/rspec/setup_aruba_for_rspec.feature +0 -179
- data/features/04_aruba_api/command/find_a_started_command.feature +0 -83
- data/features/04_aruba_api/command/find_command_in_PATH.feature +0 -37
- data/features/04_aruba_api/command/read_stderr_of_command.feature +0 -46
- data/features/04_aruba_api/command/read_stdout_of_command.feature +0 -46
- data/features/04_aruba_api/command/run_command.feature +0 -423
- data/features/04_aruba_api/command/run_simple.feature +0 -254
- data/features/04_aruba_api/command/send_signal_to_command.feature +0 -53
- data/features/04_aruba_api/command/stop_all_commands.feature +0 -57
- data/features/04_aruba_api/command/stop_single_command.feature +0 -132
- data/features/04_aruba_api/command/terminate_all_commands.feature +0 -57
- data/features/04_aruba_api/command/use_last_command_started.feature +0 -50
- data/features/04_aruba_api/command/use_last_command_stopped.feature +0 -89
- data/features/04_aruba_api/core/expand_path.feature +0 -88
- data/features/04_aruba_api/environment/append_environment_variable.feature +0 -128
- data/features/04_aruba_api/environment/delete_environment_variable.feature +0 -63
- data/features/04_aruba_api/environment/prepend_environment_variable.feature +0 -128
- data/features/04_aruba_api/environment/set_environment_variable.feature +0 -376
- data/features/04_aruba_api/filesystem/cd_to_directory.feature +0 -184
- data/features/04_aruba_api/filesystem/check_existence_file_or_directory.feature +0 -62
- data/features/04_aruba_api/filesystem/check_if_path_is_absolute.feature +0 -48
- data/features/04_aruba_api/filesystem/check_if_path_is_directory.feature +0 -53
- data/features/04_aruba_api/filesystem/check_if_path_is_file.feature +0 -54
- data/features/04_aruba_api/filesystem/check_if_path_is_relative.feature +0 -48
- data/features/04_aruba_api/filesystem/create_directory.feature +0 -57
- data/features/04_aruba_api/filesystem/move_file_or_directory.feature +0 -119
- data/features/04_aruba_api/filesystem/report_disk_usage.feature +0 -152
- data/features/04_aruba_api/filesystem/use_fixtures.feature +0 -104
- data/features/04_aruba_api/text/extract_text.feature +0 -87
- data/features/04_aruba_api/text/replace_variables.feature +0 -45
- data/features/04_aruba_api/text/sanitize_text.feature +0 -228
- data/features/04_aruba_api/text/unescape_text.feature +0 -127
- data/features/05_use_rspec_matchers/command/check_timeouts.feature +0 -48
- data/features/05_use_rspec_matchers/directory/have_sub_directory.feature +0 -110
- data/features/05_use_rspec_matchers/file/be_a_command_found_in_path.feature +0 -115
- data/features/05_use_rspec_matchers/file/be_existing_executable.feature +0 -88
- data/features/05_use_rspec_matchers/file/be_existing_file.feature +0 -82
- data/features/05_use_rspec_matchers/file/have_file_content.feature +0 -123
- data/features/05_use_rspec_matchers/file/have_file_size.feature +0 -107
- data/features/05_use_rspec_matchers/path/be_an_absolute_path.feature +0 -74
- data/features/05_use_rspec_matchers/path/be_an_existing_path.feature +0 -97
- data/features/05_use_rspec_matchers/path/have_permissions.feature +0 -118
- data/features/06_use_aruba_cli/initialize_project_with_aruba.feature +0 -79
- data/features/06_use_aruba_cli/open_console.feature +0 -55
- data/features/08_other/improve_performance_if_using_jruby.feature +0 -37
- data/features/step_definitions/hooks.rb +0 -146
- data/features/support/aruba.rb +0 -7
- data/features/support/env.rb +0 -33
- data/features/support/simplecov_setup.rb +0 -11
- data/lib/aruba/api/bundler.rb +0 -16
- data/lib/aruba/cucumber/deprecated.rb +0 -93
- data/lib/aruba/matchers/deprecated.rb +0 -1
- data/lib/aruba/matchers/deprecated/file.rb +0 -17
- data/lib/aruba/reporting.rb +0 -126
- data/script/bootstrap +0 -24
- data/script/test +0 -3
- data/spec/aruba/api/bundler_spec.rb +0 -15
- data/spec/aruba/api/commands_spec.rb +0 -30
- data/spec/aruba/api/core_spec.rb +0 -184
- data/spec/aruba/api/deprecated_spec.rb +0 -421
- data/spec/aruba/api/filesystem_spec.rb +0 -746
- data/spec/aruba/api/runtime_spec.rb +0 -28
- data/spec/aruba/api_spec.rb +0 -73
- data/spec/aruba/aruba_path_spec.rb +0 -103
- data/spec/aruba/basic_configuration_spec.rb +0 -5
- data/spec/aruba/configuration_spec.rb +0 -5
- data/spec/aruba/hooks_spec.rb +0 -17
- data/spec/aruba/in_config_wrapper_spec.rb +0 -25
- data/spec/aruba/jruby_spec.rb +0 -73
- data/spec/aruba/matchers/command/have_output_size_spec.rb +0 -25
- data/spec/aruba/matchers/command_spec.rb +0 -174
- data/spec/aruba/matchers/deprecated_spec.rb +0 -120
- data/spec/aruba/matchers/directory_spec.rb +0 -57
- data/spec/aruba/matchers/file_spec.rb +0 -208
- data/spec/aruba/matchers/path_spec.rb +0 -58
- data/spec/aruba/platform/simple_table_spec.rb +0 -23
- data/spec/aruba/platform/windows_environment_variables_spec.rb +0 -500
- data/spec/aruba/platforms/unix_command_string_spec.rb +0 -17
- data/spec/aruba/platforms/windows_command_string_spec.rb +0 -22
- data/spec/aruba/processes/spawn_process_spec.rb +0 -112
- data/spec/aruba/rspec_spec.rb +0 -15
- data/spec/aruba/runtime_spec.rb +0 -29
- data/spec/event_bus/name_resolver_spec.rb +0 -68
- data/spec/event_bus_spec.rb +0 -158
- data/spec/spec_helper.rb +0 -22
- data/spec/support/configs/.keep +0 -0
- data/spec/support/configs/aruba.rb +0 -5
- data/spec/support/configs/pry.rb +0 -3
- data/spec/support/configs/rspec.rb +0 -15
- data/spec/support/helpers/.keep +0 -0
- data/spec/support/helpers/reporting.rb +0 -44
- data/spec/support/matchers/.keep +0 -0
- data/spec/support/matchers/option.rb +0 -35
- data/spec/support/shared_contexts/.keep +0 -0
- data/spec/support/shared_contexts/aruba.rb +0 -49
- data/spec/support/shared_examples/.keep +0 -0
- data/spec/support/shared_examples/configuration.rb +0 -116
- data/spec/support/shared_examples/directory.rb +0 -7
- data/spec/support/shared_examples/file.rb +0 -7
- data/templates/css/console.css +0 -24
- data/templates/css/filesystem.css +0 -42
- data/templates/css/pygments-autumn.css +0 -59
- data/templates/files.erb +0 -14
- data/templates/images/LICENSE +0 -22
- 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 +0 -20
- data/templates/js/filesystem.js +0 -5
- data/templates/js/jquery-1.11.3.min.js +0 -5
- data/templates/main.erb +0 -34
@@ -1,68 +0,0 @@
|
|
1
|
-
Feature: STDERR of commands which were executed
|
2
|
-
|
3
|
-
In order to specify expected output
|
4
|
-
As a developer using Cucumber
|
5
|
-
I want to use the "the stderr should contain" step
|
6
|
-
|
7
|
-
Background:
|
8
|
-
Given I use a fixture named "cli-app"
|
9
|
-
|
10
|
-
Scenario: Detect stderr from all processes
|
11
|
-
Given a file named "features/output.feature" with:
|
12
|
-
"""
|
13
|
-
Feature: Run command
|
14
|
-
Scenario: Run command
|
15
|
-
When I run `bash -c 'printf "hello world!\n" >&2'`
|
16
|
-
And I run `bash -c 'cat >&2 '` interactively
|
17
|
-
And I type "hola"
|
18
|
-
And I type ""
|
19
|
-
Then the stderr should contain:
|
20
|
-
\"\"\"
|
21
|
-
hello world!
|
22
|
-
\"\"\"
|
23
|
-
And the stderr should contain:
|
24
|
-
\"\"\"
|
25
|
-
hola
|
26
|
-
\"\"\"
|
27
|
-
And the stdout should not contain anything
|
28
|
-
"""
|
29
|
-
When I run `cucumber`
|
30
|
-
Then the features should all pass
|
31
|
-
|
32
|
-
Scenario: Detect stderr from all processes
|
33
|
-
Given a file named "features/output.feature" with:
|
34
|
-
"""
|
35
|
-
Feature: Run command
|
36
|
-
Scenario: Run command
|
37
|
-
When I run `bash -c 'printf "hello world!\n" >&2'`
|
38
|
-
And I run `bash -c 'cat >&2 '` interactively
|
39
|
-
And I type "hola"
|
40
|
-
And I type ""
|
41
|
-
Then the stderr should contain:
|
42
|
-
\"\"\"
|
43
|
-
hello world!
|
44
|
-
hola
|
45
|
-
\"\"\"
|
46
|
-
And the stdout should not contain anything
|
47
|
-
"""
|
48
|
-
When I run `cucumber`
|
49
|
-
Then the features should all pass
|
50
|
-
|
51
|
-
Scenario: Detect stderr from named source
|
52
|
-
Given a file named "features/output.feature" with:
|
53
|
-
"""
|
54
|
-
Feature: Run command
|
55
|
-
Scenario: Run command
|
56
|
-
When I run `bash -c 'printf hello >&2'`
|
57
|
-
And I run `printf goodbye`
|
58
|
-
Then the stderr from "bash -c 'printf hello >&2'" should contain "hello"
|
59
|
-
And the stderr from "bash -c 'printf hello >&2'" should contain exactly "hello"
|
60
|
-
And the stderr from "bash -c 'printf hello >&2'" should contain exactly:
|
61
|
-
\"\"\"
|
62
|
-
hello
|
63
|
-
\"\"\"
|
64
|
-
And the stdout from "bash -c 'printf hello >&2'" should not contain "hello"
|
65
|
-
And the stderr from "printf goodbye" should not contain "hello"
|
66
|
-
"""
|
67
|
-
When I run `cucumber`
|
68
|
-
Then the features should all pass
|
@@ -1,109 +0,0 @@
|
|
1
|
-
Feature: STDOUT of commands which were executed
|
2
|
-
|
3
|
-
In order to specify expected output
|
4
|
-
As a developer using Cucumber
|
5
|
-
I want to use the "the stdout should contain" step
|
6
|
-
|
7
|
-
Background:
|
8
|
-
Given I use a fixture named "cli-app"
|
9
|
-
|
10
|
-
Scenario: Match output in stdout
|
11
|
-
Given an executable named "bin/aruba-test-cli" with:
|
12
|
-
"""bash
|
13
|
-
#!/usr/bin/env bash
|
14
|
-
|
15
|
-
echo -e "hello\nworld"
|
16
|
-
"""
|
17
|
-
And a file named "features/output.feature" with:
|
18
|
-
"""cucumber
|
19
|
-
Feature: Run command
|
20
|
-
Scenario: Run command
|
21
|
-
When I run `aruba-test-cli`
|
22
|
-
Then the stdout should contain "hello"
|
23
|
-
Then the stderr should not contain "hello"
|
24
|
-
"""
|
25
|
-
When I run `cucumber`
|
26
|
-
Then the features should all pass
|
27
|
-
|
28
|
-
Scenario: Match stdout on several lines
|
29
|
-
Given an executable named "bin/aruba-test-cli" with:
|
30
|
-
"""bash
|
31
|
-
#!/usr/bin/env bash
|
32
|
-
|
33
|
-
echo 'GET /'
|
34
|
-
"""
|
35
|
-
And a file named "features/output.feature" with:
|
36
|
-
"""cucumber
|
37
|
-
Feature: Run command
|
38
|
-
Scenario: Run command
|
39
|
-
When I run `aruba-test-cli`
|
40
|
-
Then the stdout should contain:
|
41
|
-
\"\"\"
|
42
|
-
GET /
|
43
|
-
\"\"\"
|
44
|
-
"""
|
45
|
-
When I run `cucumber`
|
46
|
-
Then the features should all pass
|
47
|
-
|
48
|
-
Scenario: Match output on several lines where stdout contains quotes
|
49
|
-
Given an executable named "bin/aruba-test-cli" with:
|
50
|
-
"""bash
|
51
|
-
#!/usr/bin/env bash
|
52
|
-
|
53
|
-
echo 'GET "/"'
|
54
|
-
"""
|
55
|
-
And a file named "features/output.feature" with:
|
56
|
-
"""cucumber
|
57
|
-
Feature: Run command
|
58
|
-
Scenario: Run command
|
59
|
-
When I run `aruba-test-cli`
|
60
|
-
Then the stdout should contain:
|
61
|
-
\"\"\"
|
62
|
-
GET "/"
|
63
|
-
\"\"\"
|
64
|
-
"""
|
65
|
-
When I run `cucumber`
|
66
|
-
Then the features should all pass
|
67
|
-
|
68
|
-
Scenario: Detect stdout from all processes including interactive ones
|
69
|
-
Given a file named "features/output.feature" with:
|
70
|
-
"""
|
71
|
-
Feature: Run command
|
72
|
-
Scenario: Run command
|
73
|
-
When I run `printf "hello world!\n"`
|
74
|
-
And I run `cat` interactively
|
75
|
-
And I type "hola"
|
76
|
-
And I type ""
|
77
|
-
Then the stdout should contain:
|
78
|
-
\"\"\"
|
79
|
-
hello world!
|
80
|
-
\"\"\"
|
81
|
-
And the stdout should contain:
|
82
|
-
\"\"\"
|
83
|
-
hola
|
84
|
-
\"\"\"
|
85
|
-
And the stderr should not contain anything
|
86
|
-
"""
|
87
|
-
When I run `cucumber`
|
88
|
-
Then the features should all pass
|
89
|
-
|
90
|
-
Scenario: Detect stdout from named source
|
91
|
-
Given a file named "features/output.feature" with:
|
92
|
-
"""
|
93
|
-
Feature: Run command
|
94
|
-
Scenario: Run command
|
95
|
-
When I run `printf 'hello'`
|
96
|
-
And I run `printf 'goodbye'`
|
97
|
-
Then the stdout from "printf 'hello'" should contain "hello"
|
98
|
-
And the stdout from "printf 'hello'" should contain exactly "hello"
|
99
|
-
And the stdout from "printf 'hello'" should contain exactly:
|
100
|
-
\"\"\"
|
101
|
-
hello
|
102
|
-
\"\"\"
|
103
|
-
And the stderr from "printf 'hello'" should not contain "hello"
|
104
|
-
And the stdout from "printf 'goodbye'" should not contain "hello"
|
105
|
-
"""
|
106
|
-
When I run `cucumber`
|
107
|
-
Then the features should all pass
|
108
|
-
|
109
|
-
|
data/features/03_testing_frameworks/cucumber/steps/command/debug_your_command_in_aruba.feature
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
Feature: Debug your command in cucumber-test-run
|
2
|
-
|
3
|
-
As a developer
|
4
|
-
I want to use some debugger in my code and therefor need system() to execute my program
|
5
|
-
In order to find a bug
|
6
|
-
|
7
|
-
Background:
|
8
|
-
Given I use a fixture named "cli-app"
|
9
|
-
And the default aruba exit timeout is 60 seconds
|
10
|
-
|
11
|
-
Scenario: Can handle exit status 0
|
12
|
-
Given an executable named "bin/aruba-test-cli" with:
|
13
|
-
"""bash
|
14
|
-
#!/usr/bin/env bash
|
15
|
-
|
16
|
-
exit 0
|
17
|
-
"""
|
18
|
-
And a file named "features/debug.feature" with:
|
19
|
-
"""cucumber
|
20
|
-
Feature: Exit status in debug environment
|
21
|
-
|
22
|
-
@debug
|
23
|
-
Scenario: Run program with debug code
|
24
|
-
When I run `aruba-test-cli`
|
25
|
-
Then the exit status should be 0
|
26
|
-
"""
|
27
|
-
When I successfully run `cucumber`
|
28
|
-
Then the features should all pass
|
29
|
-
|
30
|
-
Scenario: Can handle exit status 1
|
31
|
-
Given an executable named "bin/aruba-test-cli" with:
|
32
|
-
"""bash
|
33
|
-
#!/usr/bin/env bash
|
34
|
-
|
35
|
-
exit 1
|
36
|
-
"""
|
37
|
-
And a file named "features/debug.feature" with:
|
38
|
-
"""cucumber
|
39
|
-
Feature: Exit status in debug environment
|
40
|
-
|
41
|
-
@debug
|
42
|
-
Scenario: Run program with debug code
|
43
|
-
When I run `aruba-test-cli`
|
44
|
-
Then the exit status should be 1
|
45
|
-
"""
|
46
|
-
When I successfully run `cucumber`
|
47
|
-
Then the features should all pass
|
48
|
-
|
49
|
-
Scenario: You can use a debug repl in your cli program
|
50
|
-
|
51
|
-
If you want to debug a strange error, which only occures in one of your
|
52
|
-
`cucumber`-tests, the `@debug`-tag becomes handy. You can add `@debug` in
|
53
|
-
front of your feature/scenario to make `binding.pry` or `byebug` work in
|
54
|
-
your program.
|
55
|
-
|
56
|
-
Please make sure, that there's a statement after the `binding.pry`-call.
|
57
|
-
Otherwise you might not get an interactive shell, because your program will
|
58
|
-
just exit.
|
59
|
-
|
60
|
-
We are going to demonstrate this using `pry`, but any other interactive
|
61
|
-
debugger for any other programming language should also work.
|
62
|
-
|
63
|
-
Given an executable named "bin/aruba-test-cli" with:
|
64
|
-
"""ruby
|
65
|
-
#!/usr/bin/env ruby
|
66
|
-
|
67
|
-
$stderr.sync = true
|
68
|
-
$stdout.sync = true
|
69
|
-
|
70
|
-
require 'pry'
|
71
|
-
binding.pry
|
72
|
-
|
73
|
-
exit 0
|
74
|
-
"""
|
75
|
-
And a file named "features/debug.feature" with:
|
76
|
-
"""cucumber
|
77
|
-
Feature: Exit status in debug environment
|
78
|
-
|
79
|
-
@debug
|
80
|
-
Scenario: Run program with debug code
|
81
|
-
When I run `aruba-test-cli`
|
82
|
-
Then the exit status should be 0
|
83
|
-
"""
|
84
|
-
When I run `cucumber` interactively
|
85
|
-
And I stop the command started last if output contains:
|
86
|
-
"""
|
87
|
-
pry(main)>
|
88
|
-
"""
|
89
|
-
Then the output should match:
|
90
|
-
"""
|
91
|
-
7:\s+binding.pry
|
92
|
-
"""
|
93
|
-
|
94
|
-
Scenario: Can handle announcers
|
95
|
-
Given an executable named "bin/aruba-test-cli" with:
|
96
|
-
"""bash
|
97
|
-
#!/usr/bin/env bash
|
98
|
-
|
99
|
-
exit 0
|
100
|
-
"""
|
101
|
-
And a file named "features/debug.feature" with:
|
102
|
-
"""cucumber
|
103
|
-
Feature: Exit status in debug environment
|
104
|
-
|
105
|
-
@debug
|
106
|
-
@announce
|
107
|
-
Scenario: Run program with debug code
|
108
|
-
When I run `aruba-test-cli`
|
109
|
-
Then the exit status should be 0
|
110
|
-
"""
|
111
|
-
When I successfully run `cucumber`
|
112
|
-
Then the features should all pass
|
113
|
-
And the output should contain:
|
114
|
-
"""
|
115
|
-
<<-STDOUT
|
116
|
-
This is the debug launcher on STDOUT. If this output is unexpected, please check your setup.
|
117
|
-
STDOUT
|
118
|
-
"""
|
@@ -1,66 +0,0 @@
|
|
1
|
-
Feature: Run commands
|
2
|
-
|
3
|
-
There are several steps to run commands with `aruba`.
|
4
|
-
|
5
|
-
Background:
|
6
|
-
Given I use a fixture named "cli-app"
|
7
|
-
|
8
|
-
Scenario: Run command found in path
|
9
|
-
Given an executable named "bin/aruba-test-cli" with:
|
10
|
-
"""
|
11
|
-
#!/bin/bash
|
12
|
-
exit 0
|
13
|
-
"""
|
14
|
-
And a file named "features/run.feature" with:
|
15
|
-
"""
|
16
|
-
Feature: Run it
|
17
|
-
Scenario: Run command
|
18
|
-
When I run `aruba-test-cli`
|
19
|
-
"""
|
20
|
-
When I run `cucumber`
|
21
|
-
Then the features should all pass
|
22
|
-
|
23
|
-
Scenario: Activate desired announcers when running command fails
|
24
|
-
Given an executable named "bin/aruba-test-cli" with:
|
25
|
-
"""
|
26
|
-
#!/bin/bash
|
27
|
-
echo "Hello, I'm STDOUT"
|
28
|
-
exit 1
|
29
|
-
"""
|
30
|
-
And a file named "features/run.feature" with:
|
31
|
-
"""
|
32
|
-
Feature: Run it
|
33
|
-
Scenario: Run command
|
34
|
-
When I successfully run `aruba-test-cli`
|
35
|
-
"""
|
36
|
-
And I append to "features/support/env.rb" with:
|
37
|
-
"""
|
38
|
-
Before do
|
39
|
-
aruba.config.activate_announcer_on_command_failure = [:stdout]
|
40
|
-
end
|
41
|
-
"""
|
42
|
-
When I run `cucumber`
|
43
|
-
Then the features should not pass
|
44
|
-
And the output should contain:
|
45
|
-
"""
|
46
|
-
<<-STDOUT
|
47
|
-
Hello, I'm STDOUT
|
48
|
-
|
49
|
-
STDOUT
|
50
|
-
"""
|
51
|
-
|
52
|
-
Scenario: Run command found in "bin"-directory which is found in the current directory
|
53
|
-
Given a file named "features/run.feature" with:
|
54
|
-
"""
|
55
|
-
Feature: Run it
|
56
|
-
Scenario: Run command
|
57
|
-
Given an executable named "bin/local_cli" with:
|
58
|
-
\"\"\"
|
59
|
-
#!/bin/bash
|
60
|
-
exit 0
|
61
|
-
\"\"\"
|
62
|
-
And I look for executables in "bin" within the current directory
|
63
|
-
When I successfully run `local_cli`
|
64
|
-
"""
|
65
|
-
When I run `cucumber`
|
66
|
-
Then the features should all pass
|
@@ -1,485 +0,0 @@
|
|
1
|
-
Feature: Run commands in ruby process
|
2
|
-
Running a lot of scenarios where each scenario uses Aruba
|
3
|
-
to spawn a new ruby process can be time consuming.
|
4
|
-
|
5
|
-
Aruba lets you plug in your own process class that can
|
6
|
-
run a command in the same ruby process as Cucumber/Aruba.
|
7
|
-
|
8
|
-
We expect that the command supports the following API. It needs to accept:
|
9
|
-
argv, stdin, stdout, stderr and kernel on `#initialize` and it needs to have
|
10
|
-
an `execute!`-method.
|
11
|
-
|
12
|
-
```ruby
|
13
|
-
module Cli
|
14
|
-
module App
|
15
|
-
class Runner
|
16
|
-
def initialize(argv, stdin, stdout, stderr, kernel)
|
17
|
-
\@argv = argv
|
18
|
-
\@stdin = stdin
|
19
|
-
\@stdout = stdout
|
20
|
-
\@stderr = stderr
|
21
|
-
\@kernel = kernel
|
22
|
-
end
|
23
|
-
|
24
|
-
def execute!
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
```
|
30
|
-
|
31
|
-
The switch to the working directory takes place around the `execute!`-method.
|
32
|
-
If needed make sure, that you determine the current working directory within
|
33
|
-
code called by the `execute!`-method or just use `Dir.getwd` during "runtime"
|
34
|
-
and not during "loadtime", when the `ruby`-interpreter reads in you class
|
35
|
-
files.
|
36
|
-
|
37
|
-
*Pros*:
|
38
|
-
* Very fast compared to spawning processes
|
39
|
-
* You can use libraries like
|
40
|
-
[simplecov](https://github.com/colszowka/simplecov) more easily, because
|
41
|
-
there is only one "process" which adds data to `simplecov`'s database
|
42
|
-
|
43
|
-
*Cons*:
|
44
|
-
* You might oversee some bugs: You might forget to require libraries in your
|
45
|
-
"production" code, because you have required them in your testing code
|
46
|
-
* Using `:in_process` interactively is not supported
|
47
|
-
|
48
|
-
**WARNING**: Using `:in_process` interactively is not supported
|
49
|
-
|
50
|
-
Background:
|
51
|
-
Given I use a fixture named "cli-app"
|
52
|
-
And a file named "features/support/cli_app.rb" with:
|
53
|
-
"""
|
54
|
-
require 'cli/app/runner'
|
55
|
-
"""
|
56
|
-
And a file named "features/support/in_proccess.rb" with:
|
57
|
-
"""
|
58
|
-
require 'aruba/cucumber'
|
59
|
-
|
60
|
-
Before('@in-process') do
|
61
|
-
aruba.config.command_launcher = :in_process
|
62
|
-
aruba.config.main_class = Cli::App::Runner
|
63
|
-
end
|
64
|
-
|
65
|
-
After('@in-process') do
|
66
|
-
aruba.config.command_launcher = :spawn
|
67
|
-
end
|
68
|
-
"""
|
69
|
-
|
70
|
-
Scenario: Run custom code
|
71
|
-
Given a file named "lib/cli/app/runner.rb" with:
|
72
|
-
"""
|
73
|
-
module Cli
|
74
|
-
module App
|
75
|
-
class Runner
|
76
|
-
def initialize(argv, stdin, stdout, stderr, kernel)
|
77
|
-
@argv = argv
|
78
|
-
@stdin = stdin
|
79
|
-
@stdout = stdout
|
80
|
-
@stderr = stderr
|
81
|
-
@kernel = kernel
|
82
|
-
end
|
83
|
-
|
84
|
-
def execute!
|
85
|
-
@stdout.puts(@argv.map(&:reverse).join(' '))
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
"""
|
91
|
-
And a file named "features/in_process.feature" with:
|
92
|
-
"""
|
93
|
-
Feature: Run a command in process
|
94
|
-
@in-process
|
95
|
-
Scenario: Run command
|
96
|
-
When I run `reverse.rb Hello World`
|
97
|
-
Then the output should contain:
|
98
|
-
\"\"\"
|
99
|
-
olleH dlroW
|
100
|
-
\"\"\"
|
101
|
-
"""
|
102
|
-
When I run `cucumber`
|
103
|
-
Then the features should all pass
|
104
|
-
|
105
|
-
Scenario: Mixing custom code and normal cli
|
106
|
-
Given an executable named "bin/aruba-test-cli" with:
|
107
|
-
"""
|
108
|
-
#!/bin/bash
|
109
|
-
echo $*
|
110
|
-
"""
|
111
|
-
And a file named "lib/cli/app/runner.rb" with:
|
112
|
-
"""
|
113
|
-
module Cli
|
114
|
-
module App
|
115
|
-
class Runner
|
116
|
-
def initialize(argv, stdin, stdout, stderr, kernel)
|
117
|
-
@argv = argv
|
118
|
-
@stdin = stdin
|
119
|
-
@stdout = stdout
|
120
|
-
@stderr = stderr
|
121
|
-
@kernel = kernel
|
122
|
-
end
|
123
|
-
|
124
|
-
def execute!
|
125
|
-
@stdout.puts(@argv.map(&:reverse).join(' '))
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
"""
|
131
|
-
And a file named "features/in_process.feature" with:
|
132
|
-
"""
|
133
|
-
Feature: Run a command in process
|
134
|
-
@in-process
|
135
|
-
Scenario: Run command in process
|
136
|
-
When I run `reverse.rb Hello World`
|
137
|
-
Then the output should contain:
|
138
|
-
\"\"\"
|
139
|
-
olleH dlroW
|
140
|
-
\"\"\"
|
141
|
-
|
142
|
-
Scenario: Run command
|
143
|
-
When I run `aruba-test-cli Hello World`
|
144
|
-
Then the output should contain:
|
145
|
-
\"\"\"
|
146
|
-
Hello World
|
147
|
-
\"\"\"
|
148
|
-
"""
|
149
|
-
When I run `cucumber`
|
150
|
-
Then the features should all pass
|
151
|
-
|
152
|
-
Scenario: The current working directory is changed as well
|
153
|
-
Given a file named "lib/cli/app/runner.rb" with:
|
154
|
-
"""
|
155
|
-
module Cli
|
156
|
-
module App
|
157
|
-
class Runner
|
158
|
-
def initialize(argv, stdin, stdout, stderr, kernel)
|
159
|
-
@argv = argv
|
160
|
-
@stdin = stdin
|
161
|
-
@stdout = stdout
|
162
|
-
@stderr = stderr
|
163
|
-
@kernel = kernel
|
164
|
-
end
|
165
|
-
|
166
|
-
def execute!
|
167
|
-
@stdout.puts("PWD-ENV is " + Dir.getwd)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
"""
|
173
|
-
And a file named "features/in_process.feature" with:
|
174
|
-
"""
|
175
|
-
Feature: Run a command in process
|
176
|
-
@in-process
|
177
|
-
Scenario: Run command
|
178
|
-
When I run `pwd.rb`
|
179
|
-
Then the output should match %r<PWD-ENV.*tmp/aruba>
|
180
|
-
"""
|
181
|
-
When I run `cucumber`
|
182
|
-
Then the features should all pass
|
183
|
-
|
184
|
-
Scenario: The PWD environment is changed to current working directory
|
185
|
-
Given a file named "lib/cli/app/runner.rb" with:
|
186
|
-
"""
|
187
|
-
module Cli
|
188
|
-
module App
|
189
|
-
class Runner
|
190
|
-
def initialize(argv, stdin, stdout, stderr, kernel)
|
191
|
-
@argv = argv
|
192
|
-
@stdin = stdin
|
193
|
-
@stdout = stdout
|
194
|
-
@stderr = stderr
|
195
|
-
@kernel = kernel
|
196
|
-
end
|
197
|
-
|
198
|
-
def execute!
|
199
|
-
@stdout.puts("PWD-ENV is " + ENV['PWD'])
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
"""
|
205
|
-
And a file named "features/in_process.feature" with:
|
206
|
-
"""
|
207
|
-
Feature: Run a command in process
|
208
|
-
@in-process
|
209
|
-
Scenario: Run command
|
210
|
-
When I run `pwd.rb`
|
211
|
-
Then the output should match %r<PWD-ENV.*tmp/aruba>
|
212
|
-
"""
|
213
|
-
When I run `cucumber`
|
214
|
-
Then the features should all pass
|
215
|
-
|
216
|
-
Scenario: Set runner via "Aruba.process ="-method (deprecated)
|
217
|
-
Given a file named "features/support/in_proccess.rb" with:
|
218
|
-
"""
|
219
|
-
require 'aruba/cucumber'
|
220
|
-
require 'aruba/processes/in_process'
|
221
|
-
|
222
|
-
Before('@in-process') do
|
223
|
-
Aruba.process = Aruba::Processes::InProcess
|
224
|
-
Aruba.process.main_class = Cli::App::Runner
|
225
|
-
end
|
226
|
-
|
227
|
-
After('@in-process') do
|
228
|
-
Aruba.process = Aruba::Processes::SpawnProcess
|
229
|
-
end
|
230
|
-
"""
|
231
|
-
Given a file named "lib/cli/app/runner.rb" with:
|
232
|
-
"""
|
233
|
-
module Cli
|
234
|
-
module App
|
235
|
-
class Runner
|
236
|
-
def initialize(argv, stdin, stdout, stderr, kernel)
|
237
|
-
@argv = argv
|
238
|
-
@stdin = stdin
|
239
|
-
@stdout = stdout
|
240
|
-
@stderr = stderr
|
241
|
-
@kernel = kernel
|
242
|
-
end
|
243
|
-
|
244
|
-
def execute!
|
245
|
-
@stdout.puts(@argv.map(&:reverse).join(' '))
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|
250
|
-
"""
|
251
|
-
And a file named "features/in_process.feature" with:
|
252
|
-
"""
|
253
|
-
Feature: Run a command in process
|
254
|
-
@in-process
|
255
|
-
Scenario: Run command
|
256
|
-
When I run `reverse.rb Hello World`
|
257
|
-
Then the output should contain:
|
258
|
-
\"\"\"
|
259
|
-
olleH dlroW
|
260
|
-
\"\"\"
|
261
|
-
"""
|
262
|
-
When I run `cucumber`
|
263
|
-
Then the features should all pass
|
264
|
-
|
265
|
-
Scenario: Set runner via "Aruba.process ="-method and use old class name Aruba::InProcess (deprecated)
|
266
|
-
Given a file named "features/support/in_proccess.rb" with:
|
267
|
-
"""
|
268
|
-
require 'aruba/cucumber'
|
269
|
-
require 'aruba/in_process'
|
270
|
-
require 'aruba/spawn_process'
|
271
|
-
|
272
|
-
Before('@in-process') do
|
273
|
-
Aruba.process = Aruba::InProcess
|
274
|
-
Aruba.process.main_class = Cli::App::Runner
|
275
|
-
end
|
276
|
-
|
277
|
-
After('@in-process') do
|
278
|
-
Aruba.process = Aruba::SpawnProcess
|
279
|
-
end
|
280
|
-
"""
|
281
|
-
Given a file named "lib/cli/app/runner.rb" with:
|
282
|
-
"""
|
283
|
-
module Cli
|
284
|
-
module App
|
285
|
-
class Runner
|
286
|
-
def initialize(argv, stdin, stdout, stderr, kernel)
|
287
|
-
@argv = argv
|
288
|
-
@stdin = stdin
|
289
|
-
@stdout = stdout
|
290
|
-
@stderr = stderr
|
291
|
-
@kernel = kernel
|
292
|
-
end
|
293
|
-
|
294
|
-
def execute!
|
295
|
-
@stdout.puts(@argv.map(&:reverse).join(' '))
|
296
|
-
end
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end
|
300
|
-
"""
|
301
|
-
And a file named "features/in_process.feature" with:
|
302
|
-
"""
|
303
|
-
Feature: Run a command in process
|
304
|
-
@in-process
|
305
|
-
Scenario: Run command
|
306
|
-
When I run `reverse.rb Hello World`
|
307
|
-
Then the output should contain:
|
308
|
-
\"\"\"
|
309
|
-
olleH dlroW
|
310
|
-
\"\"\"
|
311
|
-
"""
|
312
|
-
When I run `cucumber`
|
313
|
-
Then the features should all pass
|
314
|
-
|
315
|
-
Scenario: Use $stderr, $stdout and $stdin to access IO
|
316
|
-
|
317
|
-
May may need/want to use the default `STDERR`, `STDOUT`, `STDIN`-constants
|
318
|
-
to access IO from within your script. Unfortunately this does not work with
|
319
|
-
the `:in_process`-command launcher. You need to use `$stderr`, `$stdout`
|
320
|
-
and `$stdin` instead.
|
321
|
-
|
322
|
-
For this example I chose `thor` to parse ARGV. Its `.start`-method accepts
|
323
|
-
an "Array" as ARGV and a "Hash" for some other options – `.start <ARGV>, <OPTIONS>`
|
324
|
-
|
325
|
-
Given a file named "lib/cli/app/runner.rb" with:
|
326
|
-
"""
|
327
|
-
require 'cli/app/cli_parser'
|
328
|
-
|
329
|
-
module Cli
|
330
|
-
module App
|
331
|
-
class Runner
|
332
|
-
def initialize(argv, stdin, stdout, stderr, kernel)
|
333
|
-
@argv = argv
|
334
|
-
$kernel = kernel
|
335
|
-
$stdin = stdin
|
336
|
-
$stdout = stdout
|
337
|
-
$stderr = stderr
|
338
|
-
end
|
339
|
-
|
340
|
-
def execute!
|
341
|
-
Cli::App::CliParser.start @argv
|
342
|
-
end
|
343
|
-
end
|
344
|
-
end
|
345
|
-
end
|
346
|
-
"""
|
347
|
-
And a file named "lib/cli/app/cli_parser.rb" with:
|
348
|
-
"""
|
349
|
-
require 'thor'
|
350
|
-
|
351
|
-
module Cli
|
352
|
-
module App
|
353
|
-
class CliParser < Thor
|
354
|
-
def self.exit_on_failure?
|
355
|
-
true
|
356
|
-
end
|
357
|
-
|
358
|
-
desc 'do_it', 'Reverse input'
|
359
|
-
def do_it(*args)
|
360
|
-
$stderr.puts 'Hey ya, Hey ya, check, check, check'
|
361
|
-
$stdout.puts(args.flatten.map(&:reverse).join(' '))
|
362
|
-
end
|
363
|
-
end
|
364
|
-
end
|
365
|
-
end
|
366
|
-
"""
|
367
|
-
And a file named "features/in_process.feature" with:
|
368
|
-
"""
|
369
|
-
Feature: Run a command in process
|
370
|
-
@in-process
|
371
|
-
Scenario: Run command
|
372
|
-
When I run `reverse.rb do_it Hello World`
|
373
|
-
Then the stdout should contain:
|
374
|
-
\"\"\"
|
375
|
-
olleH dlroW
|
376
|
-
\"\"\"
|
377
|
-
And the stderr should contain:
|
378
|
-
\"\"\"
|
379
|
-
Hey ya, Hey ya, check, check, check
|
380
|
-
\"\"\"
|
381
|
-
"""
|
382
|
-
When I run `cucumber`
|
383
|
-
Then the features should all pass
|
384
|
-
|
385
|
-
Scenario: Use $kernel to use Kernel to capture exit code
|
386
|
-
|
387
|
-
Ruby's `Kernel`-module provides some helper methods like `exit`.
|
388
|
-
Unfortunately running `#exit` with `:in_process` would make the whole ruby
|
389
|
-
interpreter exit. So you might want to use our `FakeKernel`-module module
|
390
|
-
instead which overwrites `#exit`. This will also make our tests for
|
391
|
-
checking the exit code work. This example also uses the `thor`-library.
|
392
|
-
|
393
|
-
Given a file named "lib/cli/app/runner.rb" with:
|
394
|
-
"""
|
395
|
-
require 'cli/app/cli_parser'
|
396
|
-
|
397
|
-
module Cli
|
398
|
-
module App
|
399
|
-
class Runner
|
400
|
-
def initialize(argv, stdin, stdout, stderr, kernel)
|
401
|
-
@argv = argv
|
402
|
-
$kernel = kernel
|
403
|
-
$stdin = stdin
|
404
|
-
$stdout = stdout
|
405
|
-
$stderr = stderr
|
406
|
-
end
|
407
|
-
|
408
|
-
def execute!
|
409
|
-
Cli::App::CliParser.start @argv
|
410
|
-
end
|
411
|
-
end
|
412
|
-
end
|
413
|
-
end
|
414
|
-
"""
|
415
|
-
And a file named "lib/cli/app/cli_parser.rb" with:
|
416
|
-
"""
|
417
|
-
require 'thor'
|
418
|
-
|
419
|
-
module Cli
|
420
|
-
module App
|
421
|
-
class CliParser < Thor
|
422
|
-
def self.exit_on_failure?
|
423
|
-
true
|
424
|
-
end
|
425
|
-
|
426
|
-
desc 'do_it', 'Reverse input'
|
427
|
-
def do_it(*args)
|
428
|
-
$kernel.exit 5
|
429
|
-
end
|
430
|
-
end
|
431
|
-
end
|
432
|
-
end
|
433
|
-
"""
|
434
|
-
And a file named "features/in_process.feature" with:
|
435
|
-
"""
|
436
|
-
Feature: Run a command in process
|
437
|
-
@in-process
|
438
|
-
Scenario: Run command
|
439
|
-
When I run `reverse.rb do_it`
|
440
|
-
Then the exit status should be 5
|
441
|
-
"""
|
442
|
-
When I run `cucumber`
|
443
|
-
Then the features should all pass
|
444
|
-
|
445
|
-
Scenario: Using `:in_process` interactively is not supported
|
446
|
-
|
447
|
-
Reading from STDIN blocks ruby from going on. But writing to STDIN - e.g.
|
448
|
-
type some letters on keyboard - can only appear later, but this point is
|
449
|
-
never reached, because ruby is blocked.
|
450
|
-
|
451
|
-
Given the default aruba exit timeout is 5 seconds
|
452
|
-
And a file named "lib/cli/app/runner.rb" with:
|
453
|
-
"""
|
454
|
-
module Cli
|
455
|
-
module App
|
456
|
-
class Runner
|
457
|
-
def initialize(argv, stdin, stdout, stderr, kernel)
|
458
|
-
@stdin = stdin
|
459
|
-
end
|
460
|
-
|
461
|
-
def execute!
|
462
|
-
while res = @stdin.gets.to_s.chomp
|
463
|
-
break if res == 'quit'
|
464
|
-
puts res.reverse
|
465
|
-
end
|
466
|
-
end
|
467
|
-
end
|
468
|
-
end
|
469
|
-
end
|
470
|
-
"""
|
471
|
-
And a file named "features/in_process.feature" with:
|
472
|
-
"""
|
473
|
-
Feature: Run a command in process
|
474
|
-
@in-process
|
475
|
-
Scenario: Run command
|
476
|
-
Given the default aruba exit timeout is 2 seconds
|
477
|
-
When I run `reverse.rb do_it` interactively
|
478
|
-
When I type "hello"
|
479
|
-
Then the output should contain:
|
480
|
-
\"\"\"
|
481
|
-
hello
|
482
|
-
\"\"\"
|
483
|
-
"""
|
484
|
-
When I run `cucumber`
|
485
|
-
Then the exit status should not be 0
|