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,746 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'aruba/api'
|
3
|
-
|
4
|
-
RSpec.describe Aruba::Api::Filesystem do
|
5
|
-
include_context 'uses aruba API'
|
6
|
-
|
7
|
-
def expand_path(*args)
|
8
|
-
@aruba.expand_path(*args)
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#all_paths' do
|
12
|
-
let(:name) { @file_name }
|
13
|
-
let(:path) { @file_path }
|
14
|
-
|
15
|
-
context 'when file exists' do
|
16
|
-
before :each do
|
17
|
-
Aruba.platform.write_file(path, '')
|
18
|
-
end
|
19
|
-
|
20
|
-
it { expect(all_paths).to include expand_path(name) }
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'when directory exists' do
|
24
|
-
let(:name) { 'test_dir' }
|
25
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
26
|
-
|
27
|
-
before :each do
|
28
|
-
Aruba.platform.mkdir(path)
|
29
|
-
end
|
30
|
-
|
31
|
-
it { expect(all_paths).to include expand_path(name) }
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when nothing exists' do
|
35
|
-
it { expect(all_paths).to eq [] }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#all_files' do
|
40
|
-
let(:name) { @file_name }
|
41
|
-
let(:path) { @file_path }
|
42
|
-
|
43
|
-
context 'when file exists' do
|
44
|
-
before :each do
|
45
|
-
Aruba.platform.write_file(path, '')
|
46
|
-
end
|
47
|
-
|
48
|
-
it { expect(all_files).to include expand_path(name) }
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'when directory exists' do
|
52
|
-
let(:name) { 'test_dir' }
|
53
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
54
|
-
|
55
|
-
before :each do
|
56
|
-
Aruba.platform.mkdir(path)
|
57
|
-
end
|
58
|
-
|
59
|
-
it { expect(all_files).to eq [] }
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'when nothing exists' do
|
63
|
-
it { expect(all_files).to eq [] }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#all_directories' do
|
68
|
-
let(:name) { @file_name }
|
69
|
-
let(:path) { @file_path }
|
70
|
-
|
71
|
-
context 'when file exists' do
|
72
|
-
before :each do
|
73
|
-
Aruba.platform.write_file(path, '')
|
74
|
-
end
|
75
|
-
|
76
|
-
it { expect(all_directories).to eq [] }
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'when directory exists' do
|
80
|
-
let(:name) { 'test_dir' }
|
81
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
82
|
-
|
83
|
-
before :each do
|
84
|
-
Aruba.platform.mkdir(path)
|
85
|
-
end
|
86
|
-
|
87
|
-
it { expect(all_directories).to include expand_path(name) }
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'when nothing exists' do
|
91
|
-
it { expect(all_directories).to eq [] }
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe '#file_size' do
|
96
|
-
let(:name) { @file_name }
|
97
|
-
let(:path) { @file_path }
|
98
|
-
let(:size) { file_size(name) }
|
99
|
-
|
100
|
-
context 'when file exists' do
|
101
|
-
before :each do
|
102
|
-
File.open(path, 'w') { |f| f.print 'a' }
|
103
|
-
end
|
104
|
-
|
105
|
-
it { expect(size).to eq 1 }
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'when file does not exist' do
|
109
|
-
let(:name) { 'non_existing_file' }
|
110
|
-
it { expect { size }.to raise_error ArgumentError }
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe '#touch' do
|
115
|
-
let(:name) { @file_name }
|
116
|
-
let(:path) { @file_path }
|
117
|
-
let(:options) { {} }
|
118
|
-
|
119
|
-
before :each do
|
120
|
-
@aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
|
121
|
-
end
|
122
|
-
|
123
|
-
context 'when touching a file that does not exist' do
|
124
|
-
before :each do
|
125
|
-
@aruba.touch(name, options)
|
126
|
-
end
|
127
|
-
|
128
|
-
context 'and should be created in an existing directory' do
|
129
|
-
it { expect(File.size(path)).to eq 0 }
|
130
|
-
it_behaves_like 'an existing file'
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'and should be created in a non-existing directory' do
|
134
|
-
let(:name) { 'directory/test' }
|
135
|
-
let(:path) { File.join(@aruba.aruba.current_directory, 'directory/test') }
|
136
|
-
|
137
|
-
it_behaves_like 'an existing file'
|
138
|
-
end
|
139
|
-
|
140
|
-
context 'and path includes ~' do
|
141
|
-
let(:string) { random_string }
|
142
|
-
let(:name) { File.join('~', string) }
|
143
|
-
let(:path) { File.join(@aruba.aruba.current_directory, string) }
|
144
|
-
|
145
|
-
it_behaves_like 'an existing file'
|
146
|
-
end
|
147
|
-
|
148
|
-
context 'and the mtime should be set statically' do
|
149
|
-
let(:time) { Time.parse('2014-01-01 10:00:00') }
|
150
|
-
let(:options) { { :mtime => Time.parse('2014-01-01 10:00:00') } }
|
151
|
-
|
152
|
-
it_behaves_like 'an existing file'
|
153
|
-
it { expect(File.mtime(path)).to eq time }
|
154
|
-
end
|
155
|
-
|
156
|
-
context 'and multiple file names are given' do
|
157
|
-
let(:name) { %w(file1 file2 file3) }
|
158
|
-
let(:path) { %w(file1 file2 file3).map { |p| File.join(@aruba.aruba.current_directory, p) } }
|
159
|
-
it_behaves_like 'an existing file'
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
context 'when touching an existing directory' do
|
164
|
-
let(:name) { %w(directory1) }
|
165
|
-
let(:path) { Array(name).map { |p| File.join(@aruba.aruba.current_directory, p) } }
|
166
|
-
|
167
|
-
before do
|
168
|
-
Array(path).each { |p| Aruba.platform.mkdir p }
|
169
|
-
@aruba.touch(name, options)
|
170
|
-
end
|
171
|
-
|
172
|
-
context 'and the mtime should be set statically' do
|
173
|
-
let(:time) { Time.parse('2014-01-01 10:00:00') }
|
174
|
-
let(:options) { { :mtime => Time.parse('2014-01-01 10:00:00') } }
|
175
|
-
|
176
|
-
it_behaves_like 'an existing directory'
|
177
|
-
it { Array(path).each { |p| expect(File.mtime(p)).to eq time } }
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
describe '#absolute?' do
|
183
|
-
let(:name) { @file_name }
|
184
|
-
let(:path) { File.expand_path(File.join(@aruba.aruba.current_directory, name)) }
|
185
|
-
|
186
|
-
context 'when given an absolute path' do
|
187
|
-
it { expect(@aruba).to be_absolute(path) }
|
188
|
-
end
|
189
|
-
|
190
|
-
context 'when given a relative path' do
|
191
|
-
it { expect(@aruba).not_to be_absolute(name) }
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
describe '#relative?' do
|
196
|
-
let(:name) { @file_name }
|
197
|
-
let(:path) { File.expand_path(File.join(@aruba.aruba.current_directory, name)) }
|
198
|
-
|
199
|
-
context 'when given an absolute path' do
|
200
|
-
it { expect(@aruba).not_to be_relative(path) }
|
201
|
-
end
|
202
|
-
|
203
|
-
context 'when given a relative path' do
|
204
|
-
it { expect(@aruba).to be_relative(name) }
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
describe '#exist?' do
|
209
|
-
context 'when given a file' do
|
210
|
-
let(:name) { @file_name }
|
211
|
-
let(:path) { @file_path }
|
212
|
-
|
213
|
-
context 'when it exists' do
|
214
|
-
before :each do
|
215
|
-
Aruba.platform.write_file(path, '')
|
216
|
-
end
|
217
|
-
|
218
|
-
it { expect(@aruba).to be_exist(name) }
|
219
|
-
end
|
220
|
-
|
221
|
-
context 'when it does not exist' do
|
222
|
-
it { expect(@aruba).not_to be_exist(name) }
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
context 'when given a directory' do
|
227
|
-
let(:name) { 'test.d' }
|
228
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
229
|
-
|
230
|
-
context 'when it exists' do
|
231
|
-
before :each do
|
232
|
-
Aruba.platform.mkdir(path)
|
233
|
-
end
|
234
|
-
|
235
|
-
it { expect(@aruba).to be_exist(name) }
|
236
|
-
end
|
237
|
-
|
238
|
-
context 'when it does not exist' do
|
239
|
-
it { expect(@aruba).not_to be_exist(name) }
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
describe '#file?' do
|
245
|
-
context 'when given a file' do
|
246
|
-
let(:name) { @file_name }
|
247
|
-
let(:path) { @file_path }
|
248
|
-
|
249
|
-
context 'when it exists' do
|
250
|
-
before :each do
|
251
|
-
Aruba.platform.write_file(path, '')
|
252
|
-
end
|
253
|
-
|
254
|
-
it { expect(@aruba).to be_file(name) }
|
255
|
-
end
|
256
|
-
|
257
|
-
context 'when does not exist' do
|
258
|
-
it { expect(@aruba).not_to be_file(name) }
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
context 'when given a directory' do
|
263
|
-
let(:name) { 'test.d' }
|
264
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
265
|
-
|
266
|
-
context 'when it exists' do
|
267
|
-
before :each do
|
268
|
-
Aruba.platform.mkdir(path)
|
269
|
-
end
|
270
|
-
|
271
|
-
it { expect(@aruba).not_to be_file(name) }
|
272
|
-
end
|
273
|
-
|
274
|
-
context 'when it does not exist' do
|
275
|
-
it { expect(@aruba).not_to be_file(name) }
|
276
|
-
end
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
describe '#directory?' do
|
281
|
-
context 'when given a file' do
|
282
|
-
let(:name) { @file_name }
|
283
|
-
let(:path) { @file_path }
|
284
|
-
|
285
|
-
context 'when it exists' do
|
286
|
-
before :each do
|
287
|
-
Aruba.platform.write_file(path, '')
|
288
|
-
end
|
289
|
-
|
290
|
-
it { expect(@aruba).not_to be_directory(name) }
|
291
|
-
end
|
292
|
-
|
293
|
-
context 'when it does not exist' do
|
294
|
-
it { expect(@aruba).not_to be_directory(name) }
|
295
|
-
end
|
296
|
-
end
|
297
|
-
|
298
|
-
context 'when given a directory' do
|
299
|
-
let(:name) { 'test.d' }
|
300
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
301
|
-
|
302
|
-
context 'when it exists' do
|
303
|
-
before :each do
|
304
|
-
Aruba.platform.mkdir(path)
|
305
|
-
end
|
306
|
-
|
307
|
-
it { expect(@aruba).to be_directory(name) }
|
308
|
-
end
|
309
|
-
|
310
|
-
context 'when does not exist' do
|
311
|
-
it { expect(@aruba).not_to be_directory(name) }
|
312
|
-
end
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
describe '#copy' do
|
317
|
-
let(:source) { 'file.txt' }
|
318
|
-
let(:destination) { 'file1.txt' }
|
319
|
-
|
320
|
-
context 'when source is existing' do
|
321
|
-
context 'when destination is non-existing' do
|
322
|
-
context 'when source is file' do
|
323
|
-
before(:each) { create_test_files(source) }
|
324
|
-
|
325
|
-
before :each do
|
326
|
-
@aruba.copy source, destination
|
327
|
-
end
|
328
|
-
|
329
|
-
context 'when source is plain file' do
|
330
|
-
it { expect(destination).to be_an_existing_file }
|
331
|
-
end
|
332
|
-
|
333
|
-
context 'when source is contains "~" in path' do
|
334
|
-
let(:source) { '~/file.txt' }
|
335
|
-
it { expect(destination).to be_an_existing_file }
|
336
|
-
end
|
337
|
-
|
338
|
-
context 'when source is fixture' do
|
339
|
-
let(:source) { '%/copy/file.txt' }
|
340
|
-
let(:destination) { 'file.txt' }
|
341
|
-
it { expect(destination).to be_an_existing_file }
|
342
|
-
end
|
343
|
-
|
344
|
-
context 'when source is list of files' do
|
345
|
-
let(:source) { %w(file1.txt file2.txt file3.txt) }
|
346
|
-
let(:destination) { 'file.d' }
|
347
|
-
let(:destination_files) { source.map { |s| File.join(destination, s) } }
|
348
|
-
|
349
|
-
it { expect(destination_files).to all be_an_existing_file }
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
|
-
context 'when source is directory' do
|
354
|
-
let(:source) { 'src.d' }
|
355
|
-
let(:destination) { 'dst.d' }
|
356
|
-
|
357
|
-
before :each do
|
358
|
-
Aruba.platform.mkdir(File.join(@aruba.aruba.current_directory, source))
|
359
|
-
end
|
360
|
-
|
361
|
-
before :each do
|
362
|
-
@aruba.copy source, destination
|
363
|
-
end
|
364
|
-
|
365
|
-
context 'when source is single directory' do
|
366
|
-
it { expect(destination).to be_an_existing_directory }
|
367
|
-
end
|
368
|
-
|
369
|
-
context 'when source is nested directory' do
|
370
|
-
let(:source) { 'src.d/subdir.d' }
|
371
|
-
let(:destination) { 'dst.d/' }
|
372
|
-
|
373
|
-
it { expect(destination).to be_an_existing_directory }
|
374
|
-
end
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
context 'when destination is existing' do
|
379
|
-
context 'when source is list of files' do
|
380
|
-
before(:each) { create_test_files(source) }
|
381
|
-
|
382
|
-
context 'when destination is directory' do
|
383
|
-
let(:source) { %w(file1.txt file2.txt file3.txt) }
|
384
|
-
let(:destination) { 'file.d' }
|
385
|
-
let(:destination_files) { source.map { |s| File.join(destination, s) } }
|
386
|
-
|
387
|
-
before :each do
|
388
|
-
Aruba.platform.mkdir(File.join(@aruba.aruba.current_directory, destination))
|
389
|
-
end
|
390
|
-
|
391
|
-
before :each do
|
392
|
-
@aruba.copy source, destination
|
393
|
-
end
|
394
|
-
|
395
|
-
it { source.each { |s| expect(destination_files).to all be_an_existing_file } }
|
396
|
-
end
|
397
|
-
|
398
|
-
context 'when destination is not a directory' do
|
399
|
-
let(:source) { %w(file1.txt file2.txt file3.txt) }
|
400
|
-
let(:destination) { 'file.txt' }
|
401
|
-
|
402
|
-
before(:each) { create_test_files(destination) }
|
403
|
-
|
404
|
-
it { expect { @aruba.copy source, destination }.to raise_error ArgumentError, "Multiples sources can only be copied to a directory" }
|
405
|
-
end
|
406
|
-
|
407
|
-
context 'when a source is the same like destination' do
|
408
|
-
let(:source) { 'file1.txt' }
|
409
|
-
let(:destination) { 'file1.txt' }
|
410
|
-
|
411
|
-
before(:each) { create_test_files(source) }
|
412
|
-
|
413
|
-
# rubocop:disable Metrics/LineLength
|
414
|
-
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))}) }
|
415
|
-
# rubocop:enable Metrics/LineLength
|
416
|
-
end
|
417
|
-
|
418
|
-
context 'when a fixture is destination' do
|
419
|
-
let(:source) { '%/copy/file.txt' }
|
420
|
-
let(:destination) { '%/copy/file.txt' }
|
421
|
-
|
422
|
-
it { expect { @aruba.copy source, destination }.to raise_error ArgumentError, "Using a fixture as destination (#{destination}) is not supported" }
|
423
|
-
end
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
context 'when source is non-existing' do
|
428
|
-
it { expect { @aruba.copy source, destination }.to raise_error ArgumentError }
|
429
|
-
end
|
430
|
-
end
|
431
|
-
end
|
432
|
-
|
433
|
-
context '#write_file' do
|
434
|
-
it 'writes file' do
|
435
|
-
@aruba.write_file(@file_name, '')
|
436
|
-
|
437
|
-
expect(File.exist?(@file_path)).to eq true
|
438
|
-
end
|
439
|
-
end
|
440
|
-
|
441
|
-
context '#write_fixed_size_file' do
|
442
|
-
it "should write a fixed sized file" do
|
443
|
-
@aruba.write_fixed_size_file(@file_name, @file_size)
|
444
|
-
expect(File.exist?(@file_path)).to eq true
|
445
|
-
expect(File.size(@file_path)).to eq @file_size
|
446
|
-
end
|
447
|
-
|
448
|
-
it "works with ~ in path name" do
|
449
|
-
file_path = File.join('~', random_string)
|
450
|
-
|
451
|
-
@aruba.with_environment 'HOME' => File.expand_path(aruba.current_directory) do
|
452
|
-
@aruba.write_fixed_size_file(file_path, @file_size)
|
453
|
-
|
454
|
-
expect(File.exist?(File.expand_path(file_path))).to eq true
|
455
|
-
expect(File.size(File.expand_path(file_path))).to eq @file_size
|
456
|
-
end
|
457
|
-
end
|
458
|
-
end
|
459
|
-
|
460
|
-
describe '#chmod' do
|
461
|
-
def actual_permissions
|
462
|
-
format("%o" , File::Stat.new(file_path).mode )[-4,4]
|
463
|
-
end
|
464
|
-
|
465
|
-
let(:file_name) { @file_name }
|
466
|
-
let(:file_path) { @file_path }
|
467
|
-
let(:permissions) { '0655' }
|
468
|
-
|
469
|
-
before :each do
|
470
|
-
@aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
|
471
|
-
end
|
472
|
-
|
473
|
-
before(:each) do
|
474
|
-
File.open(file_path, 'w') { |f| f << "" }
|
475
|
-
end
|
476
|
-
|
477
|
-
before(:each) do
|
478
|
-
@aruba.chmod(permissions, file_name)
|
479
|
-
end
|
480
|
-
|
481
|
-
context 'when file exists' do
|
482
|
-
context 'and permissions are given as string' do
|
483
|
-
it { expect(actual_permissions).to eq('0655') }
|
484
|
-
end
|
485
|
-
|
486
|
-
context 'and permissions are given as octal number' do
|
487
|
-
let(:permissions) { 0o655 }
|
488
|
-
it { expect(actual_permissions).to eq('0655') }
|
489
|
-
end
|
490
|
-
|
491
|
-
context 'and path has ~ in it' do
|
492
|
-
let(:path) { random_string }
|
493
|
-
let(:file_name) { File.join('~', path) }
|
494
|
-
let(:file_path) { File.join(@aruba.aruba.current_directory, path) }
|
495
|
-
|
496
|
-
it { expect(actual_permissions).to eq('0655') }
|
497
|
-
end
|
498
|
-
end
|
499
|
-
end
|
500
|
-
|
501
|
-
context "#with_file_content" do
|
502
|
-
before :each do
|
503
|
-
@aruba.write_file(@file_name, "foo bar baz")
|
504
|
-
end
|
505
|
-
|
506
|
-
it "passes the given file's full content to the given block" do
|
507
|
-
@aruba.with_file_content @file_name do |full_content|
|
508
|
-
expect(full_content).to eq "foo bar baz"
|
509
|
-
end
|
510
|
-
end
|
511
|
-
|
512
|
-
it "works with ~ in path name" do
|
513
|
-
file_path = File.join('~', random_string)
|
514
|
-
|
515
|
-
@aruba.with_environment 'HOME' => File.expand_path(aruba.current_directory) do
|
516
|
-
@aruba.write_file(file_path, "foo bar baz")
|
517
|
-
|
518
|
-
@aruba.with_file_content file_path do |full_content|
|
519
|
-
expect(full_content).to eq "foo bar baz"
|
520
|
-
end
|
521
|
-
end
|
522
|
-
end
|
523
|
-
end
|
524
|
-
|
525
|
-
describe '#create_directory' do
|
526
|
-
before(:each) do
|
527
|
-
@directory_name = 'test_dir'
|
528
|
-
@directory_path = File.join(@aruba.aruba.current_directory, @directory_name)
|
529
|
-
end
|
530
|
-
|
531
|
-
it 'creates a directory' do
|
532
|
-
@aruba.create_directory @directory_name
|
533
|
-
expect(File.exist?(File.expand_path(@directory_path))).to be_truthy
|
534
|
-
end
|
535
|
-
end
|
536
|
-
|
537
|
-
describe '#read' do
|
538
|
-
let(:name) { 'test.txt' }
|
539
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
540
|
-
let(:content) { 'asdf' }
|
541
|
-
|
542
|
-
before :each do
|
543
|
-
@aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
|
544
|
-
end
|
545
|
-
|
546
|
-
context 'when does not exist' do
|
547
|
-
it { expect { @aruba.read(name) }.to raise_error ArgumentError }
|
548
|
-
end
|
549
|
-
|
550
|
-
context 'when it exists' do
|
551
|
-
context 'when file' do
|
552
|
-
before :each do
|
553
|
-
File.open(File.expand_path(path), 'w') { |f| f << content }
|
554
|
-
end
|
555
|
-
|
556
|
-
context 'when normal file' do
|
557
|
-
it { expect(@aruba.read(name)).to eq [content] }
|
558
|
-
end
|
559
|
-
|
560
|
-
context 'when binary file' do
|
561
|
-
let(:content) { "\u0000" }
|
562
|
-
it { expect(@aruba.read(name)).to eq [content] }
|
563
|
-
end
|
564
|
-
|
565
|
-
context 'when is empty file' do
|
566
|
-
let(:content) { '' }
|
567
|
-
it { expect(@aruba.read(name)).to eq [] }
|
568
|
-
end
|
569
|
-
|
570
|
-
context 'when path contains ~' do
|
571
|
-
let(:string) { random_string }
|
572
|
-
let(:name) { File.join('~', string) }
|
573
|
-
let(:path) { File.join(@aruba.aruba.current_directory, string) }
|
574
|
-
|
575
|
-
it { expect(@aruba.read(name)).to eq [content] }
|
576
|
-
end
|
577
|
-
end
|
578
|
-
|
579
|
-
context 'when directory' do
|
580
|
-
let(:name) { 'test.d' }
|
581
|
-
|
582
|
-
before do
|
583
|
-
Array(path).each { |p| Aruba.platform.mkdir p }
|
584
|
-
end
|
585
|
-
|
586
|
-
it { expect { @aruba.read(name) }.to raise_error ArgumentError }
|
587
|
-
end
|
588
|
-
end
|
589
|
-
end
|
590
|
-
|
591
|
-
describe '#list' do
|
592
|
-
let(:name) { 'test.d' }
|
593
|
-
let(:content) { %w(subdir.1.d subdir.2.d) }
|
594
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
595
|
-
|
596
|
-
before :each do
|
597
|
-
@aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
|
598
|
-
end
|
599
|
-
|
600
|
-
context 'when does not exist' do
|
601
|
-
it { expect { @aruba.list(name) }.to raise_error ArgumentError }
|
602
|
-
end
|
603
|
-
|
604
|
-
context 'when it exists' do
|
605
|
-
context 'when file' do
|
606
|
-
let(:name) { 'test.txt' }
|
607
|
-
|
608
|
-
before :each do
|
609
|
-
File.open(File.expand_path(path), 'w') { |f| f << content }
|
610
|
-
end
|
611
|
-
|
612
|
-
context 'when normal file' do
|
613
|
-
it { expect { @aruba.list(name) }.to raise_error ArgumentError }
|
614
|
-
end
|
615
|
-
end
|
616
|
-
|
617
|
-
context 'when directory' do
|
618
|
-
before do
|
619
|
-
Array(path).each { |p| Aruba.platform.mkdir p }
|
620
|
-
Array(content).each { |p| Aruba.platform.mkdir File.join(path, p) }
|
621
|
-
end
|
622
|
-
|
623
|
-
context 'when has subdirectories' do
|
624
|
-
context 'when is simple path' do
|
625
|
-
let(:existing_files) { @aruba.list(name) }
|
626
|
-
let(:expected_files) { content.map { |c| File.join(name, c) }.sort }
|
627
|
-
|
628
|
-
it { expect(expected_files - existing_files).to be_empty }
|
629
|
-
end
|
630
|
-
|
631
|
-
context 'when path contains ~' do
|
632
|
-
let(:string) { random_string }
|
633
|
-
let(:name) { File.join('~', string) }
|
634
|
-
let(:path) { File.join(@aruba.aruba.current_directory, string) }
|
635
|
-
|
636
|
-
let(:existing_files) { @aruba.list(name) }
|
637
|
-
let(:expected_files) { content.map { |c| File.join(string, c) } }
|
638
|
-
|
639
|
-
it { expect(expected_files - existing_files).to be_empty }
|
640
|
-
end
|
641
|
-
end
|
642
|
-
|
643
|
-
context 'when has no subdirectories' do
|
644
|
-
let(:content) { [] }
|
645
|
-
it { expect(@aruba.list(name)).to eq [] }
|
646
|
-
end
|
647
|
-
end
|
648
|
-
end
|
649
|
-
end
|
650
|
-
|
651
|
-
describe '#remove' do
|
652
|
-
let(:name) { 'test.txt' }
|
653
|
-
let(:path) { File.join(@aruba.aruba.current_directory, name) }
|
654
|
-
let(:options) { {} }
|
655
|
-
|
656
|
-
before :each do
|
657
|
-
@aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
|
658
|
-
end
|
659
|
-
|
660
|
-
context 'when given a file' do
|
661
|
-
context 'when it exists' do
|
662
|
-
before do
|
663
|
-
Array(path).each { |p| File.open(File.expand_path(p), 'w') { |f| f << "" } }
|
664
|
-
|
665
|
-
@aruba.remove(name, options)
|
666
|
-
end
|
667
|
-
|
668
|
-
context 'when is a single file' do
|
669
|
-
it_behaves_like 'a non-existing file'
|
670
|
-
end
|
671
|
-
|
672
|
-
context 'when are multiple files' do
|
673
|
-
let(:file_name) { %w(file1 file2 file3) }
|
674
|
-
let(:file_path) { %w(file1 file2 file3).map { |p| File.join(@aruba.aruba.current_directory, p) } }
|
675
|
-
|
676
|
-
it_behaves_like 'a non-existing file'
|
677
|
-
end
|
678
|
-
|
679
|
-
context 'when path contains ~' do
|
680
|
-
let(:string) { random_string }
|
681
|
-
let(:file_name) { File.join('~', string) }
|
682
|
-
let(:file_path) { File.join(@aruba.aruba.current_directory, string) }
|
683
|
-
|
684
|
-
it_behaves_like 'a non-existing file'
|
685
|
-
end
|
686
|
-
end
|
687
|
-
|
688
|
-
context 'when it does not exist' do
|
689
|
-
before do
|
690
|
-
@aruba.remove(name, options)
|
691
|
-
end
|
692
|
-
|
693
|
-
context 'when forced to delete file' do
|
694
|
-
let(:options) { { :force => true } }
|
695
|
-
|
696
|
-
it_behaves_like 'a non-existing file'
|
697
|
-
end
|
698
|
-
end
|
699
|
-
end
|
700
|
-
|
701
|
-
context 'when given a directory' do
|
702
|
-
let(:name) { 'test.d' }
|
703
|
-
|
704
|
-
context 'when it exists' do
|
705
|
-
before do
|
706
|
-
Array(path).each { |p| Aruba.platform.mkdir p }
|
707
|
-
end
|
708
|
-
|
709
|
-
before :each do
|
710
|
-
@aruba.remove(name, options)
|
711
|
-
end
|
712
|
-
|
713
|
-
context 'when is a single directory' do
|
714
|
-
it_behaves_like 'a non-existing directory'
|
715
|
-
end
|
716
|
-
|
717
|
-
context 'when are multiple directorys' do
|
718
|
-
let(:directory_name) { %w(directory1 directory2 directory3) }
|
719
|
-
let(:directory_path) { %w(directory1 directory2 directory3).map { |p| File.join(@aruba.aruba.current_directory, p) } }
|
720
|
-
|
721
|
-
it_behaves_like 'a non-existing directory'
|
722
|
-
end
|
723
|
-
|
724
|
-
context 'when path contains ~' do
|
725
|
-
let(:string) { random_string }
|
726
|
-
let(:directory_name) { File.join('~', string) }
|
727
|
-
let(:directory_path) { File.join(@aruba.aruba.current_directory, string) }
|
728
|
-
|
729
|
-
it_behaves_like 'a non-existing directory'
|
730
|
-
end
|
731
|
-
end
|
732
|
-
|
733
|
-
context 'when it does not exist' do
|
734
|
-
before :each do
|
735
|
-
@aruba.remove(name, options)
|
736
|
-
end
|
737
|
-
|
738
|
-
context 'when is forced to delete directory' do
|
739
|
-
let(:options) { { :force => true } }
|
740
|
-
|
741
|
-
it_behaves_like 'a non-existing directory'
|
742
|
-
end
|
743
|
-
end
|
744
|
-
end
|
745
|
-
end
|
746
|
-
end
|