aruba 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +72 -1
  3. data/CONTRIBUTING.md +11 -31
  4. data/README.md +1 -2
  5. data/exe/aruba +2 -2
  6. data/lib/aruba.rb +1 -1
  7. data/lib/aruba/api.rb +11 -12
  8. data/lib/aruba/api/bundler.rb +18 -3
  9. data/lib/aruba/api/commands.rb +19 -22
  10. data/lib/aruba/api/core.rb +65 -48
  11. data/lib/aruba/api/environment.rb +13 -5
  12. data/lib/aruba/api/filesystem.rb +69 -39
  13. data/lib/aruba/api/text.rb +15 -3
  14. data/lib/aruba/aruba_path.rb +3 -4
  15. data/lib/aruba/basic_configuration.rb +52 -71
  16. data/lib/aruba/basic_configuration/option.rb +2 -2
  17. data/lib/aruba/cli.rb +9 -6
  18. data/lib/aruba/command.rb +4 -4
  19. data/lib/aruba/config/jruby.rb +9 -9
  20. data/lib/aruba/config_wrapper.rb +17 -2
  21. data/lib/aruba/configuration.rb +37 -32
  22. data/lib/aruba/console.rb +11 -13
  23. data/lib/aruba/console/help.rb +9 -6
  24. data/lib/aruba/contracts/absolute_path.rb +2 -2
  25. data/lib/aruba/contracts/enum.rb +1 -1
  26. data/lib/aruba/contracts/is_power_of_two.rb +3 -3
  27. data/lib/aruba/contracts/relative_path.rb +2 -2
  28. data/lib/aruba/cucumber.rb +7 -7
  29. data/lib/aruba/cucumber/command.rb +106 -95
  30. data/lib/aruba/cucumber/environment.rb +7 -7
  31. data/lib/aruba/cucumber/file.rb +50 -26
  32. data/lib/aruba/cucumber/hooks.rb +32 -29
  33. data/lib/aruba/cucumber/testing_frameworks.rb +32 -30
  34. data/lib/aruba/event_bus.rb +6 -4
  35. data/lib/aruba/event_bus/name_resolver.rb +12 -11
  36. data/lib/aruba/events.rb +2 -1
  37. data/lib/aruba/file_size.rb +1 -1
  38. data/lib/aruba/generators/script_file.rb +2 -2
  39. data/lib/aruba/hooks.rb +2 -4
  40. data/lib/aruba/in_config_wrapper.rb +8 -5
  41. data/lib/aruba/initializer.rb +14 -12
  42. data/lib/aruba/matchers/base/base_matcher.rb +3 -12
  43. data/lib/aruba/matchers/base/message_indenter.rb +2 -2
  44. data/lib/aruba/matchers/base/object_formatter.rb +2 -5
  45. data/lib/aruba/matchers/collection.rb +1 -1
  46. data/lib/aruba/matchers/collection/all.rb +1 -1
  47. data/lib/aruba/matchers/collection/include_an_object.rb +6 -6
  48. data/lib/aruba/matchers/command.rb +1 -1
  49. data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -4
  50. data/lib/aruba/matchers/command/have_exit_status.rb +3 -1
  51. data/lib/aruba/matchers/command/have_finished_in_time.rb +4 -2
  52. data/lib/aruba/matchers/command/have_output.rb +4 -2
  53. data/lib/aruba/matchers/command/have_output_on_stderr.rb +3 -1
  54. data/lib/aruba/matchers/command/have_output_on_stdout.rb +3 -1
  55. data/lib/aruba/matchers/directory.rb +1 -1
  56. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +2 -2
  57. data/lib/aruba/matchers/directory/have_sub_directory.rb +9 -4
  58. data/lib/aruba/matchers/environment.rb +1 -1
  59. data/lib/aruba/matchers/file.rb +1 -1
  60. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +1 -1
  61. data/lib/aruba/matchers/file/be_an_existing_executable.rb +2 -2
  62. data/lib/aruba/matchers/file/be_an_existing_file.rb +2 -2
  63. data/lib/aruba/matchers/file/have_file_content.rb +1 -1
  64. data/lib/aruba/matchers/file/have_file_size.rb +5 -3
  65. data/lib/aruba/matchers/file/have_same_file_content.rb +2 -2
  66. data/lib/aruba/matchers/path.rb +1 -1
  67. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +1 -1
  68. data/lib/aruba/matchers/path/be_an_absolute_path.rb +1 -1
  69. data/lib/aruba/matchers/path/be_an_existing_path.rb +1 -1
  70. data/lib/aruba/matchers/path/have_permissions.rb +9 -6
  71. data/lib/aruba/matchers/string.rb +1 -1
  72. data/lib/aruba/matchers/string/include_output_string.rb +1 -1
  73. data/lib/aruba/matchers/string/match_output_string.rb +1 -1
  74. data/lib/aruba/matchers/string/output_string_eq.rb +1 -1
  75. data/lib/aruba/platform.rb +2 -2
  76. data/lib/aruba/platforms/announcer.rb +29 -17
  77. data/lib/aruba/platforms/aruba_file_creator.rb +3 -1
  78. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +7 -2
  79. data/lib/aruba/platforms/aruba_logger.rb +11 -10
  80. data/lib/aruba/platforms/command_monitor.rb +7 -9
  81. data/lib/aruba/platforms/determine_disk_usage.rb +2 -4
  82. data/lib/aruba/platforms/filesystem_status.rb +20 -14
  83. data/lib/aruba/platforms/simple_table.rb +3 -3
  84. data/lib/aruba/platforms/unix_command_string.rb +2 -2
  85. data/lib/aruba/platforms/unix_environment_variables.rb +2 -4
  86. data/lib/aruba/platforms/unix_platform.rb +23 -23
  87. data/lib/aruba/platforms/unix_which.rb +2 -2
  88. data/lib/aruba/platforms/windows_command_string.rb +2 -2
  89. data/lib/aruba/platforms/windows_environment_variables.rb +3 -2
  90. data/lib/aruba/platforms/windows_platform.rb +7 -7
  91. data/lib/aruba/platforms/windows_which.rb +8 -4
  92. data/lib/aruba/processes/basic_process.rb +4 -4
  93. data/lib/aruba/processes/debug_process.rb +5 -3
  94. data/lib/aruba/processes/in_process.rb +10 -8
  95. data/lib/aruba/processes/spawn_process.rb +28 -25
  96. data/lib/aruba/rspec.rb +30 -20
  97. data/lib/aruba/runtime.rb +16 -9
  98. data/lib/aruba/setup.rb +25 -12
  99. data/lib/aruba/version.rb +1 -1
  100. metadata +77 -88
  101. data/.cucumberproignore +0 -3
  102. data/.document +0 -5
  103. data/.github/ISSUE_TEMPLATE.md +0 -48
  104. data/.github/PULL_REQUEST_TEMPLATE.md +0 -41
  105. data/.gitignore +0 -38
  106. data/.rspec +0 -3
  107. data/.rubocop.yml +0 -31
  108. data/.rubocop_todo.yml +0 -262
  109. data/.simplecov +0 -36
  110. data/.travis.yml +0 -62
  111. data/.yardopts +0 -11
  112. data/Dockerfile +0 -67
  113. data/Gemfile +0 -12
  114. data/Rakefile +0 -80
  115. data/TODO.md +0 -13
  116. data/appveyor.yml +0 -29
  117. data/aruba.gemspec +0 -54
  118. data/bin/console +0 -7
  119. data/bin/test +0 -9
  120. data/config/.gitignore +0 -1
  121. data/cucumber.yml +0 -6
  122. data/docker-compose.yml +0 -26
  123. data/fixtures/cli-app/.gitignore +0 -9
  124. data/fixtures/cli-app/.rspec +0 -2
  125. data/fixtures/cli-app/README.md +0 -39
  126. data/fixtures/cli-app/Rakefile +0 -1
  127. data/fixtures/cli-app/bin/aruba-test-cli +0 -6
  128. data/fixtures/cli-app/cli-app.gemspec +0 -25
  129. data/fixtures/cli-app/features/support/aruba.rb +0 -1
  130. data/fixtures/cli-app/features/support/env.rb +0 -1
  131. data/fixtures/cli-app/lib/cli/app.rb +0 -9
  132. data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +0 -15
  133. data/fixtures/cli-app/lib/cli/app/version.rb +0 -5
  134. data/fixtures/cli-app/script/console +0 -14
  135. data/fixtures/cli-app/spec/spec_helper.rb +0 -7
  136. data/fixtures/cli-app/spec/support/aruba.rb +0 -1
  137. data/fixtures/copy/file.txt +0 -1
  138. data/fixtures/empty-app/.gitignore +0 -9
  139. data/fixtures/empty-app/.rspec +0 -2
  140. data/fixtures/empty-app/README.md +0 -24
  141. data/fixtures/empty-app/Rakefile +0 -1
  142. data/fixtures/empty-app/cli-app.gemspec +0 -25
  143. data/fixtures/empty-app/lib/cli/app.rb +0 -7
  144. data/fixtures/empty-app/lib/cli/app/version.rb +0 -5
  145. data/fixtures/getting-started-app/.gitignore +0 -4
  146. data/fixtures/getting-started-app/Gemfile +0 -4
  147. data/fixtures/getting-started-app/README.md +0 -3
  148. data/fixtures/getting-started-app/features/support/env.rb +0 -1
  149. data/lib/aruba/extensions/string/strip.rb +0 -25
  150. data/lib/aruba/tasks/docker_helpers.rb +0 -154
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63d0e00b28a69fa235c0586425c501669cb313ce3dae63a76a33386eb358085e
4
- data.tar.gz: be16476fe85c35d571574194c46c426cbb5805fff5fe2277b04b3f32f7098dc8
3
+ metadata.gz: 9b464d3e65f58bdcafd421ed026c8541de9cc9723258f76175b8b8ad3dab4621
4
+ data.tar.gz: 2215471629083ac51e4b5e31694ac60408d374f8a0aa504addb79ae70f364e84
5
5
  SHA512:
6
- metadata.gz: 77fcdcd8b492e23fc72be16b48dd9913a3e7615ade362006cff3754661c0176c4483ce9d78ac7aa9d0c4da08ff1ae2c4f741b0f80ff93a221b10f7f2806b7c5f
7
- data.tar.gz: 1d8f1f0f2879f5fef29c3baeee8d2041cd2d130e8cdfed5e77dac075960c0fd6ee0c813f6be1400e176b3a6846819946f1e5b56a02be2933b1e1b7682c313102
6
+ metadata.gz: 2222d8d29dccca2bcbe973512ae24bbdc14a82d2b7dbb3e1fd84b72c35793af4919043cc077bacb2e48db3fbe9c8f60d2c8ed032a36a93d88a0c2ec3ef2e190f
7
+ data.tar.gz: 007bda65f38b79499f0fda2243f44539c76e541d871cf66b841adafbe1f9a7800946d96c32637264313a24f381f4f97d176a93a02d0e171f1d116d3467b58c19
data/CHANGELOG.md CHANGED
@@ -6,6 +6,56 @@ This project adheres to [Semantic Versioning][1].
6
6
 
7
7
  This document is formatted according to the principles of [Keep A CHANGELOG][2].
8
8
 
9
+ ## [Unreleased]
10
+
11
+ ## [1.1.0] / 2021-04-14
12
+
13
+ * Add step and API to add whole lines to a file ([#780] by [mvz])
14
+ * Deprecate file creation when using `append_to_file` ([#781] by [mvz])
15
+ * Update dependencies to cucumber to allow working with incoming major versions
16
+ ([#801] by [mattwynne])
17
+
18
+ ## [1.0.4] / 2021-01-04
19
+
20
+ * Update rubocop and fix new offenses (various pull requests)
21
+ * Turn off Cucumber publish warning in CI ([#737] by [olleolleolle])
22
+ * Move CI from Travis CI to GitHub Actions ([#738] by [mvz])
23
+ * Remove superfluous :each from before hooks in RSpec-related cucumber
24
+ scenarios ([#748] by [mvz])
25
+ * Make disabling Bundler more robust ([#750] by [mvz])
26
+ * Officially support Ruby 3.0 ([#763] by [mvz])
27
+ * Clean up hook methods in configuration ([#751] by [mvz])
28
+ * Speed up RSpec suite ([#767] by [mvz])
29
+ * Speed up Cucumber suite ([#766] and [#771] by [mvz])
30
+ * Remove obsolete `String#strip_heredoc` monkey-patch ([#769] by [mvz])
31
+ * Simplify configuration option specification ([#772] by [mvz])
32
+
33
+ ## [1.0.3]
34
+
35
+ * Loosen Cucumber dependency to allow Cucumber 5.0 ([#727] by [mvz])
36
+ * Update rubocop and fix new offenses ([#719] and [#724] by [mvz])
37
+ * Rework gemspec to avoid dependency on git ([#721] by [utkarsh2102], [#725] by [mvz])
38
+
39
+ ## [1.0.2]
40
+
41
+ * Loosen childprocess dependency
42
+ ([00cb0789](https://github.com/cucumber/aruba/commit/00cb07897c9f99e59bea630ae164cf5aa78fa76c)
43
+ by [mvz]).
44
+ * Various small code cleanups ([#717] by [mvz])
45
+
46
+ ## [1.0.1]
47
+
48
+ ### Bug fixes
49
+
50
+ * Allow use of Aruba with Cucumber 4 ([#715] by [mvz])
51
+
52
+ ### Code quality and documentation improvements
53
+
54
+ * Fix RuboCop offenses ([#693] and [#708] by [luke-hill], [#710], [#711] and
55
+ [#712] by [mvz])
56
+ * Use recent Rake version in fixtures ([#709] by [mvz])
57
+ * Repair YARD annotations ([#707] by [olleolleolle])
58
+
9
59
  ## [1.0.0]
10
60
 
11
61
  ### Breaking changes compared to Aruba 0.14.x
@@ -916,18 +966,34 @@ Note: These are changes w.r.t. Aruba version 0.14.1.
916
966
  [scottj97]: https://github.com/scottj97
917
967
  [stamhankar999]: https://github.com/stamhankar999
918
968
  [taylor]: https://github.com/taylor
969
+ [utkarsh2102]: https://github.com/utkarsh2102
919
970
  [tdreyno]: https://github.com/tdreyno
920
971
  [xtrasimplicity]: https://github.com/xtrasimplicity
921
972
  [y-higuchi]: https://github.com/y-higuchi
922
973
 
923
974
  <!-- issues & pull requests -->
924
975
 
976
+ [#801]: https://github.com/cucumber/aruba/pull/801
977
+ [#727]: https://github.com/cucumber/aruba/pull/727
978
+ [#725]: https://github.com/cucumber/aruba/pull/725
979
+ [#724]: https://github.com/cucumber/aruba/pull/724
980
+ [#721]: https://github.com/cucumber/aruba/pull/721
981
+ [#719]: https://github.com/cucumber/aruba/pull/719
982
+ [#717]: https://github.com/cucumber/aruba/pull/717
983
+ [#715]: https://github.com/cucumber/aruba/pull/715
984
+ [#712]: https://github.com/cucumber/aruba/pull/712
985
+ [#711]: https://github.com/cucumber/aruba/pull/711
986
+ [#710]: https://github.com/cucumber/aruba/pull/710
987
+ [#709]: https://github.com/cucumber/aruba/pull/709
988
+ [#708]: https://github.com/cucumber/aruba/pull/708
989
+ [#707]: https://github.com/cucumber/aruba/pull/707
925
990
  [#704]: https://github.com/cucumber/aruba/pull/704
926
991
  [#703]: https://github.com/cucumber/aruba/pull/703
927
992
  [#702]: https://github.com/cucumber/aruba/pull/702
928
993
  [#701]: https://github.com/cucumber/aruba/pull/701
929
994
  [#698]: https://github.com/cucumber/aruba/pull/698
930
995
  [#696]: https://github.com/cucumber/aruba/pull/696
996
+ [#693]: https://github.com/cucumber/aruba/pull/693
931
997
  [#692]: https://github.com/cucumber/aruba/pull/692
932
998
  [#690]: https://github.com/cucumber/aruba/pull/690
933
999
  [#689]: https://github.com/cucumber/aruba/pull/689
@@ -1186,7 +1252,12 @@ Note: These are changes w.r.t. Aruba version 0.14.1.
1186
1252
 
1187
1253
  <!-- Releases -->
1188
1254
 
1189
- [Unreleased]: https://github.com/cucumber/aruba/compare/v1.0.0...master
1255
+ [Unreleased]: https://github.com/cucumber/aruba/compare/v1.1.0...master
1256
+ [1.1.0]: https://github.com/cucumber/aruba/compare/v1.0.4...v1.1.0
1257
+ [1.0.4]: https://github.com/cucumber/aruba/compare/v1.0.3...v1.0.4
1258
+ [1.0.3]: https://github.com/cucumber/aruba/compare/v1.0.2...v1.0.3
1259
+ [1.0.2]: https://github.com/cucumber/aruba/compare/v1.0.1...v1.0.2
1260
+ [1.0.1]: https://github.com/cucumber/aruba/compare/v1.0.0...v1.0.1
1190
1261
  [1.0.0]: https://github.com/cucumber/aruba/compare/v1.0.0.pre.alpha.5...v1.0.0
1191
1262
  [1.0.0.pre.alpha.5]: https://github.com/cucumber/aruba/compare/v1.0.0.pre.alpha.4...v1.0.0.pre.alpha.5
1192
1263
  [1.0.0.pre.alpha.4]: https://github.com/cucumber/aruba/compare/v1.0.0.pre.alpha.3...v1.0.0.pre.alpha.4
data/CONTRIBUTING.md CHANGED
@@ -118,22 +118,15 @@ bundle install
118
118
 
119
119
  Run the following command to run the test suite.
120
120
 
121
- ```bash
122
- # Run the test suite
123
- bin/test
124
- ```
125
-
126
- Or use these Rake tasks:
127
-
128
121
  ```bash
129
122
  # Run the whole test suite
130
- rake test
123
+ bundle exec rake
131
124
  # Run RSpec tests
132
- rake spec
125
+ bundle exec rake spec
133
126
  # Run Cucumber features
134
- rake cucumber
127
+ bundle exec rake cucumber
135
128
  # Run Cucumber features which are "WORK IN PROGRESS" and are allowed to fail
136
- rake cucumber:wip
129
+ bundle exec rake cucumber:wip
137
130
  ```
138
131
 
139
132
  If you have problems because our assumptions about your local setup are wrong,
@@ -142,19 +135,14 @@ installed on your local system.
142
135
 
143
136
  ```bash
144
137
  # Build the docker container
145
- bundle exec rake docker:build
138
+ docker build -t test-aruba .
146
139
 
147
- # Alternative: Build with disabled cache
148
- bundle exec rake 'docker:build[false]'
140
+ # Open a bash shell inside the container with attached volume so changes to the
141
+ # code will be picked up automatically.
142
+ docker run -v $PWD:/aruba --rm -it test-aruba:latest bash
149
143
 
150
- # Build image with version tag
151
- bundle exec rake 'docker:build[false, 0.1.0]'
152
-
153
- # Run the whole test suite in "docker"-container
154
- RUN_IN_DOCKER=1 bin/test
155
-
156
- # Run only selected scenario
157
- RUN_IN_DOCKER=1 bin/test cucumber features/steps/command/shell.feature:14
144
+ # Run the test suite
145
+ bundle exec rake
158
146
  ```
159
147
 
160
148
  ### Installing your own gems used for development
@@ -210,8 +198,6 @@ bundle exec rake install:local
210
198
  entries for all fixes.
211
199
  * No need to add a [`CHANGELOG.md`] header at this point - this should be done
212
200
  later, when a new change is made.
213
- * If a major version is released, update the `still` branch, which points to
214
- the "old" major version.
215
201
 
216
202
  Now release it:
217
203
 
@@ -220,17 +206,11 @@ Now release it:
220
206
  bundle update
221
207
 
222
208
  # Run test suite
223
- bin/test
209
+ bundle exec rake
224
210
 
225
211
  # Release gem
226
212
  git commit -m "Version bump"
227
213
  bundle exec rake release
228
-
229
- # If it's a major relase:
230
- # Merge changes back to have correct documentation
231
- git checkout still
232
- git merge master
233
- git push
234
214
  ```
235
215
 
236
216
  Now send a PR to [cucumber/website] adding an article
data/README.md CHANGED
@@ -32,8 +32,7 @@ gem install aruba
32
32
  ### As a user getting started with Aruba
33
33
 
34
34
  Our most current documentation to get started with Aruba as a user can be
35
- found on [Cucumber Jam](https://app.cucumber.pro/projects/aruba).
36
- It is generated from our feature files describing the use of Aruba.
35
+ found in [./features/](https://github.com/cucumber/aruba/tree/master/features/).
37
36
 
38
37
  ### As a user getting started with a ruby testing framework
39
38
 
data/exe/aruba CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH << File.expand_path('../lib', __dir__)
3
+ $LOAD_PATH << File.expand_path("../lib", __dir__)
4
4
 
5
- require 'aruba/cli'
5
+ require "aruba/cli"
6
6
 
7
7
  Aruba::Cli.start
data/lib/aruba.rb CHANGED
@@ -1 +1 @@
1
- require 'aruba/api'
1
+ require "aruba/api"
data/lib/aruba/api.rb CHANGED
@@ -1,19 +1,18 @@
1
- require 'rspec/expectations'
2
- require 'shellwords'
1
+ require "rspec/expectations"
2
+ require "shellwords"
3
3
 
4
- require 'aruba/version'
5
- require 'aruba/extensions/string/strip'
4
+ require "aruba/version"
6
5
 
7
- require 'aruba/platform'
8
- require 'aruba/api/core'
9
- require 'aruba/api/commands'
6
+ require "aruba/platform"
7
+ require "aruba/api/core"
8
+ require "aruba/api/commands"
10
9
 
11
- require 'aruba/api/environment'
12
- require 'aruba/api/filesystem'
13
- require 'aruba/api/text'
14
- require 'aruba/api/bundler'
10
+ require "aruba/api/environment"
11
+ require "aruba/api/filesystem"
12
+ require "aruba/api/text"
13
+ require "aruba/api/bundler"
15
14
 
16
- Aruba.platform.require_matching_files('../matchers/**/*.rb', __FILE__)
15
+ Aruba.platform.require_matching_files("../matchers/**/*.rb", __FILE__)
17
16
 
18
17
  # Aruba
19
18
  module Aruba
@@ -1,4 +1,4 @@
1
- require 'aruba/api/environment'
1
+ require "aruba/api/environment"
2
2
 
3
3
  module Aruba
4
4
  module Api
@@ -7,8 +7,23 @@ module Aruba
7
7
 
8
8
  # Unset variables used by bundler
9
9
  def unset_bundler_env_vars
10
- %w[RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE].each do |key|
11
- delete_environment_variable(key)
10
+ empty_env = with_environment { with_unbundled_env { ENV.to_h } }
11
+ aruba_env = aruba.environment.to_h
12
+ (aruba_env.keys - empty_env.keys).each do |key|
13
+ delete_environment_variable key
14
+ end
15
+ empty_env.each do |k, v|
16
+ set_environment_variable k, v
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def with_unbundled_env(&block)
23
+ if ::Bundler.respond_to?(:with_unbundled_env)
24
+ ::Bundler.with_unbundled_env(&block)
25
+ else
26
+ ::Bundler.with_clean_env(&block)
12
27
  end
13
28
  end
14
29
  end
@@ -1,7 +1,7 @@
1
- require 'pathname'
1
+ require "pathname"
2
2
 
3
- require 'aruba/platform'
4
- require 'aruba/command'
3
+ require "aruba/platform"
4
+ require "aruba/command"
5
5
 
6
6
  # require 'win32/file' if File::ALT_SEPARATOR
7
7
 
@@ -22,7 +22,7 @@ module Aruba
22
22
  def which(program, path = nil)
23
23
  with_environment do
24
24
  # ENV is set within this block
25
- path = ENV['PATH'] if path.nil?
25
+ path = ENV["PATH"] if path.nil?
26
26
 
27
27
  Aruba.platform.which(program, path)
28
28
  end
@@ -35,7 +35,7 @@ module Aruba
35
35
  def pipe_in_file(file_name)
36
36
  file_name = expand_path(file_name)
37
37
 
38
- File.open(file_name, 'r').each_line do |line|
38
+ File.open(file_name, "r").each_line do |line|
39
39
  last_command_started.write(line)
40
40
  end
41
41
  end
@@ -64,7 +64,7 @@ module Aruba
64
64
  # If block is given use it to filter the commands which should be
65
65
  # stoppend.
66
66
  def stop_all_commands(&block)
67
- cmds = if block_given?
67
+ cmds = if block
68
68
  all_commands.select(&block)
69
69
  else
70
70
  all_commands
@@ -81,7 +81,7 @@ module Aruba
81
81
  # If block is given use it to filter the commands which should be
82
82
  # terminated.
83
83
  def terminate_all_commands(&block)
84
- cmds = if block_given?
84
+ cmds = if block
85
85
  all_commands.select(&block)
86
86
  else
87
87
  all_commands
@@ -152,7 +152,7 @@ module Aruba
152
152
 
153
153
  unless command.interactive?
154
154
  raise NotImplementedError,
155
- 'Running interactively is not supported with this process launcher.'
155
+ "Running interactively is not supported with this process launcher."
156
156
  end
157
157
 
158
158
  start_command(command)
@@ -168,16 +168,16 @@ module Aruba
168
168
  # @param [String] cmd
169
169
  # The command to be executed
170
170
  #
171
- # @param [Hash] options
171
+ # @param [Hash] opts
172
172
  # Options for aruba
173
173
  #
174
- # @option options [Boolean] fail_on_error
174
+ # @option opts [Boolean] :fail_on_error
175
175
  # Should aruba fail on error?
176
176
  #
177
- # @option options [Numeric] exit_timeout
177
+ # @option opts [Numeric] :exit_timeout
178
178
  # Timeout for execution
179
179
  #
180
- # @option options [Numeric] io_wait_timeout
180
+ # @option opts [Numeric] :io_wait_timeout
181
181
  # Timeout for IO - STDERR, STDOUT
182
182
  #
183
183
  def run_command_and_stop(cmd, opts = {})
@@ -220,12 +220,11 @@ module Aruba
220
220
 
221
221
  private
222
222
 
223
- # rubocop:disable Metrics/MethodLength
224
223
  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]
224
+ exit_timeout = opts[:exit_timeout] || aruba.config.exit_timeout
225
+ io_wait_timeout = opts[:io_wait_timeout] || aruba.config.io_wait_timeout
226
+ stop_signal = opts[:stop_signal] || aruba.config.stop_signal
227
+ startup_wait_time = opts[:startup_wait_time] || aruba.config.startup_wait_time
229
228
 
230
229
  cmd = replace_variables(cmd)
231
230
 
@@ -233,7 +232,7 @@ module Aruba
233
232
  @commands << cmd
234
233
 
235
234
  environment = aruba.environment
236
- working_directory = expand_path('.')
235
+ working_directory = expand_path(".")
237
236
  event_bus = aruba.event_bus
238
237
 
239
238
  cmd = Aruba.platform.detect_ruby(cmd)
@@ -256,10 +255,8 @@ module Aruba
256
255
  )
257
256
  end
258
257
 
259
- # rubocop:enable Metrics/MethodLength
260
-
261
258
  def start_command(command)
262
- aruba.config.before(:command, self, command)
259
+ aruba.config.run_before_hook(:command, self, command)
263
260
 
264
261
  in_current_directory do
265
262
  command.start
@@ -268,7 +265,7 @@ module Aruba
268
265
  stop_signal = command.stop_signal
269
266
  aruba.announcer.announce(:stop_signal, command.pid, stop_signal) if stop_signal
270
267
 
271
- aruba.config.after(:command, self, command)
268
+ aruba.config.run_after_hook(:command, self, command)
272
269
  end
273
270
  end
274
271
  end
@@ -1,7 +1,7 @@
1
- require 'rspec/expectations'
2
- require 'aruba/runtime'
3
- require 'aruba/errors'
4
- require 'aruba/setup'
1
+ require "rspec/expectations"
2
+ require "aruba/runtime"
3
+ require "aruba/errors"
4
+ require "aruba/setup"
5
5
 
6
6
  # Aruba
7
7
  module Aruba
@@ -15,8 +15,10 @@ module Aruba
15
15
 
16
16
  # Aruba Runtime
17
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!
18
+ # TODO: Check this variable being accessed inconsistently. Should only
19
+ # be using the memo!
20
+ # Renaming this to `aruba` causes 100's of rspec failures. Needs a
21
+ # deeper dive, approach with caution!
20
22
  @_aruba_runtime ||= Runtime.new
21
23
  end
22
24
 
@@ -36,8 +38,8 @@ module Aruba
36
38
  # @yield
37
39
  # The block which should be run in current directory
38
40
  def in_current_directory(&block)
39
- create_directory '.' unless directory?('.')
40
- cd('.', &block)
41
+ create_directory "." unless directory?(".")
42
+ cd(".", &block)
41
43
  end
42
44
 
43
45
  # Switch to directory
@@ -54,26 +56,30 @@ module Aruba
54
56
  # @example Run code in directory
55
57
  # result = cd('some-dir') { Dir.getwd }
56
58
  #
57
- # rubocop:disable Metrics/MethodLength
58
59
  def cd(dir, &block)
59
- if block_given?
60
+ if block
60
61
  begin
61
- fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba.platform.directory? expand_path(dir)
62
+ unless Aruba.platform.directory?(expand_path(dir))
63
+ raise ArgumentError,
64
+ "#{expand_path(dir)} is not a directory or does not exist."
65
+ end
62
66
 
63
- old_directory = expand_path('.')
67
+ old_directory = expand_path(".")
64
68
  aruba.current_directory << dir
65
- new_directory = expand_path('.')
69
+ new_directory = expand_path(".")
66
70
 
67
- aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory, new: new_directory)
71
+ aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory,
72
+ new: new_directory)
68
73
 
69
74
  old_dir = Aruba.platform.getwd
70
75
 
71
- real_new_directory = File.expand_path(aruba.current_directory, aruba.root_directory)
76
+ real_new_directory = File.expand_path(aruba.current_directory,
77
+ aruba.root_directory)
72
78
  Aruba.platform.chdir real_new_directory
73
79
 
74
80
  result = with_environment(
75
- 'OLDPWD' => old_dir,
76
- 'PWD' => real_new_directory,
81
+ "OLDPWD" => old_dir,
82
+ "PWD" => real_new_directory,
77
83
  &block
78
84
  )
79
85
  ensure
@@ -84,17 +90,19 @@ module Aruba
84
90
  return result
85
91
  end
86
92
 
87
- fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba.platform.directory? expand_path(dir)
93
+ unless Aruba.platform.directory?(expand_path(dir))
94
+ raise ArgumentError, "#{expand_path(dir)} is not a directory or does not exist."
95
+ end
88
96
 
89
- old_directory = expand_path('.')
97
+ old_directory = expand_path(".")
90
98
  aruba.current_directory << dir
91
- new_directory = expand_path('.')
99
+ new_directory = expand_path(".")
92
100
 
93
- aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory, new: new_directory)
101
+ aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory,
102
+ new: new_directory)
94
103
 
95
104
  self
96
105
  end
97
- # rubocop:enable Metrics/MethodLength
98
106
 
99
107
  # Expand file name
100
108
  #
@@ -132,48 +140,60 @@ module Aruba
132
140
  # # => /foo/bar
133
141
  # expand_path('/foo/bar')
134
142
  #
135
- # rubocop:disable Metrics/MethodLength
136
- # rubocop:disable Metrics/CyclomaticComplexity
137
- # rubocop:disable Metrics/PerceivedComplexity
138
143
  def expand_path(file_name, dir_string = nil)
139
- # rubocop:disable Layout/LineLength
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.)
141
- # rubocop:enable Layout/LineLength
142
-
143
- fail ArgumentError, message unless file_name.is_a?(String) && !file_name.empty?
144
+ unless file_name.is_a?(String) && !file_name.empty?
145
+ message = "Filename #{file_name} needs to be a string." \
146
+ " It cannot be nil or empty either. "\
147
+ "Please use `expand_path('.')` if you want the current directory to be expanded."
144
148
 
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)
149
+ raise ArgumentError, message
150
+ end
147
151
 
148
- # rubocop:enable Layout/LineLength
152
+ unless Aruba.platform.directory? File.join(aruba.config.root_directory,
153
+ aruba.config.working_directory)
154
+ raise "Aruba's working directory does not exist." \
155
+ " Maybe you forgot to run `setup_aruba` before using its API."
156
+ end
149
157
 
150
158
  prefix = file_name[0]
151
- rest = file_name[2..-1]
152
159
 
153
160
  if aruba.config.fixtures_path_prefix == prefix
161
+ rest = file_name[2..-1]
154
162
  path = File.join(*[aruba.fixtures_directory, rest].compact)
155
-
156
- # rubocop:disable Layout/LineLength
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
158
-
159
- # rubocop:enable Layout/LineLength
163
+ unless Aruba.platform.exist? path
164
+ aruba_fixture_candidates = aruba.config.fixtures_directories
165
+ .map { |p| format('"%s"', p) }.join(", ")
166
+
167
+ raise ArgumentError,
168
+ "Fixture \"#{rest}\" does not exist" \
169
+ " in fixtures directory \"#{aruba.fixtures_directory}\"." \
170
+ " This was the one we found first on your system from all possible" \
171
+ " candidates: #{aruba_fixture_candidates}."
172
+ end
160
173
 
161
174
  path
162
- elsif prefix == '~'
175
+ elsif prefix == "~"
163
176
  path = with_environment do
164
177
  File.expand_path(file_name)
165
178
  end
166
179
 
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
180
+ raise ArgumentError, 'Expanding "~/" to "/" is not allowed' if path == "/"
181
+
182
+ unless Aruba.platform.absolute_path? path
183
+ raise ArgumentError,
184
+ "Expanding \"~\" to a relative path \"#{path}\" is not allowed"
185
+ end
169
186
 
170
187
  path.to_s
171
- elsif absolute? file_name
188
+ elsif absolute?(file_name)
172
189
  unless aruba.config.allow_absolute_paths
173
190
  caller_location = caller_locations(1, 1).first
174
191
  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'
192
+ aruba.logger.warn \
193
+ "Aruba's `expand_path` method was called with an absolute path" \
194
+ " at #{caller_file_line}, which is not recommended." \
195
+ " Change the call to pass a relative path or set "\
196
+ "`config.allow_absolute_paths = true` to silence this warning"
177
197
  end
178
198
  file_name
179
199
  else
@@ -184,9 +204,6 @@ module Aruba
184
204
  end
185
205
  end
186
206
  end
187
- # rubocop:enable Metrics/MethodLength
188
- # rubocop:enable Metrics/CyclomaticComplexity
189
- # rubocop:enable Metrics/PerceivedComplexity
190
207
 
191
208
  # Run block with environment
192
209
  #