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.
Files changed (309) 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 -179
  8. data/.rubocop_todo.yml +262 -0
  9. data/.simplecov +7 -5
  10. data/.travis.yml +54 -46
  11. data/.yardopts +3 -0
  12. data/CHANGELOG.md +613 -246
  13. data/CONTRIBUTING.md +247 -45
  14. data/Dockerfile +67 -0
  15. data/Gemfile +5 -96
  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 +6 -0
  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 -6
  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/empty-app/lib/cli/app.rb +0 -6
  40. data/fixtures/getting-started-app/Gemfile +1 -1
  41. data/lib/aruba/api/commands.rb +109 -143
  42. data/lib/aruba/api/core.rb +57 -43
  43. data/lib/aruba/api/environment.rb +16 -7
  44. data/lib/aruba/api/filesystem.rb +42 -29
  45. data/lib/aruba/api/text.rb +3 -9
  46. data/lib/aruba/api.rb +6 -11
  47. data/lib/aruba/aruba_path.rb +27 -89
  48. data/lib/aruba/basic_configuration.rb +4 -24
  49. data/lib/aruba/cli.rb +1 -1
  50. data/lib/aruba/colorizer.rb +10 -99
  51. data/lib/aruba/command.rb +2 -0
  52. data/lib/aruba/config/jruby.rb +15 -5
  53. data/lib/aruba/config_wrapper.rb +1 -1
  54. data/lib/aruba/configuration.rb +92 -0
  55. data/lib/aruba/console/help.rb +1 -7
  56. data/lib/aruba/console.rb +5 -5
  57. data/lib/aruba/contracts/absolute_path.rb +2 -2
  58. data/lib/aruba/contracts/relative_path.rb +2 -2
  59. data/lib/aruba/cucumber/command.rb +171 -160
  60. data/lib/aruba/cucumber/environment.rb +1 -1
  61. data/lib/aruba/cucumber/file.rb +21 -35
  62. data/lib/aruba/cucumber/hooks.rb +17 -56
  63. data/lib/aruba/cucumber/testing_frameworks.rb +74 -50
  64. data/lib/aruba/cucumber.rb +0 -5
  65. data/lib/aruba/event_bus/name_resolver.rb +5 -16
  66. data/lib/aruba/hooks.rb +1 -1
  67. data/lib/aruba/in_config_wrapper.rb +5 -1
  68. data/lib/aruba/initializer.rb +36 -42
  69. data/lib/aruba/matchers/base/base_matcher.rb +2 -2
  70. data/lib/aruba/matchers/base/message_indenter.rb +19 -0
  71. data/lib/aruba/matchers/base/object_formatter.rb +2 -9
  72. data/lib/aruba/matchers/collection/include_an_object.rb +7 -9
  73. data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -4
  74. data/lib/aruba/matchers/command/have_exit_status.rb +14 -4
  75. data/lib/aruba/matchers/command/have_finished_in_time.rb +3 -5
  76. data/lib/aruba/matchers/command/have_output.rb +10 -5
  77. data/lib/aruba/matchers/command/have_output_on_stderr.rb +2 -2
  78. data/lib/aruba/matchers/command/have_output_on_stdout.rb +2 -2
  79. data/lib/aruba/matchers/command/have_output_size.rb +2 -2
  80. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
  81. data/lib/aruba/matchers/directory/have_sub_directory.rb +4 -6
  82. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
  83. data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
  84. data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
  85. data/lib/aruba/matchers/file/have_file_content.rb +4 -4
  86. data/lib/aruba/matchers/file/have_file_size.rb +6 -8
  87. data/lib/aruba/matchers/file/have_same_file_content.rb +5 -8
  88. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
  89. data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
  90. data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
  91. data/lib/aruba/matchers/path/have_permissions.rb +6 -8
  92. data/lib/aruba/matchers/string/include_output_string.rb +8 -10
  93. data/lib/aruba/matchers/string/match_output_string.rb +9 -11
  94. data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
  95. data/lib/aruba/platform.rb +0 -8
  96. data/lib/aruba/platforms/announcer.rb +42 -79
  97. data/lib/aruba/platforms/aruba_file_creator.rb +2 -6
  98. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +2 -2
  99. data/lib/aruba/platforms/aruba_logger.rb +23 -7
  100. data/lib/aruba/platforms/command_monitor.rb +12 -107
  101. data/lib/aruba/platforms/determine_disk_usage.rb +56 -14
  102. data/lib/aruba/platforms/filesystem_status.rb +10 -14
  103. data/lib/aruba/platforms/local_environment.rb +2 -2
  104. data/lib/aruba/platforms/simple_table.rb +3 -11
  105. data/lib/aruba/platforms/unix_command_string.rb +7 -11
  106. data/lib/aruba/platforms/unix_environment_variables.rb +18 -27
  107. data/lib/aruba/platforms/unix_platform.rb +20 -51
  108. data/lib/aruba/platforms/unix_which.rb +2 -1
  109. data/lib/aruba/platforms/windows_command_string.rb +15 -10
  110. data/lib/aruba/platforms/windows_environment_variables.rb +43 -44
  111. data/lib/aruba/platforms/windows_platform.rb +4 -0
  112. data/lib/aruba/platforms/windows_which.rb +4 -3
  113. data/lib/aruba/processes/basic_process.rb +28 -30
  114. data/lib/aruba/processes/debug_process.rb +12 -3
  115. data/lib/aruba/processes/in_process.rb +17 -8
  116. data/lib/aruba/processes/spawn_process.rb +57 -46
  117. data/lib/aruba/rspec.rb +14 -36
  118. data/lib/aruba/runtime.rb +3 -6
  119. data/lib/aruba/setup.rb +6 -6
  120. data/lib/aruba/tasks/docker_helpers.rb +154 -0
  121. data/lib/aruba/version.rb +1 -1
  122. metadata +191 -244
  123. data/features/.nav +0 -72
  124. data/features/api/command/find_command.feature +0 -83
  125. data/features/api/command/last_command_started.feature +0 -50
  126. data/features/api/command/last_command_stopped.feature +0 -89
  127. data/features/api/command/run.feature +0 -414
  128. data/features/api/command/run_simple.feature +0 -242
  129. data/features/api/command/send_signal.feature +0 -53
  130. data/features/api/command/stderr.feature +0 -46
  131. data/features/api/command/stdout.feature +0 -46
  132. data/features/api/command/stop.feature +0 -131
  133. data/features/api/command/stop_all_commands.feature +0 -53
  134. data/features/api/command/terminate_all_commands.feature +0 -53
  135. data/features/api/command/which.feature +0 -37
  136. data/features/api/core/expand_path.feature +0 -88
  137. data/features/api/environment/append_environment_variable.feature +0 -128
  138. data/features/api/environment/delete_environment_variable.feature +0 -63
  139. data/features/api/environment/prepend_environment_variable.feature +0 -128
  140. data/features/api/environment/set_environment_variable.feature +0 -376
  141. data/features/api/filesystem/cd.feature +0 -184
  142. data/features/api/filesystem/create_directory.feature +0 -57
  143. data/features/api/filesystem/disk_usage.feature +0 -152
  144. data/features/api/filesystem/does_exist.feature +0 -62
  145. data/features/api/filesystem/fixtures.feature +0 -104
  146. data/features/api/filesystem/is_absolute.feature +0 -48
  147. data/features/api/filesystem/is_directory.feature +0 -53
  148. data/features/api/filesystem/is_file.feature +0 -54
  149. data/features/api/filesystem/is_relative.feature +0 -48
  150. data/features/api/filesystem/move.feature +0 -119
  151. data/features/api/text/extract_text.feature +0 -87
  152. data/features/api/text/replace_variables.feature +0 -45
  153. data/features/api/text/sanitize_text.feature +0 -228
  154. data/features/api/text/unescape_text.feature +0 -127
  155. data/features/cli/console.feature +0 -52
  156. data/features/cli/init.feature +0 -79
  157. data/features/configuration/activate_announcer_on_command_failure.feature +0 -38
  158. data/features/configuration/command_runtime_environment.feature +0 -129
  159. data/features/configuration/console_history_file.feature +0 -38
  160. data/features/configuration/exit_timeout.feature +0 -52
  161. data/features/configuration/fixtures_directories.feature +0 -38
  162. data/features/configuration/fixtures_path_prefix.feature +0 -23
  163. data/features/configuration/home_directory.feature +0 -80
  164. data/features/configuration/io_timeout.feature +0 -30
  165. data/features/configuration/keep_ansi.feature +0 -30
  166. data/features/configuration/log_level.feature +0 -38
  167. data/features/configuration/physical_block_size.feature +0 -53
  168. data/features/configuration/remove_ansi_escape_sequences.feature +0 -38
  169. data/features/configuration/root_directory.feature +0 -30
  170. data/features/configuration/startup_wait_time.feature +0 -48
  171. data/features/configuration/usage.feature +0 -159
  172. data/features/configuration/working_directory.feature +0 -33
  173. data/features/development/build.feature +0 -15
  174. data/features/getting_started/cleanup.feature +0 -58
  175. data/features/getting_started/run_commands.feature +0 -187
  176. data/features/getting_started/supported_testing_frameworks.feature +0 -104
  177. data/features/getting_started/writing_good_feature_tests.feature +0 -38
  178. data/features/hooks/after/command.feature +0 -46
  179. data/features/hooks/before/command.feature +0 -75
  180. data/features/matchers/collection/include_an_object.feature +0 -72
  181. data/features/matchers/directory/have_sub_directory.feature +0 -110
  182. data/features/matchers/file/be_a_command_found_in_path.feature +0 -115
  183. data/features/matchers/file/be_existing_executable.feature +0 -88
  184. data/features/matchers/file/be_existing_file.feature +0 -82
  185. data/features/matchers/file/have_file_content.feature +0 -123
  186. data/features/matchers/file/have_file_size.feature +0 -107
  187. data/features/matchers/path/be_an_absolute_path.feature +0 -74
  188. data/features/matchers/path/be_an_existing_path.feature +0 -97
  189. data/features/matchers/path/have_permissions.feature +0 -118
  190. data/features/matchers/timeouts.feature +0 -48
  191. data/features/platforms/jruby.feature +0 -14
  192. data/features/rspec/integration.feature +0 -179
  193. data/features/step_definitions/aruba_dev_steps.rb +0 -56
  194. data/features/step_definitions/hooks.rb +0 -156
  195. data/features/steps/command/debug.feature +0 -92
  196. data/features/steps/command/exit_statuses.feature +0 -136
  197. data/features/steps/command/in_process.feature +0 -485
  198. data/features/steps/command/interactive.feature +0 -90
  199. data/features/steps/command/output.feature +0 -567
  200. data/features/steps/command/run.feature +0 -66
  201. data/features/steps/command/send_signal.feature +0 -104
  202. data/features/steps/command/shell.feature +0 -155
  203. data/features/steps/command/stderr.feature +0 -68
  204. data/features/steps/command/stdout.feature +0 -109
  205. data/features/steps/command/stop.feature +0 -313
  206. data/features/steps/core/announce.feature +0 -283
  207. data/features/steps/environment/append_environment_variable.feature +0 -52
  208. data/features/steps/environment/disable_bunder.feature +0 -18
  209. data/features/steps/environment/home_variable.feature +0 -62
  210. data/features/steps/environment/prepend_environment_variable.feature +0 -52
  211. data/features/steps/environment/set_environment_variable.feature +0 -49
  212. data/features/steps/filesystem/append_to_file.feature +0 -45
  213. data/features/steps/filesystem/cd_to_directory.feature +0 -33
  214. data/features/steps/filesystem/check_file_content.feature +0 -61
  215. data/features/steps/filesystem/check_permissions_of_file.feature +0 -39
  216. data/features/steps/filesystem/compare_files.feature +0 -42
  217. data/features/steps/filesystem/copy.feature +0 -45
  218. data/features/steps/filesystem/create_directory.feature +0 -57
  219. data/features/steps/filesystem/create_file.feature +0 -76
  220. data/features/steps/filesystem/existence_of_directory.feature +0 -57
  221. data/features/steps/filesystem/existence_of_file.feature +0 -43
  222. data/features/steps/filesystem/file_content.feature +0 -86
  223. data/features/steps/filesystem/fixtures.feature +0 -64
  224. data/features/steps/filesystem/move.feature +0 -45
  225. data/features/steps/filesystem/non_existence_of_directory.feature +0 -69
  226. data/features/steps/filesystem/non_existence_of_file.feature +0 -80
  227. data/features/steps/filesystem/overwrite_file.feature +0 -72
  228. data/features/steps/filesystem/remove_directory.feature +0 -38
  229. data/features/steps/filesystem/remove_file.feature +0 -38
  230. data/features/steps/filesystem/use_fixture.feature +0 -77
  231. data/features/steps/overview.feature +0 -25
  232. data/features/support/aruba.rb +0 -7
  233. data/features/support/env.rb +0 -33
  234. data/features/support/jruby.rb +0 -5
  235. data/features/support/simplecov_setup.rb +0 -8
  236. data/fixtures/cli-app/bin/cli +0 -6
  237. data/fixtures/spawn_process/stderr.sh +0 -3
  238. data/lib/aruba/api/deprecated.rb +0 -1234
  239. data/lib/aruba/config.rb +0 -107
  240. data/lib/aruba/cucumber/core.rb +0 -5
  241. data/lib/aruba/cucumber/rvm.rb +0 -3
  242. data/lib/aruba/in_process.rb +0 -14
  243. data/lib/aruba/jruby.rb +0 -4
  244. data/lib/aruba/matchers/deprecated/file.rb +0 -17
  245. data/lib/aruba/matchers/deprecated.rb +0 -1
  246. data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
  247. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
  248. data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
  249. data/lib/aruba/reporting.rb +0 -126
  250. data/lib/aruba/spawn_process.rb +0 -11
  251. data/script/bootstrap +0 -28
  252. data/script/console +0 -16
  253. data/script/test +0 -3
  254. data/spec/aruba/api/bundler_spec.rb +0 -15
  255. data/spec/aruba/api/deprecated_spec.rb +0 -308
  256. data/spec/aruba/api/environment/restore_env_spec.rb +0 -86
  257. data/spec/aruba/api/environment/set_env_spec.rb +0 -46
  258. data/spec/aruba/api/filesystem/file_size_spec.rb +0 -28
  259. data/spec/aruba/api/runtime_spec.rb +0 -28
  260. data/spec/aruba/api_spec.rb +0 -981
  261. data/spec/aruba/aruba_path_spec.rb +0 -103
  262. data/spec/aruba/basic_configuration_spec.rb +0 -5
  263. data/spec/aruba/configuration_spec.rb +0 -5
  264. data/spec/aruba/hooks_spec.rb +0 -17
  265. data/spec/aruba/in_config_wrapper_spec.rb +0 -25
  266. data/spec/aruba/jruby_spec.rb +0 -55
  267. data/spec/aruba/matchers/command/have_output_size_spec.rb +0 -25
  268. data/spec/aruba/matchers/command_spec.rb +0 -174
  269. data/spec/aruba/matchers/deprecated_spec.rb +0 -120
  270. data/spec/aruba/matchers/directory_spec.rb +0 -57
  271. data/spec/aruba/matchers/file_spec.rb +0 -208
  272. data/spec/aruba/matchers/path_spec.rb +0 -58
  273. data/spec/aruba/platform/simple_table_spec.rb +0 -23
  274. data/spec/aruba/platform/windows_environment_variables_spec.rb +0 -500
  275. data/spec/aruba/platforms/unix_command_string_spec.rb +0 -17
  276. data/spec/aruba/platforms/windows_command_string_spec.rb +0 -22
  277. data/spec/aruba/rspec_spec.rb +0 -15
  278. data/spec/aruba/runtime_spec.rb +0 -29
  279. data/spec/aruba/spawn_process_spec.rb +0 -96
  280. data/spec/event_bus/name_resolver_spec.rb +0 -68
  281. data/spec/event_bus_spec.rb +0 -158
  282. data/spec/spec_helper.rb +0 -20
  283. data/spec/support/configs/.keep +0 -0
  284. data/spec/support/configs/aruba.rb +0 -5
  285. data/spec/support/configs/pry.rb +0 -3
  286. data/spec/support/configs/rspec.rb +0 -15
  287. data/spec/support/helpers/.keep +0 -0
  288. data/spec/support/helpers/reporting.rb +0 -44
  289. data/spec/support/matchers/.keep +0 -0
  290. data/spec/support/matchers/option.rb +0 -35
  291. data/spec/support/shared_contexts/.keep +0 -0
  292. data/spec/support/shared_contexts/aruba.rb +0 -49
  293. data/spec/support/shared_examples/.keep +0 -0
  294. data/spec/support/shared_examples/configuration.rb +0 -116
  295. data/spec/support/shared_examples/directory.rb +0 -7
  296. data/spec/support/shared_examples/file.rb +0 -7
  297. data/templates/css/console.css +0 -24
  298. data/templates/css/filesystem.css +0 -42
  299. data/templates/css/pygments-autumn.css +0 -59
  300. data/templates/files.erb +0 -14
  301. data/templates/images/LICENSE +0 -22
  302. data/templates/images/folder.png +0 -0
  303. data/templates/images/page_white.png +0 -0
  304. data/templates/images/page_white_gherkin.png +0 -0
  305. data/templates/images/page_white_ruby.png +0 -0
  306. data/templates/index.erb +0 -20
  307. data/templates/js/filesystem.js +0 -5
  308. data/templates/js/jquery-1.11.3.min.js +0 -5
  309. data/templates/main.erb +0 -34
