aruba 0.14.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.cucumberproignore +3 -0
- data/.github/ISSUE_TEMPLATE.md +48 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +41 -0
- data/.gitignore +1 -0
- data/.rspec +1 -1
- data/.rubocop.yml +20 -179
- data/.rubocop_todo.yml +262 -0
- data/.simplecov +7 -5
- data/.travis.yml +54 -46
- data/.yardopts +3 -0
- data/CHANGELOG.md +613 -246
- data/CONTRIBUTING.md +247 -45
- data/Dockerfile +67 -0
- data/Gemfile +5 -96
- data/LICENSE +1 -1
- data/README.md +57 -180
- data/Rakefile +63 -32
- data/appveyor.yml +8 -11
- data/aruba.gemspec +47 -41
- data/bin/console +7 -0
- data/bin/test +9 -0
- data/cucumber.yml +4 -24
- data/doc/dependency_decisions.yml +42 -2
- data/docker-compose.yml +26 -0
- data/{bin → exe}/aruba +1 -1
- data/fixtures/cli-app/Rakefile +1 -1
- data/fixtures/cli-app/bin/aruba-test-cli +6 -0
- data/fixtures/cli-app/cli-app.gemspec +1 -2
- 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/suppress_simple_cov_output.rb +3 -3
- data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
- data/fixtures/cli-app/lib/cli/app.rb +1 -5
- data/fixtures/cli-app/spec/spec_helper.rb +4 -6
- data/fixtures/empty-app/Rakefile +1 -1
- data/fixtures/empty-app/cli-app.gemspec +1 -2
- data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
- data/fixtures/empty-app/lib/cli/app.rb +0 -6
- data/fixtures/getting-started-app/Gemfile +1 -1
- data/lib/aruba/api/commands.rb +109 -143
- data/lib/aruba/api/core.rb +57 -43
- data/lib/aruba/api/environment.rb +16 -7
- data/lib/aruba/api/filesystem.rb +42 -29
- data/lib/aruba/api/text.rb +3 -9
- data/lib/aruba/api.rb +6 -11
- data/lib/aruba/aruba_path.rb +27 -89
- data/lib/aruba/basic_configuration.rb +4 -24
- data/lib/aruba/cli.rb +1 -1
- data/lib/aruba/colorizer.rb +10 -99
- data/lib/aruba/command.rb +2 -0
- data/lib/aruba/config/jruby.rb +15 -5
- data/lib/aruba/config_wrapper.rb +1 -1
- data/lib/aruba/configuration.rb +92 -0
- data/lib/aruba/console/help.rb +1 -7
- data/lib/aruba/console.rb +5 -5
- data/lib/aruba/contracts/absolute_path.rb +2 -2
- data/lib/aruba/contracts/relative_path.rb +2 -2
- data/lib/aruba/cucumber/command.rb +171 -160
- data/lib/aruba/cucumber/environment.rb +1 -1
- data/lib/aruba/cucumber/file.rb +21 -35
- data/lib/aruba/cucumber/hooks.rb +17 -56
- data/lib/aruba/cucumber/testing_frameworks.rb +74 -50
- data/lib/aruba/cucumber.rb +0 -5
- data/lib/aruba/event_bus/name_resolver.rb +5 -16
- data/lib/aruba/hooks.rb +1 -1
- data/lib/aruba/in_config_wrapper.rb +5 -1
- data/lib/aruba/initializer.rb +36 -42
- data/lib/aruba/matchers/base/base_matcher.rb +2 -2
- data/lib/aruba/matchers/base/message_indenter.rb +19 -0
- data/lib/aruba/matchers/base/object_formatter.rb +2 -9
- data/lib/aruba/matchers/collection/include_an_object.rb +7 -9
- data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -4
- data/lib/aruba/matchers/command/have_exit_status.rb +14 -4
- data/lib/aruba/matchers/command/have_finished_in_time.rb +3 -5
- data/lib/aruba/matchers/command/have_output.rb +10 -5
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +2 -2
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +2 -2
- data/lib/aruba/matchers/command/have_output_size.rb +2 -2
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
- data/lib/aruba/matchers/directory/have_sub_directory.rb +4 -6
- data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
- data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
- data/lib/aruba/matchers/file/have_file_content.rb +4 -4
- data/lib/aruba/matchers/file/have_file_size.rb +6 -8
- data/lib/aruba/matchers/file/have_same_file_content.rb +5 -8
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
- data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
- data/lib/aruba/matchers/path/have_permissions.rb +6 -8
- data/lib/aruba/matchers/string/include_output_string.rb +8 -10
- data/lib/aruba/matchers/string/match_output_string.rb +9 -11
- data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
- data/lib/aruba/platform.rb +0 -8
- data/lib/aruba/platforms/announcer.rb +42 -79
- data/lib/aruba/platforms/aruba_file_creator.rb +2 -6
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +2 -2
- data/lib/aruba/platforms/aruba_logger.rb +23 -7
- data/lib/aruba/platforms/command_monitor.rb +12 -107
- data/lib/aruba/platforms/determine_disk_usage.rb +56 -14
- data/lib/aruba/platforms/filesystem_status.rb +10 -14
- data/lib/aruba/platforms/local_environment.rb +2 -2
- data/lib/aruba/platforms/simple_table.rb +3 -11
- data/lib/aruba/platforms/unix_command_string.rb +7 -11
- data/lib/aruba/platforms/unix_environment_variables.rb +18 -27
- data/lib/aruba/platforms/unix_platform.rb +20 -51
- data/lib/aruba/platforms/unix_which.rb +2 -1
- data/lib/aruba/platforms/windows_command_string.rb +15 -10
- data/lib/aruba/platforms/windows_environment_variables.rb +43 -44
- data/lib/aruba/platforms/windows_platform.rb +4 -0
- data/lib/aruba/platforms/windows_which.rb +4 -3
- data/lib/aruba/processes/basic_process.rb +28 -30
- data/lib/aruba/processes/debug_process.rb +12 -3
- data/lib/aruba/processes/in_process.rb +17 -8
- data/lib/aruba/processes/spawn_process.rb +57 -46
- data/lib/aruba/rspec.rb +14 -36
- data/lib/aruba/runtime.rb +3 -6
- data/lib/aruba/setup.rb +6 -6
- data/lib/aruba/tasks/docker_helpers.rb +154 -0
- data/lib/aruba/version.rb +1 -1
- metadata +191 -244
- data/features/.nav +0 -72
- data/features/api/command/find_command.feature +0 -83
- data/features/api/command/last_command_started.feature +0 -50
- data/features/api/command/last_command_stopped.feature +0 -89
- data/features/api/command/run.feature +0 -414
- data/features/api/command/run_simple.feature +0 -242
- data/features/api/command/send_signal.feature +0 -53
- data/features/api/command/stderr.feature +0 -46
- data/features/api/command/stdout.feature +0 -46
- data/features/api/command/stop.feature +0 -131
- data/features/api/command/stop_all_commands.feature +0 -53
- data/features/api/command/terminate_all_commands.feature +0 -53
- data/features/api/command/which.feature +0 -37
- data/features/api/core/expand_path.feature +0 -88
- data/features/api/environment/append_environment_variable.feature +0 -128
- data/features/api/environment/delete_environment_variable.feature +0 -63
- data/features/api/environment/prepend_environment_variable.feature +0 -128
- data/features/api/environment/set_environment_variable.feature +0 -376
- data/features/api/filesystem/cd.feature +0 -184
- data/features/api/filesystem/create_directory.feature +0 -57
- data/features/api/filesystem/disk_usage.feature +0 -152
- data/features/api/filesystem/does_exist.feature +0 -62
- data/features/api/filesystem/fixtures.feature +0 -104
- data/features/api/filesystem/is_absolute.feature +0 -48
- data/features/api/filesystem/is_directory.feature +0 -53
- data/features/api/filesystem/is_file.feature +0 -54
- data/features/api/filesystem/is_relative.feature +0 -48
- data/features/api/filesystem/move.feature +0 -119
- data/features/api/text/extract_text.feature +0 -87
- data/features/api/text/replace_variables.feature +0 -45
- data/features/api/text/sanitize_text.feature +0 -228
- data/features/api/text/unescape_text.feature +0 -127
- data/features/cli/console.feature +0 -52
- data/features/cli/init.feature +0 -79
- data/features/configuration/activate_announcer_on_command_failure.feature +0 -38
- data/features/configuration/command_runtime_environment.feature +0 -129
- data/features/configuration/console_history_file.feature +0 -38
- data/features/configuration/exit_timeout.feature +0 -52
- data/features/configuration/fixtures_directories.feature +0 -38
- data/features/configuration/fixtures_path_prefix.feature +0 -23
- data/features/configuration/home_directory.feature +0 -80
- data/features/configuration/io_timeout.feature +0 -30
- data/features/configuration/keep_ansi.feature +0 -30
- data/features/configuration/log_level.feature +0 -38
- data/features/configuration/physical_block_size.feature +0 -53
- data/features/configuration/remove_ansi_escape_sequences.feature +0 -38
- data/features/configuration/root_directory.feature +0 -30
- data/features/configuration/startup_wait_time.feature +0 -48
- data/features/configuration/usage.feature +0 -159
- data/features/configuration/working_directory.feature +0 -33
- data/features/development/build.feature +0 -15
- data/features/getting_started/cleanup.feature +0 -58
- data/features/getting_started/run_commands.feature +0 -187
- data/features/getting_started/supported_testing_frameworks.feature +0 -104
- data/features/getting_started/writing_good_feature_tests.feature +0 -38
- data/features/hooks/after/command.feature +0 -46
- data/features/hooks/before/command.feature +0 -75
- data/features/matchers/collection/include_an_object.feature +0 -72
- data/features/matchers/directory/have_sub_directory.feature +0 -110
- data/features/matchers/file/be_a_command_found_in_path.feature +0 -115
- data/features/matchers/file/be_existing_executable.feature +0 -88
- data/features/matchers/file/be_existing_file.feature +0 -82
- data/features/matchers/file/have_file_content.feature +0 -123
- data/features/matchers/file/have_file_size.feature +0 -107
- data/features/matchers/path/be_an_absolute_path.feature +0 -74
- data/features/matchers/path/be_an_existing_path.feature +0 -97
- data/features/matchers/path/have_permissions.feature +0 -118
- data/features/matchers/timeouts.feature +0 -48
- data/features/platforms/jruby.feature +0 -14
- data/features/rspec/integration.feature +0 -179
- data/features/step_definitions/aruba_dev_steps.rb +0 -56
- data/features/step_definitions/hooks.rb +0 -156
- data/features/steps/command/debug.feature +0 -92
- data/features/steps/command/exit_statuses.feature +0 -136
- data/features/steps/command/in_process.feature +0 -485
- data/features/steps/command/interactive.feature +0 -90
- data/features/steps/command/output.feature +0 -567
- data/features/steps/command/run.feature +0 -66
- data/features/steps/command/send_signal.feature +0 -104
- data/features/steps/command/shell.feature +0 -155
- data/features/steps/command/stderr.feature +0 -68
- data/features/steps/command/stdout.feature +0 -109
- data/features/steps/command/stop.feature +0 -313
- data/features/steps/core/announce.feature +0 -283
- data/features/steps/environment/append_environment_variable.feature +0 -52
- data/features/steps/environment/disable_bunder.feature +0 -18
- data/features/steps/environment/home_variable.feature +0 -62
- data/features/steps/environment/prepend_environment_variable.feature +0 -52
- data/features/steps/environment/set_environment_variable.feature +0 -49
- data/features/steps/filesystem/append_to_file.feature +0 -45
- data/features/steps/filesystem/cd_to_directory.feature +0 -33
- data/features/steps/filesystem/check_file_content.feature +0 -61
- data/features/steps/filesystem/check_permissions_of_file.feature +0 -39
- data/features/steps/filesystem/compare_files.feature +0 -42
- data/features/steps/filesystem/copy.feature +0 -45
- data/features/steps/filesystem/create_directory.feature +0 -57
- data/features/steps/filesystem/create_file.feature +0 -76
- data/features/steps/filesystem/existence_of_directory.feature +0 -57
- data/features/steps/filesystem/existence_of_file.feature +0 -43
- data/features/steps/filesystem/file_content.feature +0 -86
- data/features/steps/filesystem/fixtures.feature +0 -64
- data/features/steps/filesystem/move.feature +0 -45
- data/features/steps/filesystem/non_existence_of_directory.feature +0 -69
- data/features/steps/filesystem/non_existence_of_file.feature +0 -80
- data/features/steps/filesystem/overwrite_file.feature +0 -72
- data/features/steps/filesystem/remove_directory.feature +0 -38
- data/features/steps/filesystem/remove_file.feature +0 -38
- data/features/steps/filesystem/use_fixture.feature +0 -77
- data/features/steps/overview.feature +0 -25
- data/features/support/aruba.rb +0 -7
- data/features/support/env.rb +0 -33
- data/features/support/jruby.rb +0 -5
- data/features/support/simplecov_setup.rb +0 -8
- data/fixtures/cli-app/bin/cli +0 -6
- data/fixtures/spawn_process/stderr.sh +0 -3
- data/lib/aruba/api/deprecated.rb +0 -1234
- data/lib/aruba/config.rb +0 -107
- data/lib/aruba/cucumber/core.rb +0 -5
- data/lib/aruba/cucumber/rvm.rb +0 -3
- data/lib/aruba/in_process.rb +0 -14
- data/lib/aruba/jruby.rb +0 -4
- data/lib/aruba/matchers/deprecated/file.rb +0 -17
- data/lib/aruba/matchers/deprecated.rb +0 -1
- data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
- data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
- data/lib/aruba/reporting.rb +0 -126
- data/lib/aruba/spawn_process.rb +0 -11
- data/script/bootstrap +0 -28
- data/script/console +0 -16
- data/script/test +0 -3
- data/spec/aruba/api/bundler_spec.rb +0 -15
- data/spec/aruba/api/deprecated_spec.rb +0 -308
- data/spec/aruba/api/environment/restore_env_spec.rb +0 -86
- data/spec/aruba/api/environment/set_env_spec.rb +0 -46
- data/spec/aruba/api/filesystem/file_size_spec.rb +0 -28
- data/spec/aruba/api/runtime_spec.rb +0 -28
- data/spec/aruba/api_spec.rb +0 -981
- 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 -55
- 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/rspec_spec.rb +0 -15
- data/spec/aruba/runtime_spec.rb +0 -29
- data/spec/aruba/spawn_process_spec.rb +0 -96
- data/spec/event_bus/name_resolver_spec.rb +0 -68
- data/spec/event_bus_spec.rb +0 -158
- data/spec/spec_helper.rb +0 -20
- 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
data/spec/aruba/api_spec.rb
DELETED
|
@@ -1,981 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
require 'aruba/api'
|
|
3
|
-
require 'fileutils'
|
|
4
|
-
|
|
5
|
-
describe Aruba::Api do
|
|
6
|
-
include_context 'uses aruba API'
|
|
7
|
-
|
|
8
|
-
describe '#all_paths' do
|
|
9
|
-
let(:name) { @file_name }
|
|
10
|
-
let(:path) { @file_path }
|
|
11
|
-
|
|
12
|
-
context 'when file exist' do
|
|
13
|
-
before :each do
|
|
14
|
-
Aruba.platform.write_file(path, '')
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it { expect(all_paths).to include expand_path(name) }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context 'when directory exist' do
|
|
21
|
-
let(:name) { 'test_dir' }
|
|
22
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
|
23
|
-
|
|
24
|
-
before :each do
|
|
25
|
-
Aruba.platform.mkdir(path)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it { expect(all_paths).to include expand_path(name) }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'when nothing exist' do
|
|
32
|
-
it { expect(all_paths).to eq [] }
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
describe '#all_files' do
|
|
37
|
-
let(:name) { @file_name }
|
|
38
|
-
let(:path) { @file_path }
|
|
39
|
-
|
|
40
|
-
context 'when file exist' do
|
|
41
|
-
before :each do
|
|
42
|
-
Aruba.platform.write_file(path, '')
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it { expect(all_files).to include expand_path(name) }
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
context 'when directory exist' do
|
|
49
|
-
let(:name) { 'test_dir' }
|
|
50
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
|
51
|
-
|
|
52
|
-
before :each do
|
|
53
|
-
Aruba.platform.mkdir(path)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it { expect(all_files).to eq [] }
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
context 'when nothing exist' do
|
|
60
|
-
it { expect(all_files).to eq [] }
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
describe '#all_directories' do
|
|
65
|
-
let(:name) { @file_name }
|
|
66
|
-
let(:path) { @file_path }
|
|
67
|
-
|
|
68
|
-
context 'when file exist' do
|
|
69
|
-
before :each do
|
|
70
|
-
Aruba.platform.write_file(path, '')
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it { expect(all_directories).to eq [] }
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
context 'when directory exist' do
|
|
77
|
-
let(:name) { 'test_dir' }
|
|
78
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
|
79
|
-
|
|
80
|
-
before :each do
|
|
81
|
-
Aruba.platform.mkdir(path)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it { expect(all_directories).to include expand_path(name) }
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
context 'when nothing exist' do
|
|
88
|
-
it { expect(all_directories).to eq [] }
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
describe 'directories' do
|
|
93
|
-
before(:each) do
|
|
94
|
-
@directory_name = 'test_dir'
|
|
95
|
-
@directory_path = File.join(@aruba.aruba.current_directory, @directory_name)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
context '#create_directory' do
|
|
99
|
-
it 'creates a directory' do
|
|
100
|
-
@aruba.create_directory @directory_name
|
|
101
|
-
expect(File.exist?(File.expand_path(@directory_path))).to be_truthy
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
describe '#cd' do
|
|
106
|
-
context 'with a block given' do
|
|
107
|
-
it 'runs the passed block in the given directory' do
|
|
108
|
-
@aruba.create_directory @directory_name
|
|
109
|
-
full_path = File.expand_path(@directory_path)
|
|
110
|
-
@aruba.cd @directory_name do
|
|
111
|
-
expect(Dir.pwd).to eq full_path
|
|
112
|
-
end
|
|
113
|
-
expect(Dir.pwd).not_to eq full_path
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
it 'sets directory environment in the passed block' do
|
|
117
|
-
@aruba.create_directory @directory_name
|
|
118
|
-
old_pwd = ENV['PWD']
|
|
119
|
-
full_path = File.expand_path(@directory_path)
|
|
120
|
-
@aruba.cd @directory_name do
|
|
121
|
-
expect(ENV['PWD']).to eq full_path
|
|
122
|
-
expect(ENV['OLDPWD']).to eq old_pwd
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it 'sets aruba environment in the passed block' do
|
|
127
|
-
@aruba.create_directory @directory_name
|
|
128
|
-
@aruba.set_environment_variable('FOO', 'bar')
|
|
129
|
-
@aruba.cd @directory_name do
|
|
130
|
-
expect(ENV['FOO']).to eq 'bar'
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
it 'does not touch other environment variables in the passed block' do
|
|
135
|
-
@aruba.create_directory @directory_name
|
|
136
|
-
@aruba.cd @directory_name do
|
|
137
|
-
expect(ENV['HOME']).not_to be_nil
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
describe '#read' do
|
|
145
|
-
let(:name) { 'test.txt'}
|
|
146
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
|
147
|
-
let(:content) { 'asdf' }
|
|
148
|
-
|
|
149
|
-
before :each do
|
|
150
|
-
@aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
context 'when does not exist' do
|
|
154
|
-
it { expect { @aruba.read(name) }.to raise_error ArgumentError }
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
context 'when exists' do
|
|
158
|
-
context 'when file' do
|
|
159
|
-
before :each do
|
|
160
|
-
File.open(File.expand_path(path), 'w') { |f| f << content }
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
context 'when normal file' do
|
|
164
|
-
it { expect(@aruba.read(name)).to eq [content] }
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
context 'when binary file' do
|
|
168
|
-
let(:content) { "\u0000" }
|
|
169
|
-
it { expect(@aruba.read(name)).to eq [content] }
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
context 'when is empty file' do
|
|
173
|
-
let(:content) { '' }
|
|
174
|
-
it { expect(@aruba.read(name)).to eq [] }
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
context 'when path contains ~' do
|
|
178
|
-
let(:string) { random_string }
|
|
179
|
-
let(:name) { File.join('~', string) }
|
|
180
|
-
let(:path) { File.join(@aruba.aruba.current_directory, string) }
|
|
181
|
-
|
|
182
|
-
it { expect(@aruba.read(name)).to eq [content] }
|
|
183
|
-
end
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
context 'when directory' do
|
|
187
|
-
let(:name) { 'test.d' }
|
|
188
|
-
|
|
189
|
-
before :each do
|
|
190
|
-
Array(path).each { |p| Aruba.platform.mkdir p }
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
it { expect { @aruba.read(name) }.to raise_error ArgumentError }
|
|
194
|
-
end
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
describe '#list' do
|
|
199
|
-
let(:name) { 'test.d' }
|
|
200
|
-
let(:content) { %w(subdir.1.d subdir.2.d) }
|
|
201
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
|
202
|
-
|
|
203
|
-
before :each do
|
|
204
|
-
@aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
context 'when does not exist' do
|
|
208
|
-
it { expect { @aruba.list(name) }.to raise_error ArgumentError }
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
context 'when exists' do
|
|
212
|
-
context 'when file' do
|
|
213
|
-
let(:name) { 'test.txt' }
|
|
214
|
-
|
|
215
|
-
before :each do
|
|
216
|
-
File.open(File.expand_path(path), 'w') { |f| f << content }
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
context 'when normal file' do
|
|
220
|
-
it { expect{ @aruba.list(name) }.to raise_error ArgumentError }
|
|
221
|
-
end
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
context 'when directory' do
|
|
225
|
-
before :each do
|
|
226
|
-
Array(path).each { |p| Aruba.platform.mkdir p }
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
before :each do
|
|
230
|
-
Array(content).each { |p| Aruba.platform.mkdir File.join(path, p) }
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
context 'when has subdirectories' do
|
|
234
|
-
context 'when is simple path' do
|
|
235
|
-
let(:existing_files) { @aruba.list(name) }
|
|
236
|
-
let(:expected_files) { content.map { |c| File.join(name, c) }.sort }
|
|
237
|
-
|
|
238
|
-
it { expect(expected_files - existing_files).to be_empty}
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
context 'when path contains ~' do
|
|
242
|
-
let(:string) { random_string }
|
|
243
|
-
let(:name) { File.join('~', string) }
|
|
244
|
-
let(:path) { File.join(@aruba.aruba.current_directory, string) }
|
|
245
|
-
|
|
246
|
-
let(:existing_files) { @aruba.list(name) }
|
|
247
|
-
let(:expected_files) { content.map { |c| File.join(string, c) } }
|
|
248
|
-
|
|
249
|
-
it { expect(expected_files - existing_files).to be_empty}
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
context 'when has no subdirectories' do
|
|
254
|
-
let(:content) { [] }
|
|
255
|
-
it { expect(@aruba.list(name)).to eq [] }
|
|
256
|
-
end
|
|
257
|
-
end
|
|
258
|
-
end
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
describe '#remove' do
|
|
262
|
-
let(:name) { 'test.txt'}
|
|
263
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
|
264
|
-
let(:options) { {} }
|
|
265
|
-
|
|
266
|
-
before :each do
|
|
267
|
-
@aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
context 'when file' do
|
|
271
|
-
context 'when exists' do
|
|
272
|
-
before :each do
|
|
273
|
-
Array(path).each { |p| File.open(File.expand_path(p), 'w') { |f| f << "" } }
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
before :each do
|
|
277
|
-
@aruba.remove(name, options)
|
|
278
|
-
end
|
|
279
|
-
|
|
280
|
-
context 'when is a single file' do
|
|
281
|
-
it_behaves_like 'a non-existing file'
|
|
282
|
-
end
|
|
283
|
-
|
|
284
|
-
context 'when are multiple files' do
|
|
285
|
-
let(:file_name) { %w(file1 file2 file3) }
|
|
286
|
-
let(:file_path) { %w(file1 file2 file3).map { |p| File.join(@aruba.aruba.current_directory, p) } }
|
|
287
|
-
|
|
288
|
-
it_behaves_like 'a non-existing file'
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
context 'when path contains ~' do
|
|
292
|
-
let(:string) { random_string }
|
|
293
|
-
let(:file_name) { File.join('~', string) }
|
|
294
|
-
let(:file_path) { File.join(@aruba.aruba.current_directory, string) }
|
|
295
|
-
|
|
296
|
-
it_behaves_like 'a non-existing file'
|
|
297
|
-
end
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
context 'when does not exist' do
|
|
301
|
-
before :each do
|
|
302
|
-
@aruba.remove(name, options)
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
context 'when is forced to delete file' do
|
|
306
|
-
let(:options) { { :force => true } }
|
|
307
|
-
|
|
308
|
-
it_behaves_like 'a non-existing file'
|
|
309
|
-
end
|
|
310
|
-
end
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
-
context 'when is directory' do
|
|
314
|
-
let(:name) { 'test.d' }
|
|
315
|
-
|
|
316
|
-
context 'when exists' do
|
|
317
|
-
before :each do
|
|
318
|
-
Array(path).each { |p| Aruba.platform.mkdir p }
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
before :each do
|
|
322
|
-
@aruba.remove(name, options)
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
context 'when is a single directory' do
|
|
326
|
-
it_behaves_like 'a non-existing directory'
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
context 'when are multiple directorys' do
|
|
330
|
-
let(:directory_name) { %w(directory1 directory2 directory3) }
|
|
331
|
-
let(:directory_path) { %w(directory1 directory2 directory3).map { |p| File.join(@aruba.aruba.current_directory, p) } }
|
|
332
|
-
|
|
333
|
-
it_behaves_like 'a non-existing directory'
|
|
334
|
-
end
|
|
335
|
-
|
|
336
|
-
context 'when path contains ~' do
|
|
337
|
-
let(:string) { random_string }
|
|
338
|
-
let(:directory_name) { File.join('~', string) }
|
|
339
|
-
let(:directory_path) { File.join(@aruba.aruba.current_directory, string) }
|
|
340
|
-
|
|
341
|
-
it_behaves_like 'a non-existing directory'
|
|
342
|
-
end
|
|
343
|
-
end
|
|
344
|
-
|
|
345
|
-
context 'when does not exist' do
|
|
346
|
-
before :each do
|
|
347
|
-
@aruba.remove(name, options)
|
|
348
|
-
end
|
|
349
|
-
|
|
350
|
-
context 'when is forced to delete directory' do
|
|
351
|
-
let(:options) { { :force => true } }
|
|
352
|
-
|
|
353
|
-
it_behaves_like 'a non-existing directory'
|
|
354
|
-
end
|
|
355
|
-
end
|
|
356
|
-
end
|
|
357
|
-
end
|
|
358
|
-
|
|
359
|
-
describe 'files' do
|
|
360
|
-
describe '#touch' do
|
|
361
|
-
let(:name) { @file_name }
|
|
362
|
-
let(:path) { @file_path }
|
|
363
|
-
let(:options) { {} }
|
|
364
|
-
|
|
365
|
-
before :each do
|
|
366
|
-
@aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
context 'when file' do
|
|
370
|
-
before :each do
|
|
371
|
-
@aruba.touch(name, options)
|
|
372
|
-
end
|
|
373
|
-
|
|
374
|
-
context 'when does not exist' do
|
|
375
|
-
context 'and should be created in existing directory' do
|
|
376
|
-
it { expect(File.size(path)).to eq 0 }
|
|
377
|
-
it_behaves_like 'an existing file'
|
|
378
|
-
end
|
|
379
|
-
|
|
380
|
-
context 'and should be created in non-existing directory' do
|
|
381
|
-
let(:name) { 'directory/test' }
|
|
382
|
-
let(:path) { File.join(@aruba.aruba.current_directory, 'directory/test') }
|
|
383
|
-
|
|
384
|
-
it_behaves_like 'an existing file'
|
|
385
|
-
end
|
|
386
|
-
|
|
387
|
-
context 'and path includes ~' do
|
|
388
|
-
let(:string) { random_string }
|
|
389
|
-
let(:name) { File.join('~', string) }
|
|
390
|
-
let(:path) { File.join(@aruba.aruba.current_directory, string) }
|
|
391
|
-
|
|
392
|
-
it_behaves_like 'an existing file'
|
|
393
|
-
end
|
|
394
|
-
|
|
395
|
-
context 'and the mtime should be set statically' do
|
|
396
|
-
let(:time) { Time.parse('2014-01-01 10:00:00') }
|
|
397
|
-
let(:options) { { :mtime => Time.parse('2014-01-01 10:00:00') } }
|
|
398
|
-
|
|
399
|
-
it_behaves_like 'an existing file'
|
|
400
|
-
it { expect(File.mtime(path)).to eq time }
|
|
401
|
-
end
|
|
402
|
-
|
|
403
|
-
context 'and multiple file names are given' do
|
|
404
|
-
let(:name) { %w(file1 file2 file3) }
|
|
405
|
-
let(:path) { %w(file1 file2 file3).map { |p| File.join(@aruba.aruba.current_directory, p) } }
|
|
406
|
-
it_behaves_like 'an existing file'
|
|
407
|
-
end
|
|
408
|
-
end
|
|
409
|
-
end
|
|
410
|
-
|
|
411
|
-
context 'when directory' do
|
|
412
|
-
let(:name) { %w(directory1) }
|
|
413
|
-
let(:path) { Array(name).map { |p| File.join(@aruba.aruba.current_directory, p) } }
|
|
414
|
-
|
|
415
|
-
context 'when exist' do
|
|
416
|
-
before(:each) { Array(path).each { |p| Aruba.platform.mkdir p } }
|
|
417
|
-
|
|
418
|
-
before :each do
|
|
419
|
-
@aruba.touch(name, options)
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
context 'and the mtime should be set statically' do
|
|
423
|
-
let(:time) { Time.parse('2014-01-01 10:00:00') }
|
|
424
|
-
let(:options) { { :mtime => Time.parse('2014-01-01 10:00:00') } }
|
|
425
|
-
|
|
426
|
-
it_behaves_like 'an existing directory'
|
|
427
|
-
it { Array(path).each { |p| expect(File.mtime(p)).to eq time } }
|
|
428
|
-
end
|
|
429
|
-
end
|
|
430
|
-
end
|
|
431
|
-
end
|
|
432
|
-
|
|
433
|
-
describe '#absolute?' do
|
|
434
|
-
let(:name) { @file_name }
|
|
435
|
-
let(:path) { File.expand_path(File.join(@aruba.aruba.current_directory, name)) }
|
|
436
|
-
|
|
437
|
-
context 'when is absolute path' do
|
|
438
|
-
it { expect(@aruba).to be_absolute(path) }
|
|
439
|
-
end
|
|
440
|
-
|
|
441
|
-
context 'when is relative path' do
|
|
442
|
-
it { expect(@aruba).not_to be_absolute(name) }
|
|
443
|
-
end
|
|
444
|
-
end
|
|
445
|
-
|
|
446
|
-
describe '#relative?' do
|
|
447
|
-
let(:name) { @file_name }
|
|
448
|
-
let(:path) { File.expand_path(File.join(@aruba.aruba.current_directory, name)) }
|
|
449
|
-
|
|
450
|
-
context 'when is absolute path' do
|
|
451
|
-
it { expect(@aruba).not_to be_relative(path) }
|
|
452
|
-
end
|
|
453
|
-
|
|
454
|
-
context 'when is relative path' do
|
|
455
|
-
it { expect(@aruba).to be_relative(name) }
|
|
456
|
-
end
|
|
457
|
-
end
|
|
458
|
-
|
|
459
|
-
describe '#exist?' do
|
|
460
|
-
context 'when is file' do
|
|
461
|
-
let(:name) { @file_name }
|
|
462
|
-
let(:path) { @file_path }
|
|
463
|
-
|
|
464
|
-
context 'when exists' do
|
|
465
|
-
before :each do
|
|
466
|
-
Aruba.platform.write_file(path, '')
|
|
467
|
-
end
|
|
468
|
-
|
|
469
|
-
it { expect(@aruba).to be_exist(name) }
|
|
470
|
-
end
|
|
471
|
-
|
|
472
|
-
context 'when does not exist' do
|
|
473
|
-
it { expect(@aruba).not_to be_exist(name) }
|
|
474
|
-
end
|
|
475
|
-
end
|
|
476
|
-
|
|
477
|
-
context 'when is directory' do
|
|
478
|
-
let(:name) { 'test.d' }
|
|
479
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
|
480
|
-
|
|
481
|
-
context 'when exists' do
|
|
482
|
-
before :each do
|
|
483
|
-
Aruba.platform.mkdir(path)
|
|
484
|
-
end
|
|
485
|
-
|
|
486
|
-
it { expect(@aruba).to be_exist(name) }
|
|
487
|
-
end
|
|
488
|
-
|
|
489
|
-
context 'when does not exist' do
|
|
490
|
-
it { expect(@aruba).not_to be_exist(name) }
|
|
491
|
-
end
|
|
492
|
-
end
|
|
493
|
-
end
|
|
494
|
-
|
|
495
|
-
describe '#file?' do
|
|
496
|
-
context 'when is file' do
|
|
497
|
-
let(:name) { @file_name }
|
|
498
|
-
let(:path) { @file_path }
|
|
499
|
-
|
|
500
|
-
context 'when exists' do
|
|
501
|
-
before :each do
|
|
502
|
-
Aruba.platform.write_file(path, '')
|
|
503
|
-
end
|
|
504
|
-
|
|
505
|
-
it { expect(@aruba).to be_file(name) }
|
|
506
|
-
end
|
|
507
|
-
|
|
508
|
-
context 'when does not exist' do
|
|
509
|
-
it { expect(@aruba).not_to be_file(name) }
|
|
510
|
-
end
|
|
511
|
-
end
|
|
512
|
-
|
|
513
|
-
context 'when is directory' do
|
|
514
|
-
let(:name) { 'test.d' }
|
|
515
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
|
516
|
-
|
|
517
|
-
context 'when exists' do
|
|
518
|
-
before :each do
|
|
519
|
-
Aruba.platform.mkdir(path)
|
|
520
|
-
end
|
|
521
|
-
|
|
522
|
-
it { expect(@aruba).not_to be_file(name) }
|
|
523
|
-
end
|
|
524
|
-
|
|
525
|
-
context 'when does not exist' do
|
|
526
|
-
it { expect(@aruba).not_to be_file(name) }
|
|
527
|
-
end
|
|
528
|
-
end
|
|
529
|
-
end
|
|
530
|
-
|
|
531
|
-
describe '#directory?' do
|
|
532
|
-
context 'when is file' do
|
|
533
|
-
let(:name) { @file_name }
|
|
534
|
-
let(:path) { @file_path }
|
|
535
|
-
|
|
536
|
-
context 'when exists' do
|
|
537
|
-
before :each do
|
|
538
|
-
Aruba.platform.write_file(path, '')
|
|
539
|
-
end
|
|
540
|
-
|
|
541
|
-
it { expect(@aruba).not_to be_directory(name) }
|
|
542
|
-
end
|
|
543
|
-
|
|
544
|
-
context 'when does not exist' do
|
|
545
|
-
it { expect(@aruba).not_to be_directory(name) }
|
|
546
|
-
end
|
|
547
|
-
end
|
|
548
|
-
|
|
549
|
-
context 'when is directory' do
|
|
550
|
-
let(:name) { 'test.d' }
|
|
551
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
|
552
|
-
|
|
553
|
-
context 'when exists' do
|
|
554
|
-
before :each do
|
|
555
|
-
Aruba.platform.mkdir(path)
|
|
556
|
-
end
|
|
557
|
-
|
|
558
|
-
it { expect(@aruba).to be_directory(name) }
|
|
559
|
-
end
|
|
560
|
-
|
|
561
|
-
context 'when does not exist' do
|
|
562
|
-
it { expect(@aruba).not_to be_directory(name) }
|
|
563
|
-
end
|
|
564
|
-
end
|
|
565
|
-
end
|
|
566
|
-
|
|
567
|
-
describe '#copy' do
|
|
568
|
-
let(:source) { 'file.txt' }
|
|
569
|
-
let(:destination) { 'file1.txt' }
|
|
570
|
-
|
|
571
|
-
context 'when source is existing' do
|
|
572
|
-
context 'when destination is non-existing' do
|
|
573
|
-
context 'when source is file' do
|
|
574
|
-
before(:each) { create_test_files(source) }
|
|
575
|
-
|
|
576
|
-
before :each do
|
|
577
|
-
@aruba.copy source, destination
|
|
578
|
-
end
|
|
579
|
-
|
|
580
|
-
context 'when source is plain file' do
|
|
581
|
-
it { expect(destination).to be_an_existing_file }
|
|
582
|
-
end
|
|
583
|
-
|
|
584
|
-
context 'when source is contains "~" in path' do
|
|
585
|
-
let(:source) { '~/file.txt' }
|
|
586
|
-
it { expect(destination).to be_an_existing_file }
|
|
587
|
-
end
|
|
588
|
-
|
|
589
|
-
context 'when source is fixture' do
|
|
590
|
-
let(:source) { '%/copy/file.txt' }
|
|
591
|
-
let(:destination) { 'file.txt' }
|
|
592
|
-
it { expect(destination).to be_an_existing_file }
|
|
593
|
-
end
|
|
594
|
-
|
|
595
|
-
context 'when source is list of files' do
|
|
596
|
-
let(:source) { %w(file1.txt file2.txt file3.txt) }
|
|
597
|
-
let(:destination) { 'file.d' }
|
|
598
|
-
let(:destination_files) { source.map { |s| File.join(destination, s) } }
|
|
599
|
-
|
|
600
|
-
it { expect(destination_files).to all be_an_existing_file }
|
|
601
|
-
end
|
|
602
|
-
end
|
|
603
|
-
|
|
604
|
-
context 'when source is directory' do
|
|
605
|
-
let(:source) { 'src.d' }
|
|
606
|
-
let(:destination) { 'dst.d' }
|
|
607
|
-
|
|
608
|
-
before :each do
|
|
609
|
-
Aruba.platform.mkdir(File.join(@aruba.aruba.current_directory, source))
|
|
610
|
-
end
|
|
611
|
-
|
|
612
|
-
before :each do
|
|
613
|
-
@aruba.copy source, destination
|
|
614
|
-
end
|
|
615
|
-
|
|
616
|
-
context 'when source is single directory' do
|
|
617
|
-
it { expect(destination).to be_an_existing_directory }
|
|
618
|
-
end
|
|
619
|
-
|
|
620
|
-
context 'when source is nested directory' do
|
|
621
|
-
let(:source) { 'src.d/subdir.d' }
|
|
622
|
-
let(:destination) { 'dst.d/' }
|
|
623
|
-
|
|
624
|
-
it { expect(destination).to be_an_existing_directory }
|
|
625
|
-
end
|
|
626
|
-
end
|
|
627
|
-
end
|
|
628
|
-
|
|
629
|
-
context 'when destination is existing' do
|
|
630
|
-
context 'when source is list of files' do
|
|
631
|
-
before(:each) { create_test_files(source) }
|
|
632
|
-
|
|
633
|
-
context 'when destination is directory' do
|
|
634
|
-
let(:source) { %w(file1.txt file2.txt file3.txt) }
|
|
635
|
-
let(:destination) { 'file.d' }
|
|
636
|
-
let(:destination_files) { source.map { |s| File.join(destination, s) } }
|
|
637
|
-
|
|
638
|
-
before :each do
|
|
639
|
-
Aruba.platform.mkdir(File.join(@aruba.aruba.current_directory, destination))
|
|
640
|
-
end
|
|
641
|
-
|
|
642
|
-
before :each do
|
|
643
|
-
@aruba.copy source, destination
|
|
644
|
-
end
|
|
645
|
-
|
|
646
|
-
it { source.each { |s| expect(destination_files).to all be_an_existing_file } }
|
|
647
|
-
end
|
|
648
|
-
|
|
649
|
-
context 'when destination is not a directory' do
|
|
650
|
-
let(:source) { %w(file1.txt file2.txt file3.txt) }
|
|
651
|
-
let(:destination) { 'file.txt' }
|
|
652
|
-
|
|
653
|
-
before(:each) { create_test_files(destination) }
|
|
654
|
-
|
|
655
|
-
it { expect { @aruba.copy source, destination }.to raise_error ArgumentError, "Multiples sources can only be copied to a directory" }
|
|
656
|
-
end
|
|
657
|
-
|
|
658
|
-
context 'when a source is the same like destination' do
|
|
659
|
-
let(:source) { 'file1.txt' }
|
|
660
|
-
let(:destination) { 'file1.txt' }
|
|
661
|
-
|
|
662
|
-
before(:each) { create_test_files(source) }
|
|
663
|
-
|
|
664
|
-
# rubocop:disable Metrics/LineLength
|
|
665
|
-
it { expect { @aruba.copy source, destination }.to raise_error ArgumentError, %(same file: #{File.expand_path(File.join(@aruba.aruba.current_directory, source))} and #{File.expand_path(File.join(@aruba.aruba.current_directory, destination))}) }
|
|
666
|
-
# rubocop:enable Metrics/LineLength
|
|
667
|
-
end
|
|
668
|
-
|
|
669
|
-
context 'when a fixture is destination' do
|
|
670
|
-
let(:source) { '%/copy/file.txt' }
|
|
671
|
-
let(:destination) { '%/copy/file.txt' }
|
|
672
|
-
|
|
673
|
-
it { expect { @aruba.copy source, destination }.to raise_error ArgumentError, "Using a fixture as destination (#{destination}) is not supported" }
|
|
674
|
-
end
|
|
675
|
-
end
|
|
676
|
-
end
|
|
677
|
-
|
|
678
|
-
context 'when source is non-existing' do
|
|
679
|
-
it { expect { @aruba.copy source, destination }.to raise_error ArgumentError}
|
|
680
|
-
end
|
|
681
|
-
end
|
|
682
|
-
end
|
|
683
|
-
|
|
684
|
-
context '#absolute_path' do
|
|
685
|
-
context 'when file_name is array of path names' do
|
|
686
|
-
it { silence(:stderr) { expect(@aruba.absolute_path(['path', @file_name])).to eq File.expand_path(File.join(aruba.current_directory, 'path', @file_name)) } }
|
|
687
|
-
end
|
|
688
|
-
end
|
|
689
|
-
|
|
690
|
-
context '#expand_path' do
|
|
691
|
-
context 'when file_name is given' do
|
|
692
|
-
it { expect(@aruba.expand_path(@file_name)).to eq File.expand_path(@file_path) }
|
|
693
|
-
end
|
|
694
|
-
|
|
695
|
-
context 'when file_path is given' do
|
|
696
|
-
it { expect(@aruba.expand_path(@file_path)).to eq @file_path }
|
|
697
|
-
end
|
|
698
|
-
|
|
699
|
-
context 'when path contains "."' do
|
|
700
|
-
it { expect(@aruba.expand_path('.')).to eq File.expand_path(aruba.current_directory) }
|
|
701
|
-
end
|
|
702
|
-
|
|
703
|
-
context 'when path contains ".."' do
|
|
704
|
-
it { expect(@aruba.expand_path('path/..')).to eq File.expand_path(File.join(aruba.current_directory)) }
|
|
705
|
-
end
|
|
706
|
-
|
|
707
|
-
context 'when path is nil' do
|
|
708
|
-
it { expect { @aruba.expand_path(nil) }.to raise_error ArgumentError }
|
|
709
|
-
end
|
|
710
|
-
|
|
711
|
-
context 'when path is empty' do
|
|
712
|
-
it { expect { @aruba.expand_path('') }.to raise_error ArgumentError }
|
|
713
|
-
end
|
|
714
|
-
|
|
715
|
-
context 'when dir_path is given similar to File.expand_path ' do
|
|
716
|
-
it { expect(@aruba.expand_path(@file_name, 'path')).to eq File.expand_path(File.join(aruba.current_directory, 'path', @file_name)) }
|
|
717
|
-
end
|
|
718
|
-
|
|
719
|
-
context 'when file_name contains fixtures "%" string' do
|
|
720
|
-
let(:runtime) { instance_double('Aruba::Runtime') }
|
|
721
|
-
let(:config) { double('Aruba::Config') }
|
|
722
|
-
let(:environment) { instance_double('Aruba::Environment') }
|
|
723
|
-
|
|
724
|
-
let(:klass) do
|
|
725
|
-
Class.new do
|
|
726
|
-
include Aruba::Api
|
|
727
|
-
|
|
728
|
-
attr_reader :aruba
|
|
729
|
-
|
|
730
|
-
def initialize(aruba)
|
|
731
|
-
@aruba = aruba
|
|
732
|
-
end
|
|
733
|
-
end
|
|
734
|
-
end
|
|
735
|
-
|
|
736
|
-
before :each do
|
|
737
|
-
allow(config).to receive(:fixtures_path_prefix).and_return('%')
|
|
738
|
-
allow(config).to receive(:root_directory).and_return aruba.config.root_directory
|
|
739
|
-
allow(config).to receive(:working_directory).and_return aruba.config.working_directory
|
|
740
|
-
end
|
|
741
|
-
|
|
742
|
-
before :each do
|
|
743
|
-
allow(environment).to receive(:clear)
|
|
744
|
-
allow(environment).to receive(:update).and_return(environment)
|
|
745
|
-
allow(environment).to receive(:to_h).and_return('PATH' => aruba.current_directory.to_s)
|
|
746
|
-
end
|
|
747
|
-
|
|
748
|
-
before :each do
|
|
749
|
-
allow(runtime).to receive(:config).and_return config
|
|
750
|
-
allow(runtime).to receive(:environment).and_return environment
|
|
751
|
-
allow(runtime).to receive(:current_directory).and_return aruba.current_directory
|
|
752
|
-
allow(runtime).to receive(:root_directory).and_return aruba.root_directory
|
|
753
|
-
allow(runtime).to receive(:fixtures_directory).and_return File.join(aruba.root_directory, aruba.current_directory, 'spec', 'fixtures')
|
|
754
|
-
end
|
|
755
|
-
|
|
756
|
-
before :each do
|
|
757
|
-
@aruba = klass.new(runtime)
|
|
758
|
-
@aruba.touch 'spec/fixtures/file1'
|
|
759
|
-
end
|
|
760
|
-
|
|
761
|
-
it { expect(@aruba.expand_path('%/file1')).to eq File.expand_path(File.join(aruba.current_directory, 'spec', 'fixtures', 'file1')) }
|
|
762
|
-
end
|
|
763
|
-
end
|
|
764
|
-
|
|
765
|
-
context '#write_file' do
|
|
766
|
-
it 'writes file' do
|
|
767
|
-
@aruba.write_file(@file_name, '')
|
|
768
|
-
|
|
769
|
-
expect(File.exist?(@file_path)).to eq true
|
|
770
|
-
end
|
|
771
|
-
end
|
|
772
|
-
|
|
773
|
-
context '#write_fixed_size_file' do
|
|
774
|
-
it "should write a fixed sized file" do
|
|
775
|
-
@aruba.write_fixed_size_file(@file_name, @file_size)
|
|
776
|
-
expect(File.exist?(@file_path)).to eq true
|
|
777
|
-
expect(File.size(@file_path)).to eq @file_size
|
|
778
|
-
end
|
|
779
|
-
|
|
780
|
-
it "works with ~ in path name" do
|
|
781
|
-
file_path = File.join('~', random_string)
|
|
782
|
-
|
|
783
|
-
@aruba.with_environment 'HOME' => File.expand_path(aruba.current_directory) do
|
|
784
|
-
@aruba.write_fixed_size_file(file_path, @file_size)
|
|
785
|
-
|
|
786
|
-
expect(File.exist?(File.expand_path(file_path))).to eq true
|
|
787
|
-
expect(File.size(File.expand_path(file_path))).to eq @file_size
|
|
788
|
-
end
|
|
789
|
-
end
|
|
790
|
-
end
|
|
791
|
-
|
|
792
|
-
describe '#chmod' do
|
|
793
|
-
def actual_permissions
|
|
794
|
-
format( "%o" , File::Stat.new(file_path).mode )[-4,4]
|
|
795
|
-
end
|
|
796
|
-
|
|
797
|
-
let(:file_name) { @file_name }
|
|
798
|
-
let(:file_path) { @file_path }
|
|
799
|
-
let(:permissions) { '0655' }
|
|
800
|
-
|
|
801
|
-
before :each do
|
|
802
|
-
@aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
|
|
803
|
-
end
|
|
804
|
-
|
|
805
|
-
before(:each) do
|
|
806
|
-
File.open(file_path, 'w') { |f| f << "" }
|
|
807
|
-
end
|
|
808
|
-
|
|
809
|
-
before(:each) do
|
|
810
|
-
@aruba.chmod(permissions, file_name)
|
|
811
|
-
end
|
|
812
|
-
|
|
813
|
-
context 'when file exists' do
|
|
814
|
-
context 'and permissions are given as string' do
|
|
815
|
-
it { expect(actual_permissions).to eq('0655') }
|
|
816
|
-
end
|
|
817
|
-
|
|
818
|
-
context 'and permissions are given as octal number' do
|
|
819
|
-
let(:permissions) { 0o655 }
|
|
820
|
-
it { expect(actual_permissions).to eq('0655') }
|
|
821
|
-
end
|
|
822
|
-
|
|
823
|
-
context 'and path has ~ in it' do
|
|
824
|
-
let(:path) { random_string }
|
|
825
|
-
let(:file_name) { File.join('~', path) }
|
|
826
|
-
let(:file_path) { File.join(@aruba.aruba.current_directory, path) }
|
|
827
|
-
|
|
828
|
-
it { expect(actual_permissions).to eq('0655') }
|
|
829
|
-
end
|
|
830
|
-
end
|
|
831
|
-
end
|
|
832
|
-
|
|
833
|
-
context "#with_file_content" do
|
|
834
|
-
before :each do
|
|
835
|
-
@aruba.write_file(@file_name, "foo bar baz")
|
|
836
|
-
end
|
|
837
|
-
|
|
838
|
-
it "checks the given file's full content against the expectations in the passed block" do
|
|
839
|
-
@aruba.with_file_content @file_name do |full_content|
|
|
840
|
-
expect(full_content).to eq "foo bar baz"
|
|
841
|
-
end
|
|
842
|
-
end
|
|
843
|
-
|
|
844
|
-
it "works with ~ in path name" do
|
|
845
|
-
file_path = File.join('~', random_string)
|
|
846
|
-
|
|
847
|
-
@aruba.with_environment 'HOME' => File.expand_path(aruba.current_directory) do
|
|
848
|
-
@aruba.write_file(file_path, "foo bar baz")
|
|
849
|
-
|
|
850
|
-
@aruba.with_file_content file_path do |full_content|
|
|
851
|
-
expect(full_content).to eq "foo bar baz"
|
|
852
|
-
end
|
|
853
|
-
end
|
|
854
|
-
end
|
|
855
|
-
|
|
856
|
-
context "checking the file's content against the expectations in the block" do
|
|
857
|
-
it "is successful when the inner expectations match" do
|
|
858
|
-
expect do
|
|
859
|
-
@aruba.with_file_content @file_name do |full_content|
|
|
860
|
-
expect(full_content).to match(/foo/)
|
|
861
|
-
expect(full_content).not_to match(/zoo/)
|
|
862
|
-
end
|
|
863
|
-
end . not_to raise_error
|
|
864
|
-
end
|
|
865
|
-
|
|
866
|
-
it "raises RSpec::Expectations::ExpectationNotMetError when the inner expectations don't match" do
|
|
867
|
-
expect do
|
|
868
|
-
@aruba.with_file_content @file_name do |full_content|
|
|
869
|
-
expect(full_content).to match(/zoo/)
|
|
870
|
-
expect(full_content).not_to match(/foo/)
|
|
871
|
-
end
|
|
872
|
-
end . to raise_error RSpec::Expectations::ExpectationNotMetError
|
|
873
|
-
end
|
|
874
|
-
end
|
|
875
|
-
end #with_file_content
|
|
876
|
-
end
|
|
877
|
-
|
|
878
|
-
describe 'process environment' do
|
|
879
|
-
context '#with_environment' do
|
|
880
|
-
it 'modifies env for block' do
|
|
881
|
-
variable = 'THIS_IS_A_ENV_VAR'
|
|
882
|
-
ENV[variable] = '1'
|
|
883
|
-
|
|
884
|
-
@aruba.with_environment variable => '0' do
|
|
885
|
-
expect(ENV[variable]).to eq '0'
|
|
886
|
-
end
|
|
887
|
-
|
|
888
|
-
expect(ENV[variable]).to eq '1'
|
|
889
|
-
end
|
|
890
|
-
end
|
|
891
|
-
end
|
|
892
|
-
|
|
893
|
-
describe 'tags' do
|
|
894
|
-
describe '@announce_stdout' do
|
|
895
|
-
after(:each) { @aruba.all_commands.each(&:stop) }
|
|
896
|
-
|
|
897
|
-
context 'enabled' do
|
|
898
|
-
before :each do
|
|
899
|
-
@aruba.aruba.announcer = instance_double 'Aruba::Platforms::Announcer'
|
|
900
|
-
expect(@aruba.aruba.announcer).to receive(:announce).with(:stdout) { "hello world\n" }
|
|
901
|
-
allow(@aruba.aruba.announcer).to receive(:announce)
|
|
902
|
-
end
|
|
903
|
-
|
|
904
|
-
it "should announce to stdout exactly once" do
|
|
905
|
-
@aruba.run_command_and_stop('echo "hello world"')
|
|
906
|
-
expect(@aruba.last_command_started.output).to include('hello world')
|
|
907
|
-
end
|
|
908
|
-
end
|
|
909
|
-
|
|
910
|
-
context 'disabled' do
|
|
911
|
-
it "should not announce to stdout" do
|
|
912
|
-
result = capture(:stdout) do
|
|
913
|
-
@aruba.run_command_and_stop('echo "hello world"')
|
|
914
|
-
end
|
|
915
|
-
|
|
916
|
-
expect(result).not_to include('hello world')
|
|
917
|
-
expect(@aruba.last_command_started.output).to include('hello world')
|
|
918
|
-
end
|
|
919
|
-
end
|
|
920
|
-
end
|
|
921
|
-
end
|
|
922
|
-
|
|
923
|
-
describe '#run_command' do
|
|
924
|
-
before(:each){ @aruba.run_command 'cat' }
|
|
925
|
-
after(:each) { @aruba.all_commands.each(&:stop) }
|
|
926
|
-
|
|
927
|
-
it "respond to input" do
|
|
928
|
-
@aruba.type "Hello"
|
|
929
|
-
@aruba.type ""
|
|
930
|
-
expect(@aruba.last_command_started).to have_output "Hello"
|
|
931
|
-
end
|
|
932
|
-
|
|
933
|
-
it "respond to close_input" do
|
|
934
|
-
@aruba.type "Hello"
|
|
935
|
-
@aruba.close_input
|
|
936
|
-
expect(@aruba.last_command_started).to have_output "Hello"
|
|
937
|
-
end
|
|
938
|
-
|
|
939
|
-
it "pipes data" do
|
|
940
|
-
@aruba.write_file(@file_name, "Hello\nWorld!")
|
|
941
|
-
@aruba.pipe_in_file(@file_name)
|
|
942
|
-
@aruba.close_input
|
|
943
|
-
expect(@aruba.last_command_started).to have_output "Hello\nWorld!"
|
|
944
|
-
end
|
|
945
|
-
end
|
|
946
|
-
|
|
947
|
-
describe 'fixtures' do
|
|
948
|
-
let(:api) do
|
|
949
|
-
klass = Class.new do
|
|
950
|
-
include Aruba::Api
|
|
951
|
-
|
|
952
|
-
def root_directory
|
|
953
|
-
expand_path('.')
|
|
954
|
-
end
|
|
955
|
-
end
|
|
956
|
-
|
|
957
|
-
klass.new
|
|
958
|
-
end
|
|
959
|
-
end
|
|
960
|
-
|
|
961
|
-
describe "#set_environment_variable" do
|
|
962
|
-
after(:each) do
|
|
963
|
-
@aruba.all_commands.each(&:stop)
|
|
964
|
-
end
|
|
965
|
-
|
|
966
|
-
it "set environment variable" do
|
|
967
|
-
@aruba.set_environment_variable 'LONG_LONG_ENV_VARIABLE', 'true'
|
|
968
|
-
@aruba.run_command_and_stop "env"
|
|
969
|
-
expect(@aruba.last_command_started.output).
|
|
970
|
-
to include("LONG_LONG_ENV_VARIABLE=true")
|
|
971
|
-
end
|
|
972
|
-
|
|
973
|
-
it "overwrites environment variable" do
|
|
974
|
-
@aruba.set_environment_variable 'LONG_LONG_ENV_VARIABLE', 'true'
|
|
975
|
-
@aruba.set_environment_variable 'LONG_LONG_ENV_VARIABLE', 'false'
|
|
976
|
-
@aruba.run_command_and_stop "env"
|
|
977
|
-
expect(@aruba.last_command_started.output).
|
|
978
|
-
to include("LONG_LONG_ENV_VARIABLE=false")
|
|
979
|
-
end
|
|
980
|
-
end
|
|
981
|
-
end # Aruba::Api
|