aruba 0.14.10 → 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.
Files changed (299) hide show
  1. checksums.yaml +4 -4
  2. data/.cucumberproignore +3 -0
  3. data/.github/ISSUE_TEMPLATE.md +48 -0
  4. data/.github/PULL_REQUEST_TEMPLATE.md +41 -0
  5. data/.gitignore +1 -0
  6. data/.rspec +1 -1
  7. data/.rubocop.yml +20 -181
  8. data/.rubocop_todo.yml +262 -0
  9. data/.simplecov +7 -5
  10. data/.travis.yml +53 -25
  11. data/.yardopts +3 -0
  12. data/CHANGELOG.md +585 -248
  13. data/CONTRIBUTING.md +247 -45
  14. data/Dockerfile +67 -0
  15. data/Gemfile +5 -106
  16. data/LICENSE +1 -1
  17. data/README.md +57 -180
  18. data/Rakefile +63 -32
  19. data/appveyor.yml +8 -11
  20. data/aruba.gemspec +47 -41
  21. data/bin/console +7 -0
  22. data/bin/test +9 -0
  23. data/cucumber.yml +4 -24
  24. data/doc/dependency_decisions.yml +42 -2
  25. data/docker-compose.yml +26 -0
  26. data/{bin → exe}/aruba +1 -1
  27. data/fixtures/cli-app/Rakefile +1 -1
  28. data/fixtures/cli-app/bin/aruba-test-cli +1 -1
  29. data/fixtures/cli-app/cli-app.gemspec +1 -2
  30. data/fixtures/cli-app/features/support/aruba.rb +1 -0
  31. data/fixtures/cli-app/features/support/env.rb +1 -1
  32. data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +3 -3
  33. data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
  34. data/fixtures/cli-app/lib/cli/app.rb +1 -5
  35. data/fixtures/cli-app/spec/spec_helper.rb +4 -7
  36. data/fixtures/empty-app/Rakefile +1 -1
  37. data/fixtures/empty-app/cli-app.gemspec +1 -2
  38. data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
  39. data/fixtures/getting-started-app/Gemfile +1 -1
  40. data/lib/aruba/api/commands.rb +85 -143
  41. data/lib/aruba/api/core.rb +48 -41
  42. data/lib/aruba/api/environment.rb +16 -7
  43. data/lib/aruba/api/filesystem.rb +43 -30
  44. data/lib/aruba/api/text.rb +3 -9
  45. data/lib/aruba/api.rb +6 -11
  46. data/lib/aruba/aruba_path.rb +27 -89
  47. data/lib/aruba/basic_configuration.rb +4 -24
  48. data/lib/aruba/cli.rb +1 -1
  49. data/lib/aruba/command.rb +2 -0
  50. data/lib/aruba/config/jruby.rb +1 -1
  51. data/lib/aruba/config_wrapper.rb +1 -1
  52. data/lib/aruba/configuration.rb +92 -0
  53. data/lib/aruba/console/help.rb +1 -7
  54. data/lib/aruba/console.rb +5 -5
  55. data/lib/aruba/contracts/absolute_path.rb +2 -2
  56. data/lib/aruba/contracts/relative_path.rb +2 -2
  57. data/lib/aruba/cucumber/command.rb +136 -95
  58. data/lib/aruba/cucumber/environment.rb +1 -1
  59. data/lib/aruba/cucumber/file.rb +21 -23
  60. data/lib/aruba/cucumber/hooks.rb +18 -13
  61. data/lib/aruba/cucumber/testing_frameworks.rb +74 -50
  62. data/lib/aruba/cucumber.rb +0 -6
  63. data/lib/aruba/event_bus/name_resolver.rb +5 -16
  64. data/lib/aruba/hooks.rb +1 -1
  65. data/lib/aruba/in_config_wrapper.rb +5 -1
  66. data/lib/aruba/initializer.rb +36 -42
  67. data/lib/aruba/matchers/base/base_matcher.rb +2 -2
  68. data/lib/aruba/matchers/base/message_indenter.rb +19 -0
  69. data/lib/aruba/matchers/base/object_formatter.rb +2 -9
  70. data/lib/aruba/matchers/collection/include_an_object.rb +7 -9
  71. data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -4
  72. data/lib/aruba/matchers/command/have_exit_status.rb +14 -4
  73. data/lib/aruba/matchers/command/have_finished_in_time.rb +3 -5
  74. data/lib/aruba/matchers/command/have_output.rb +10 -5
  75. data/lib/aruba/matchers/command/have_output_on_stderr.rb +2 -2
  76. data/lib/aruba/matchers/command/have_output_on_stdout.rb +2 -2
  77. data/lib/aruba/matchers/command/have_output_size.rb +2 -2
  78. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
  79. data/lib/aruba/matchers/directory/have_sub_directory.rb +4 -6
  80. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
  81. data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
  82. data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
  83. data/lib/aruba/matchers/file/have_file_content.rb +4 -4
  84. data/lib/aruba/matchers/file/have_file_size.rb +6 -8
  85. data/lib/aruba/matchers/file/have_same_file_content.rb +5 -8
  86. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
  87. data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
  88. data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
  89. data/lib/aruba/matchers/path/have_permissions.rb +6 -8
  90. data/lib/aruba/matchers/string/include_output_string.rb +8 -10
  91. data/lib/aruba/matchers/string/match_output_string.rb +9 -11
  92. data/lib/aruba/matchers/string/output_string_eq.rb +8 -10
  93. data/lib/aruba/platform.rb +0 -8
  94. data/lib/aruba/platforms/announcer.rb +42 -79
  95. data/lib/aruba/platforms/aruba_file_creator.rb +2 -6
  96. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +2 -2
  97. data/lib/aruba/platforms/aruba_logger.rb +23 -7
  98. data/lib/aruba/platforms/command_monitor.rb +12 -104
  99. data/lib/aruba/platforms/determine_disk_usage.rb +56 -14
  100. data/lib/aruba/platforms/filesystem_status.rb +10 -14
  101. data/lib/aruba/platforms/local_environment.rb +2 -2
  102. data/lib/aruba/platforms/simple_table.rb +3 -11
  103. data/lib/aruba/platforms/unix_command_string.rb +7 -11
  104. data/lib/aruba/platforms/unix_environment_variables.rb +18 -27
  105. data/lib/aruba/platforms/unix_platform.rb +20 -51
  106. data/lib/aruba/platforms/unix_which.rb +2 -1
  107. data/lib/aruba/platforms/windows_command_string.rb +15 -10
  108. data/lib/aruba/platforms/windows_environment_variables.rb +43 -44
  109. data/lib/aruba/platforms/windows_platform.rb +4 -0
  110. data/lib/aruba/platforms/windows_which.rb +4 -3
  111. data/lib/aruba/processes/basic_process.rb +28 -30
  112. data/lib/aruba/processes/debug_process.rb +12 -3
  113. data/lib/aruba/processes/in_process.rb +17 -8
  114. data/lib/aruba/processes/spawn_process.rb +40 -41
  115. data/lib/aruba/rspec.rb +14 -36
  116. data/lib/aruba/runtime.rb +3 -6
  117. data/lib/aruba/setup.rb +6 -6
  118. data/lib/aruba/tasks/docker_helpers.rb +154 -0
  119. data/lib/aruba/version.rb +1 -1
  120. metadata +190 -236
  121. data/features/.nav +0 -72
  122. data/features/01_getting_started_with_aruba/cleanup_working_directory.feature +0 -57
  123. data/features/01_getting_started_with_aruba/run_commands.feature +0 -217
  124. data/features/01_getting_started_with_aruba/supported_testing_frameworks.feature +0 -88
  125. data/features/02_configure_aruba/activate_announcer_on_command_failure.feature +0 -38
  126. data/features/02_configure_aruba/basics.feature +0 -151
  127. data/features/02_configure_aruba/command_runtime_environment.feature +0 -129
  128. data/features/02_configure_aruba/console_history_file.feature +0 -38
  129. data/features/02_configure_aruba/exit_timeout.feature +0 -60
  130. data/features/02_configure_aruba/fixtures_directories.feature +0 -38
  131. data/features/02_configure_aruba/fixtures_path_prefix.feature +0 -23
  132. data/features/02_configure_aruba/home_directory.feature +0 -80
  133. data/features/02_configure_aruba/io_timeout.feature +0 -30
  134. data/features/02_configure_aruba/keep_ansi.feature +0 -30
  135. data/features/02_configure_aruba/log_level.feature +0 -38
  136. data/features/02_configure_aruba/physical_block_size.feature +0 -53
  137. data/features/02_configure_aruba/remove_ansi_escape_sequences.feature +0 -38
  138. data/features/02_configure_aruba/root_directory.feature +0 -30
  139. data/features/02_configure_aruba/startup_wait_time.feature +0 -48
  140. data/features/02_configure_aruba/working_directory.feature +0 -38
  141. data/features/03_testing_frameworks/cucumber/announce_information_for_troubleshooting.feature +0 -263
  142. data/features/03_testing_frameworks/cucumber/disable_bunder.feature +0 -18
  143. data/features/03_testing_frameworks/cucumber/steps/command/check_for_exit_statuses.feature +0 -136
  144. data/features/03_testing_frameworks/cucumber/steps/command/check_output_of_command.feature +0 -514
  145. data/features/03_testing_frameworks/cucumber/steps/command/check_stderr_of_command.feature +0 -68
  146. data/features/03_testing_frameworks/cucumber/steps/command/check_stdout_of_command.feature +0 -109
  147. data/features/03_testing_frameworks/cucumber/steps/command/debug_your_command_in_aruba.feature +0 -92
  148. data/features/03_testing_frameworks/cucumber/steps/command/run_a_command.feature +0 -66
  149. data/features/03_testing_frameworks/cucumber/steps/command/run_command_in_process.feature +0 -485
  150. data/features/03_testing_frameworks/cucumber/steps/command/run_command_interactively.feature +0 -90
  151. data/features/03_testing_frameworks/cucumber/steps/command/run_commands_which_require_a_shell.feature +0 -79
  152. data/features/03_testing_frameworks/cucumber/steps/command/send_signal_to_command.feature +0 -83
  153. data/features/03_testing_frameworks/cucumber/steps/command/stop_command.feature +0 -285
  154. data/features/03_testing_frameworks/cucumber/steps/environment/append_environment_variable.feature +0 -52
  155. data/features/03_testing_frameworks/cucumber/steps/environment/modify_home_variable_for_testing.feature +0 -62
  156. data/features/03_testing_frameworks/cucumber/steps/environment/prepend_environment_variable.feature +0 -52
  157. data/features/03_testing_frameworks/cucumber/steps/environment/set_environment_variable.feature +0 -49
  158. data/features/03_testing_frameworks/cucumber/steps/filesystem/append_to_file.feature +0 -45
  159. data/features/03_testing_frameworks/cucumber/steps/filesystem/cd_to_directory.feature +0 -33
  160. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_existence_of_directory.feature +0 -57
  161. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_existence_of_file.feature +0 -43
  162. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_file_content.feature +0 -143
  163. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_non_existence_of_directory.feature +0 -69
  164. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_non_existence_of_file.feature +0 -80
  165. data/features/03_testing_frameworks/cucumber/steps/filesystem/check_permissions_of_file.feature +0 -39
  166. data/features/03_testing_frameworks/cucumber/steps/filesystem/compare_files.feature +0 -42
  167. data/features/03_testing_frameworks/cucumber/steps/filesystem/copy_file_or_directory.feature +0 -45
  168. data/features/03_testing_frameworks/cucumber/steps/filesystem/create_directory.feature +0 -57
  169. data/features/03_testing_frameworks/cucumber/steps/filesystem/create_file.feature +0 -76
  170. data/features/03_testing_frameworks/cucumber/steps/filesystem/move_file_or_directory.feature +0 -44
  171. data/features/03_testing_frameworks/cucumber/steps/filesystem/overwrite_file.feature +0 -72
  172. data/features/03_testing_frameworks/cucumber/steps/filesystem/remove_directory.feature +0 -38
  173. data/features/03_testing_frameworks/cucumber/steps/filesystem/remove_file.feature +0 -38
  174. data/features/03_testing_frameworks/cucumber/steps/filesystem/use_fixtures_for_setup_test.feature +0 -77
  175. data/features/03_testing_frameworks/rspec/hooks/define_after_hook_for_commands.feature +0 -43
  176. data/features/03_testing_frameworks/rspec/hooks/define_before_hook_for_commands.feature +0 -71
  177. data/features/03_testing_frameworks/rspec/setup_aruba_for_rspec.feature +0 -179
  178. data/features/04_aruba_api/command/find_a_started_command.feature +0 -83
  179. data/features/04_aruba_api/command/find_command_in_PATH.feature +0 -37
  180. data/features/04_aruba_api/command/read_stderr_of_command.feature +0 -46
  181. data/features/04_aruba_api/command/read_stdout_of_command.feature +0 -46
  182. data/features/04_aruba_api/command/run_command.feature +0 -423
  183. data/features/04_aruba_api/command/run_simple.feature +0 -254
  184. data/features/04_aruba_api/command/send_signal_to_command.feature +0 -53
  185. data/features/04_aruba_api/command/stop_all_commands.feature +0 -57
  186. data/features/04_aruba_api/command/stop_single_command.feature +0 -132
  187. data/features/04_aruba_api/command/terminate_all_commands.feature +0 -57
  188. data/features/04_aruba_api/command/use_last_command_started.feature +0 -50
  189. data/features/04_aruba_api/command/use_last_command_stopped.feature +0 -89
  190. data/features/04_aruba_api/core/expand_path.feature +0 -88
  191. data/features/04_aruba_api/environment/append_environment_variable.feature +0 -128
  192. data/features/04_aruba_api/environment/delete_environment_variable.feature +0 -63
  193. data/features/04_aruba_api/environment/prepend_environment_variable.feature +0 -128
  194. data/features/04_aruba_api/environment/set_environment_variable.feature +0 -376
  195. data/features/04_aruba_api/filesystem/cd_to_directory.feature +0 -184
  196. data/features/04_aruba_api/filesystem/check_existence_file_or_directory.feature +0 -62
  197. data/features/04_aruba_api/filesystem/check_if_path_is_absolute.feature +0 -48
  198. data/features/04_aruba_api/filesystem/check_if_path_is_directory.feature +0 -53
  199. data/features/04_aruba_api/filesystem/check_if_path_is_file.feature +0 -54
  200. data/features/04_aruba_api/filesystem/check_if_path_is_relative.feature +0 -48
  201. data/features/04_aruba_api/filesystem/create_directory.feature +0 -57
  202. data/features/04_aruba_api/filesystem/move_file_or_directory.feature +0 -119
  203. data/features/04_aruba_api/filesystem/report_disk_usage.feature +0 -152
  204. data/features/04_aruba_api/filesystem/use_fixtures.feature +0 -104
  205. data/features/04_aruba_api/text/extract_text.feature +0 -87
  206. data/features/04_aruba_api/text/replace_variables.feature +0 -45
  207. data/features/04_aruba_api/text/sanitize_text.feature +0 -228
  208. data/features/04_aruba_api/text/unescape_text.feature +0 -127
  209. data/features/05_use_rspec_matchers/command/check_timeouts.feature +0 -48
  210. data/features/05_use_rspec_matchers/directory/have_sub_directory.feature +0 -110
  211. data/features/05_use_rspec_matchers/file/be_a_command_found_in_path.feature +0 -115
  212. data/features/05_use_rspec_matchers/file/be_existing_executable.feature +0 -88
  213. data/features/05_use_rspec_matchers/file/be_existing_file.feature +0 -82
  214. data/features/05_use_rspec_matchers/file/have_file_content.feature +0 -123
  215. data/features/05_use_rspec_matchers/file/have_file_size.feature +0 -107
  216. data/features/05_use_rspec_matchers/path/be_an_absolute_path.feature +0 -74
  217. data/features/05_use_rspec_matchers/path/be_an_existing_path.feature +0 -97
  218. data/features/05_use_rspec_matchers/path/have_permissions.feature +0 -118
  219. data/features/06_use_aruba_cli/initialize_project_with_aruba.feature +0 -79
  220. data/features/06_use_aruba_cli/open_console.feature +0 -52
  221. data/features/08_other/improve_performance_if_using_jruby.feature +0 -37
  222. data/features/step_definitions/hooks.rb +0 -146
  223. data/features/support/aruba.rb +0 -7
  224. data/features/support/env.rb +0 -33
  225. data/features/support/jruby.rb +0 -5
  226. data/features/support/simplecov_setup.rb +0 -11
  227. data/fixtures/spawn_process/stderr.sh +0 -3
  228. data/lib/aruba/api/deprecated.rb +0 -1163
  229. data/lib/aruba/config.rb +0 -107
  230. data/lib/aruba/cucumber/core.rb +0 -5
  231. data/lib/aruba/cucumber/deprecated.rb +0 -93
  232. data/lib/aruba/cucumber/rvm.rb +0 -3
  233. data/lib/aruba/in_process.rb +0 -16
  234. data/lib/aruba/jruby.rb +0 -4
  235. data/lib/aruba/matchers/deprecated/file.rb +0 -17
  236. data/lib/aruba/matchers/deprecated.rb +0 -1
  237. data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
  238. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
  239. data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
  240. data/lib/aruba/reporting.rb +0 -126
  241. data/lib/aruba/spawn_process.rb +0 -14
  242. data/script/bootstrap +0 -24
  243. data/script/console +0 -16
  244. data/script/test +0 -3
  245. data/spec/aruba/api/bundler_spec.rb +0 -15
  246. data/spec/aruba/api/core_spec.rb +0 -142
  247. data/spec/aruba/api/deprecated_spec.rb +0 -421
  248. data/spec/aruba/api/filesystem_spec.rb +0 -746
  249. data/spec/aruba/api/runtime_spec.rb +0 -28
  250. data/spec/aruba/api_spec.rb +0 -97
  251. data/spec/aruba/aruba_path_spec.rb +0 -103
  252. data/spec/aruba/basic_configuration_spec.rb +0 -5
  253. data/spec/aruba/configuration_spec.rb +0 -5
  254. data/spec/aruba/hooks_spec.rb +0 -17
  255. data/spec/aruba/in_config_wrapper_spec.rb +0 -25
  256. data/spec/aruba/jruby_spec.rb +0 -73
  257. data/spec/aruba/matchers/command/have_output_size_spec.rb +0 -25
  258. data/spec/aruba/matchers/command_spec.rb +0 -174
  259. data/spec/aruba/matchers/deprecated_spec.rb +0 -120
  260. data/spec/aruba/matchers/directory_spec.rb +0 -57
  261. data/spec/aruba/matchers/file_spec.rb +0 -208
  262. data/spec/aruba/matchers/path_spec.rb +0 -58
  263. data/spec/aruba/platform/simple_table_spec.rb +0 -23
  264. data/spec/aruba/platform/windows_environment_variables_spec.rb +0 -500
  265. data/spec/aruba/platforms/unix_command_string_spec.rb +0 -17
  266. data/spec/aruba/platforms/windows_command_string_spec.rb +0 -22
  267. data/spec/aruba/processes/spawn_process_spec.rb +0 -112
  268. data/spec/aruba/rspec_spec.rb +0 -15
  269. data/spec/aruba/runtime_spec.rb +0 -29
  270. data/spec/event_bus/name_resolver_spec.rb +0 -68
  271. data/spec/event_bus_spec.rb +0 -158
  272. data/spec/spec_helper.rb +0 -22
  273. data/spec/support/configs/.keep +0 -0
  274. data/spec/support/configs/aruba.rb +0 -5
  275. data/spec/support/configs/pry.rb +0 -3
  276. data/spec/support/configs/rspec.rb +0 -15
  277. data/spec/support/helpers/.keep +0 -0
  278. data/spec/support/helpers/reporting.rb +0 -44
  279. data/spec/support/matchers/.keep +0 -0
  280. data/spec/support/matchers/option.rb +0 -35
  281. data/spec/support/shared_contexts/.keep +0 -0
  282. data/spec/support/shared_contexts/aruba.rb +0 -49
  283. data/spec/support/shared_examples/.keep +0 -0
  284. data/spec/support/shared_examples/configuration.rb +0 -116
  285. data/spec/support/shared_examples/directory.rb +0 -7
  286. data/spec/support/shared_examples/file.rb +0 -7
  287. data/templates/css/console.css +0 -24
  288. data/templates/css/filesystem.css +0 -42
  289. data/templates/css/pygments-autumn.css +0 -59
  290. data/templates/files.erb +0 -14
  291. data/templates/images/LICENSE +0 -22
  292. data/templates/images/folder.png +0 -0
  293. data/templates/images/page_white.png +0 -0
  294. data/templates/images/page_white_gherkin.png +0 -0
  295. data/templates/images/page_white_ruby.png +0 -0
  296. data/templates/index.erb +0 -20
  297. data/templates/js/filesystem.js +0 -5
  298. data/templates/js/jquery-1.11.3.min.js +0 -5
  299. 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