data/{bin → exe}/aruba RENAMED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH << File.expand_path('../../lib', __FILE__)
3
+ $LOAD_PATH << File.expand_path('../lib', __dir__)
4
4
 
5
5
  require 'aruba/cli'
6
6
 
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH << File.expand_path('../lib', __dir__)
4
+ require 'cli/app'
5
+
6
+ exit 0
@@ -1,5 +1,4 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'cli/app/version'
5
4
 
@@ -0,0 +1 @@
1
+ require 'aruba/cucumber'
@@ -1 +1 @@
1
- require 'aruba/cucumber'
1
+ require_relative 'aruba'
@@ -2,12 +2,12 @@ module SimpleCov
2
2
  module Formatter
3
3
  class HTMLFormatter
4
4
  def format(result)
5
- Dir[File.join(File.dirname(__FILE__), "../public/*")].each do |path|
5
+ Dir[File.join(File.dirname(__FILE__), '../public/*')].each do |path|
6
6
  FileUtils.cp_r(path, asset_output_path)
7
7
  end
8
8
 
9
- File.open(File.join(output_path, "index.html"), "wb") do |file|
10
- file.puts template("layout").result(binding)
9
+ File.open(File.join(output_path, 'index.html'), 'wb') do |file|
10
+ file.puts template('layout').result(binding)
11
11
  end
12
12
  end
13
13
  end
@@ -1,5 +1,5 @@
1
1
  module Cli
2
2
  module App
3
- VERSION = "0.1.0".freeze
3
+ VERSION = '0.1.0'.freeze
4
4
  end
5
5
  end
@@ -1,10 +1,6 @@
1
1
  require 'cli/app/version'
2
2
 
3
- if RUBY_VERSION < '1.9.3'
4
- ::Dir.glob(::File.expand_path('../**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
5
- else
6
- ::Dir.glob(File.expand_path('../**/*.rb', __FILE__)).each { |f| require_relative f }
7
- end
3
+ ::Dir.glob(File.expand_path('**/*.rb', __dir__)).each { |f| require_relative f }
8
4
 
9
5
  module Cli
10
6
  module App
@@ -1,9 +1,7 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
2
 
3
3
  require 'cli/app'
4
4
 
5
- if RUBY_VERSION < '1.9.3'
6
- ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
7
- else
8
- ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
9
- end
5
+ require_relative 'support/aruba'
6
+
7
+ ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
@@ -1,5 +1,4 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'cli/app/version'
5
4
 
@@ -1,5 +1,5 @@
1
1
  module Cli
2
2
  module App
3
- VERSION = "0.1.0".freeze
3
+ VERSION = '0.1.0'.freeze
4
4
  end
5
5
  end
@@ -1,11 +1,5 @@
1
1
  require 'cli/app/version'
2
2
 
3
- if RUBY_VERSION < '1.9.3'
4
- ::Dir.glob(::File.expand_path('../**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
5
- else
6
- ::Dir.glob(File.expand_path('../**/*.rb', __FILE__)).each { |f| require_relative f }
7
- end
8
-
9
3
  module Cli
10
4
  module App
11
5
  # Your code goes here...
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'aruba', path: File.expand_path('../../..', __dir__)
3
4
  gem 'cucumber'
4
- gem 'aruba', path: File.expand_path('../../../../', __FILE__)
@@ -5,17 +5,6 @@ require 'aruba/command'
5
5
 
6
6
  # require 'win32/file' if File::ALT_SEPARATOR
7
7
 
8
- # Aruba
9
- module Aruba
10
- class << self
11
- # @deprecated
12
- attr_accessor :process
13
- end
14
-
15
- # @deprecated
16
- # self.process = Aruba::Processes::SpawnProcess
17
- end
18
-
19
8
  # Aruba
20
9
  module Aruba
21
10
  # Api
@@ -103,6 +92,30 @@ module Aruba
103
92
  self
104
93
  end
105
94
 
95
+ # Get stdout of all processes
96
+ #
97
+ # @return [String]
98
+ # The stdout of all processes which have run before
99
+ def all_stdout
100
+ aruba.command_monitor.all_stdout
101
+ end
102
+
103
+ # Get stderr of all processes
104
+ #
105
+ # @return [String]
106
+ # The stderr of all processes which have run before
107
+ def all_stderr
108
+ aruba.command_monitor.all_stderr
109
+ end
110
+
111
+ # Get stderr and stdout of all processes
112
+ #
113
+ # @return [String]
114
+ # The stderr and stdout of all processes which have run before
115
+ def all_output
116
+ aruba.command_monitor.all_output
117
+ end
118
+
106
119
  # Find a started command
107
120
  #
108
121
  # @param [String, Command] commandline
@@ -119,108 +132,33 @@ module Aruba
119
132
  # @param [Hash] opts
120
133
  # Options
121
134
  #
122
- # @option [Integer] exit_timeout
135
+ # @option opts [Numeric] exit_timeout
123
136
  # If the timeout is reached the command will be killed
124
137
  #
125
- # @option [Integer] io_wait_timeout
138
+ # @option opts [Numeric] io_wait_timeout
126
139
  # Wait for IO to finish
127
140
  #
128
- # @option [Integer] startup_wait_time
141
+ # @option opts [Numeric] startup_wait_time
129
142
  # Wait for a command to start
130
143
  #
131
- # @option [String] stop_signal
144
+ # @option opts [String] stop_signal
132
145
  # Use signal to stop command
133
146
  #
134
147
  # @yield [SpawnProcess]
135
148
  # Run block with process
136
149
  #
137
- # rubocop:disable Metrics/MethodLength
138
- # rubocop:disable Metrics/CyclomaticComplexity
139
- def run_command(*args)
140
- fail ArgumentError, 'Please pass at least a command as first argument.' if args.empty?
141
-
142
- cmd = args.shift
143
-
144
- if args.last.is_a? Hash
145
- opts = args.pop
146
-
147
- exit_timeout = opts[:exit_timeout].nil? ? aruba.config.exit_timeout : opts[:exit_timeout]
148
- io_wait_timeout = opts[:io_wait_timeout].nil? ? aruba.config.io_wait_timeout : opts[:io_wait_timeout]
149
- stop_signal = opts[:stop_signal].nil? ? aruba.config.stop_signal : opts[:stop_signal]
150
- startup_wait_time = opts[:startup_wait_time].nil? ? aruba.config.startup_wait_time : opts[:startup_wait_time]
151
- else
152
- if args.size > 0
153
- Aruba.platform.deprecated(
154
- "Please pass options to `#run_command` as named parameters/hash and don\'t use the old style, e.g. `#run_command('cmd', :exit_timeout => 5)`.")
155
- end
156
-
157
- exit_timeout = args[0].nil? ? aruba.config.exit_timeout : args[0]
158
- io_wait_timeout = args[1].nil? ? aruba.config.io_wait_timeout : args[1]
159
- stop_signal = args[2].nil? ? aruba.config.stop_signal : args[2]
160
- startup_wait_time = args[3].nil? ? aruba.config.startup_wait_time : args[3]
161
- end
162
-
163
- cmd = replace_variables(cmd)
164
-
165
- @commands ||= []
166
- @commands << cmd
167
-
168
- environment = aruba.environment
169
- working_directory = expand_path('.')
170
- event_bus = aruba.event_bus
171
-
172
- cmd = Aruba.platform.detect_ruby(cmd)
173
-
174
- mode = if Aruba.process
175
- # rubocop:disable Metrics/LineLength
176
- Aruba.platform.deprecated('The use of "Aruba.process = <process>" and "Aruba.process.main_class" is deprecated. Use "Aruba.configure { |config| config.command_launcher = :in_process|:debug|:spawn }" and "Aruba.configure { |config| config.main_class = <klass> }" instead.')
177
- # rubocop:enable Metrics/LineLength
178
- Aruba.process
179
- else
180
- aruba.config.command_launcher
181
- end
182
-
183
- main_class = if Aruba.process.respond_to?(:main_class) && Aruba.process.main_class
184
- # rubocop:disable Metrics/LineLength
185
- Aruba.platform.deprecated('The use of "Aruba.process = <process>" and "Aruba.process.main_class" is deprecated. Use "Aruba.configure { |config| config.command_launcher = :in_process|:debug|:spawn }" and "Aruba.configure { |config| config.main_class = <klass> }" instead.')
186
- # rubocop:enable Metrics/LineLength
187
- Aruba.process.main_class
188
- else
189
- aruba.config.main_class
190
- end
191
-
192
- command = Command.new(
193
- cmd,
194
- :mode => mode,
195
- :exit_timeout => exit_timeout,
196
- :io_wait_timeout => io_wait_timeout,
197
- :working_directory => working_directory,
198
- :environment => environment.to_hash,
199
- :main_class => main_class,
200
- :stop_signal => stop_signal,
201
- :startup_wait_time => startup_wait_time,
202
- :event_bus => event_bus
203
- )
150
+ def run_command(cmd, opts = {})
151
+ command = prepare_command(cmd, opts)
204
152
 
205
- if aruba.config.before? :cmd
206
- # rubocop:disable Metrics/LineLength
207
- Aruba.platform.deprecated('The use of "before"-hook" ":cmd" is deprecated. Use ":command" instead. Please be aware that this hook gets the command passed in not the cmdline itself. To get the commandline use "#cmd.commandline"')
208
- # rubocop:enable Metrics/LineLength
209
- aruba.config.before(:cmd, self, cmd)
153
+ unless command.interactive?
154
+ raise NotImplementedError,
155
+ 'Running interactively is not supported with this process launcher.'
210
156
  end
211
157
 
212
- aruba.config.before(:command, self, command)
213
-
214
- command.start
215
-
216
- aruba.announcer.announce(:stop_signal, command.pid, stop_signal) if stop_signal
217
-
218
- aruba.config.after(:command, self, command)
158
+ start_command(command)
219
159
 
220
160
  block_given? ? yield(command) : command
221
161
  end
222
- # rubocop:enable Metrics/CyclomaticComplexity
223
- # rubocop:enable Metrics/MethodLength
224
162
 
225
163
  # Run a command with aruba
226
164
  #
@@ -233,70 +171,45 @@ module Aruba
233
171
  # @param [Hash] options
234
172
  # Options for aruba
235
173
  #
236
- # @option [TrueClass,FalseClass] fail_on_error
174
+ # @option options [Boolean] fail_on_error
237
175
  # Should aruba fail on error?
238
176
  #
239
- # @option [Integer] exit_timeout
177
+ # @option options [Numeric] exit_timeout
240
178
  # Timeout for execution
241
179
  #
242
- # @option [Integer] io_wait_timeout
180
+ # @option options [Numeric] io_wait_timeout
243
181
  # Timeout for IO - STDERR, STDOUT
244
182
  #
245
- # rubocop:disable Metrics/CyclomaticComplexity
246
- # rubocop:disable Metrics/MethodLength
247
- def run_command_and_stop(*args)
248
- fail ArgumentError, 'Please pass at least a command as first argument.' if args.empty?
249
-
250
- cmd = args.shift
251
-
252
- if args.last.is_a? Hash
253
- opts = args.pop
254
- fail_on_error = opts.delete(:fail_on_error) == true ? true : false
255
- else
256
- if args.size > 0
257
- # rubocop:disable Metrics/LineLength
258
- Aruba.platform.deprecated("Please pass options to `#run_command_and_stop` as named parameters/hash and don\'t use the old style with positional parameters, NEW: e.g. `#run_command_and_stop('cmd', :exit_timeout => 5)`.")
259
- # rubocop:enable Metrics/LineLength
260
- end
261
-
262
- fail_on_error = args[0] == false ? false : true
263
-
264
- opts = {
265
- :exit_timeout => (args[1] || aruba.config.exit_timeout),
266
- :io_wait_timeout => (args[2] || aruba.config.io_wait_timeout),
267
- :stop_signal => (args[3] || aruba.config.stop_signal),
268
- :startup_wait_time => (args[4] || aruba.config.startup_wait_time)
269
- }
270
- end
271
-
272
- command = run_command(cmd, opts)
183
+ def run_command_and_stop(cmd, opts = {})
184
+ fail_on_error = if opts.key?(:fail_on_error)
185
+ opts.delete(:fail_on_error) == true
186
+ else
187
+ true
188
+ end
189
+
190
+ command = prepare_command(cmd, opts)
191
+ start_command(command)
273
192
  command.stop
274
193
 
275
- if Aruba::VERSION < '1'
276
- @last_exit_status = command.exit_status
277
- @timed_out = command.timed_out?
278
- end
194
+ return unless fail_on_error
279
195
 
280
- if fail_on_error
281
- begin
282
- expect(command).to have_finished_in_time
283
- expect(command).to be_successfully_executed
284
- rescue RSpec::Expectations::ExpectationNotMetError => e
285
- aruba.announcer.activate(aruba.config.activate_announcer_on_command_failure)
286
- aruba.event_bus.notify Events::CommandStopped.new(command)
287
- raise e
288
- end
196
+ begin
197
+ expect(command).to have_finished_in_time
198
+ expect(command).to be_successfully_executed
199
+ rescue ::RSpec::Expectations::ExpectationNotMetError => e
200
+ aruba.announcer.activate(aruba.config.activate_announcer_on_command_failure)
201
+ aruba.event_bus.notify Events::CommandStopped.new(command)
202
+ raise e
289
203
  end
290
204
  end
291
- # rubocop:enable Metrics/CyclomaticComplexity
292
- # rubocop:enable Metrics/MethodLength
293
205
 
294
206
  # Provide data to command via stdin
295
207
  #
296
208
  # @param [String] input
297
209
  # The input for the command
298
210
  def type(input)
299
- return close_input if "" == input
211
+ return close_input if input == "\u0004"
212
+
300
213
  last_command_started.write(input << "\n")
301
214
  end
302
215
 
@@ -304,6 +217,59 @@ module Aruba
304
217
  def close_input
305
218
  last_command_started.close_io(:stdin)
306
219
  end
220
+
221
+ private
222
+
223
+ # rubocop:disable Metrics/MethodLength
224
+ def prepare_command(cmd, opts)
225
+ exit_timeout = opts[:exit_timeout].nil? ? aruba.config.exit_timeout : opts[:exit_timeout]
226
+ io_wait_timeout = opts[:io_wait_timeout].nil? ? aruba.config.io_wait_timeout : opts[:io_wait_timeout]
227
+ stop_signal = opts[:stop_signal].nil? ? aruba.config.stop_signal : opts[:stop_signal]
228
+ startup_wait_time = opts[:startup_wait_time].nil? ? aruba.config.startup_wait_time : opts[:startup_wait_time]
229
+
230
+ cmd = replace_variables(cmd)
231
+
232
+ @commands ||= []
233
+ @commands << cmd
234
+
235
+ environment = aruba.environment
236
+ working_directory = expand_path('.')
237
+ event_bus = aruba.event_bus
238
+
239
+ cmd = Aruba.platform.detect_ruby(cmd)
240
+
241
+ mode = aruba.config.command_launcher
242
+
243
+ main_class = aruba.config.main_class
244
+
245
+ Command.new(
246
+ cmd,
247
+ mode: mode,
248
+ exit_timeout: exit_timeout,
249
+ io_wait_timeout: io_wait_timeout,
250
+ working_directory: working_directory,
251
+ environment: environment.to_hash,
252
+ main_class: main_class,
253
+ stop_signal: stop_signal,
254
+ startup_wait_time: startup_wait_time,
255
+ event_bus: event_bus
256
+ )
257
+ end
258
+
259
+ # rubocop:enable Metrics/MethodLength
260
+
261
+ def start_command(command)
262
+ aruba.config.before(:command, self, command)
263
+
264
+ in_current_directory do
265
+ command.start
266
+ end
267
+
268
+ stop_signal = command.stop_signal
269
+ aruba.announcer.announce(:stop_signal, command.pid, stop_signal) if stop_signal
270
+
271
+ aruba.config.after(:command, self, command)
272
+ end
307
273
  end
308
274
  end
309
275
  end
@@ -3,8 +3,6 @@ require 'aruba/runtime'
3
3
  require 'aruba/errors'
4
4
  require 'aruba/setup'
5
5
 
6
- require 'aruba/config/jruby'
7
-
8
6
  # Aruba
9
7
  module Aruba
10
8
  # Api
@@ -17,6 +15,8 @@ module Aruba
17
15
 
18
16
  # Aruba Runtime
19
17
  def aruba
18
+ # TODO: Check this variable being accessed inconsistently. Should only be using the memo!
19
+ # Renaming this to `aruba` causes 100's of rspec failures. Needs a deeper dive, approach with caution!
20
20
  @_aruba_runtime ||= Runtime.new
21
21
  end
22
22
 
@@ -31,6 +31,15 @@ module Aruba
31
31
  self
32
32
  end
33
33
 
34
+ # Execute block in Aruba's current directory
35
+ #
36
+ # @yield
37
+ # The block which should be run in current directory
38
+ def in_current_directory(&block)
39
+ create_directory '.' unless directory?('.')
40
+ cd('.', &block)
41
+ end
42
+
34
43
  # Switch to directory
35
44
  #
36
45
  # @param [String] dir
@@ -55,15 +64,16 @@ module Aruba
55
64
  aruba.current_directory << dir
56
65
  new_directory = expand_path('.')
57
66
 
58
- aruba.event_bus.notify Events::ChangedWorkingDirectory.new(:old => old_directory, :new => new_directory)
67
+ aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory, new: new_directory)
59
68
 
60
69
  old_dir = Aruba.platform.getwd
61
70
 
62
- Aruba.platform.chdir File.join(aruba.root_directory, aruba.current_directory)
71
+ real_new_directory = File.expand_path(aruba.current_directory, aruba.root_directory)
72
+ Aruba.platform.chdir real_new_directory
63
73
 
64
74
  result = with_environment(
65
75
  'OLDPWD' => old_dir,
66
- 'PWD' => File.expand_path(File.join(aruba.root_directory, aruba.current_directory)),
76
+ 'PWD' => real_new_directory,
67
77
  &block
68
78
  )
69
79
  ensure
@@ -80,7 +90,7 @@ module Aruba
80
90
  aruba.current_directory << dir
81
91
  new_directory = expand_path('.')
82
92
 
83
- aruba.event_bus.notify Events::ChangedWorkingDirectory.new(:old => old_directory, :new => new_directory)
93
+ aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory, new: new_directory)
84
94
 
85
95
  self
86
96
  end
@@ -117,58 +127,66 @@ module Aruba
117
127
  # # => <path>/test/fixtures/file
118
128
  # expand_path('%/file')
119
129
  #
130
+ # @example Absolute directory
131
+ #
132
+ # # => /foo/bar
133
+ # expand_path('/foo/bar')
134
+ #
120
135
  # rubocop:disable Metrics/MethodLength
121
136
  # rubocop:disable Metrics/CyclomaticComplexity
137
+ # rubocop:disable Metrics/PerceivedComplexity
122
138
  def expand_path(file_name, dir_string = nil)
123
- check_for_deprecated_variables if Aruba::VERSION < '1'
124
-
125
- # rubocop:disable Metrics/LineLength
139
+ # rubocop:disable Layout/LineLength
126
140
  message = %(Filename "#{file_name}" needs to be a string. It cannot be nil or empty either. Please use `expand_path('.')` if you want the current directory to be expanded.)
127
- # rubocop:enable Metrics/LineLength
141
+ # rubocop:enable Layout/LineLength
128
142
 
129
143
  fail ArgumentError, message unless file_name.is_a?(String) && !file_name.empty?
130
144
 
131
- # rubocop:disable Metrics/LineLength
132
- aruba.logger.warn %(`aruba`'s working directory does not exist. Maybe you forgot to run `setup_aruba` before using it's API. This warning will be an error from 1.0.0) unless Aruba.platform.directory? File.join(aruba.config.root_directory, aruba.config.working_directory)
133
- # rubocop:enable Metrics/LineLength
134
-
135
- if RUBY_VERSION < '1.9'
136
- prefix = file_name.chars.to_a[0].to_s
137
- rest = if file_name.chars.to_a[2..-1].nil?
138
- nil
139
- else
140
- file_name.chars.to_a[2..-1].join
141
- end
142
- else
143
- prefix = file_name[0]
144
- rest = file_name[2..-1]
145
- end
145
+ # rubocop:disable Layout/LineLength
146
+ fail %(Aruba's working directory does not exist. Maybe you forgot to run `setup_aruba` before using its API.) unless Aruba.platform.directory? File.join(aruba.config.root_directory, aruba.config.working_directory)
147
+
148
+ # rubocop:enable Layout/LineLength
149
+
150
+ prefix = file_name[0]
151
+ rest = file_name[2..-1]
146
152
 
147
153
  if aruba.config.fixtures_path_prefix == prefix
148
154
  path = File.join(*[aruba.fixtures_directory, rest].compact)
149
155
 
150
- # rubocop:disable Metrics/LineLength
156
+ # rubocop:disable Layout/LineLength
151
157
  fail ArgumentError, %(Fixture "#{rest}" does not exist in fixtures directory "#{aruba.fixtures_directory}". This was the one we found first on your system from all possible candidates: #{aruba.config.fixtures_directories.map { |p| format('"%s"', p) }.join(', ')}.) unless Aruba.platform.exist? path
152
- # rubocop:enable Metrics/LineLength
158
+
159
+ # rubocop:enable Layout/LineLength
153
160
 
154
161
  path
155
- elsif '~' == prefix
162
+ elsif prefix == '~'
156
163
  path = with_environment do
157
- ArubaPath.new(File.expand_path(file_name))
164
+ File.expand_path(file_name)
158
165
  end
159
166
 
160
- fail ArgumentError, 'Expanding "~/" to "/" is not allowed' if path.to_s == '/'
161
- fail ArgumentError, %(Expanding "~/" to a relative path "#{path}" is not allowed) unless path.absolute?
167
+ fail ArgumentError, 'Expanding "~/" to "/" is not allowed' if path == '/'
168
+ fail ArgumentError, %(Expanding "~/" to a relative path "#{path}" is not allowed) unless Aruba.platform.absolute_path? path
162
169
 
163
170
  path.to_s
171
+ elsif absolute? file_name
172
+ unless aruba.config.allow_absolute_paths
173
+ caller_location = caller_locations(1, 1).first
174
+ caller_file_line = "#{caller_location.path}:#{caller_location.lineno}"
175
+ aruba.logger.warn "Aruba's `expand_path` method was called with an absolute path at #{caller_file_line}, which is not recommended." \
176
+ ' Change the call to pass a relative path or set config.allow_absolute_paths = true to silence this warning'
177
+ end
178
+ file_name
164
179
  else
165
- directory = File.join(aruba.root_directory, aruba.current_directory)
166
- directory = File.expand_path(dir_string, directory) if dir_string
167
- File.expand_path(file_name, directory)
180
+ with_environment do
181
+ directory = File.expand_path(aruba.current_directory, aruba.root_directory)
182
+ directory = File.expand_path(dir_string, directory) if dir_string
183
+ File.expand_path(file_name, directory)
184
+ end
168
185
  end
169
186
  end
170
187
  # rubocop:enable Metrics/MethodLength
171
- # rubocop:enable Metrics/CyclomaticComplexity
188
+ # rubocop:enable Metrics/CyclomaticComplexity
189
+ # rubocop:enable Metrics/PerceivedComplexity
172
190
 
173
191
  # Run block with environment
174
192
  #
@@ -178,14 +196,10 @@ module Aruba
178
196
  # @yield
179
197
  # The block of code which should be run with the changed environment variables
180
198
  def with_environment(env = {}, &block)
181
- old_aruba_env = aruba.environment.to_h
182
-
183
- # make sure the old environment is really restored in "ENV"
184
- Aruba.platform.with_environment aruba.environment.update(env).to_h, &block
185
- ensure
186
- # make sure the old environment is really restored in "aruba.environment"
187
- aruba.environment.clear
188
- aruba.environment.update old_aruba_env
199
+ aruba.environment.nest do |nested_env|
200
+ nested_env.update(env)
201
+ Aruba.platform.with_environment nested_env.to_h, &block
202
+ end
189
203
  end
190
204
  end
191
205
  end