aruba 1.0.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +60 -2
  3. data/CONTRIBUTING.md +18 -22
  4. data/README.md +13 -18
  5. data/exe/aruba +2 -2
  6. data/lib/aruba.rb +1 -1
  7. data/lib/aruba/api.rb +11 -11
  8. data/lib/aruba/api/bundler.rb +2 -1
  9. data/lib/aruba/api/commands.rb +7 -7
  10. data/lib/aruba/api/core.rb +33 -29
  11. data/lib/aruba/api/environment.rb +2 -2
  12. data/lib/aruba/api/filesystem.rb +35 -14
  13. data/lib/aruba/api/text.rb +4 -4
  14. data/lib/aruba/aruba_path.rb +2 -2
  15. data/lib/aruba/basic_configuration.rb +11 -11
  16. data/lib/aruba/cli.rb +7 -7
  17. data/lib/aruba/command.rb +4 -4
  18. data/lib/aruba/config/jruby.rb +9 -9
  19. data/lib/aruba/config_wrapper.rb +2 -2
  20. data/lib/aruba/configuration.rb +14 -14
  21. data/lib/aruba/console.rb +11 -11
  22. data/lib/aruba/console/help.rb +5 -5
  23. data/lib/aruba/contracts/absolute_path.rb +1 -1
  24. data/lib/aruba/contracts/enum.rb +1 -1
  25. data/lib/aruba/contracts/is_power_of_two.rb +1 -1
  26. data/lib/aruba/contracts/relative_path.rb +1 -1
  27. data/lib/aruba/cucumber.rb +8 -7
  28. data/lib/aruba/cucumber/command.rb +187 -143
  29. data/lib/aruba/cucumber/environment.rb +7 -7
  30. data/lib/aruba/cucumber/file.rb +7 -3
  31. data/lib/aruba/cucumber/hooks.rb +29 -29
  32. data/lib/aruba/cucumber/parameter_types.rb +1 -0
  33. data/lib/aruba/cucumber/testing_frameworks.rb +18 -18
  34. data/lib/aruba/event_bus.rb +4 -4
  35. data/lib/aruba/event_bus/name_resolver.rb +5 -5
  36. data/lib/aruba/file_size.rb +1 -1
  37. data/lib/aruba/generators/script_file.rb +2 -2
  38. data/lib/aruba/in_config_wrapper.rb +1 -1
  39. data/lib/aruba/initializer.rb +10 -10
  40. data/lib/aruba/matchers/base/base_matcher.rb +1 -1
  41. data/lib/aruba/matchers/base/message_indenter.rb +1 -1
  42. data/lib/aruba/matchers/base/object_formatter.rb +2 -2
  43. data/lib/aruba/matchers/collection.rb +1 -1
  44. data/lib/aruba/matchers/collection/all.rb +1 -1
  45. data/lib/aruba/matchers/collection/include_an_object.rb +2 -2
  46. data/lib/aruba/matchers/command.rb +1 -1
  47. data/lib/aruba/matchers/command/be_successfully_executed.rb +4 -4
  48. data/lib/aruba/matchers/command/have_finished_in_time.rb +1 -1
  49. data/lib/aruba/matchers/command/have_output.rb +1 -1
  50. data/lib/aruba/matchers/directory.rb +1 -1
  51. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +2 -2
  52. data/lib/aruba/matchers/directory/have_sub_directory.rb +3 -3
  53. data/lib/aruba/matchers/environment.rb +1 -1
  54. data/lib/aruba/matchers/file.rb +1 -1
  55. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +1 -1
  56. data/lib/aruba/matchers/file/be_an_existing_executable.rb +2 -2
  57. data/lib/aruba/matchers/file/be_an_existing_file.rb +2 -2
  58. data/lib/aruba/matchers/file/have_file_content.rb +1 -1
  59. data/lib/aruba/matchers/file/have_file_size.rb +1 -1
  60. data/lib/aruba/matchers/file/have_same_file_content.rb +2 -2
  61. data/lib/aruba/matchers/path.rb +1 -1
  62. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +1 -1
  63. data/lib/aruba/matchers/path/be_an_absolute_path.rb +1 -1
  64. data/lib/aruba/matchers/path/be_an_existing_path.rb +1 -1
  65. data/lib/aruba/matchers/path/have_permissions.rb +2 -2
  66. data/lib/aruba/matchers/string.rb +1 -1
  67. data/lib/aruba/matchers/string/include_output_string.rb +1 -1
  68. data/lib/aruba/matchers/string/match_output_string.rb +1 -1
  69. data/lib/aruba/matchers/string/output_string_eq.rb +1 -1
  70. data/lib/aruba/platform.rb +2 -2
  71. data/lib/aruba/platforms/announcer.rb +14 -14
  72. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +1 -1
  73. data/lib/aruba/platforms/aruba_logger.rb +1 -1
  74. data/lib/aruba/platforms/command_monitor.rb +5 -5
  75. data/lib/aruba/platforms/determine_disk_usage.rb +1 -1
  76. data/lib/aruba/platforms/filesystem_status.rb +1 -1
  77. data/lib/aruba/platforms/simple_table.rb +1 -1
  78. data/lib/aruba/platforms/unix_command_string.rb +2 -2
  79. data/lib/aruba/platforms/unix_platform.rb +23 -23
  80. data/lib/aruba/platforms/unix_which.rb +1 -1
  81. data/lib/aruba/platforms/windows_command_string.rb +2 -2
  82. data/lib/aruba/platforms/windows_environment_variables.rb +2 -2
  83. data/lib/aruba/platforms/windows_platform.rb +6 -8
  84. data/lib/aruba/platforms/windows_which.rb +5 -5
  85. data/lib/aruba/processes/basic_process.rb +2 -2
  86. data/lib/aruba/processes/debug_process.rb +5 -5
  87. data/lib/aruba/processes/in_process.rb +7 -7
  88. data/lib/aruba/processes/spawn_process.rb +17 -22
  89. data/lib/aruba/rspec.rb +6 -6
  90. data/lib/aruba/runtime.rb +6 -6
  91. data/lib/aruba/setup.rb +3 -3
  92. data/lib/aruba/version.rb +1 -1
  93. metadata +75 -29
  94. data/lib/aruba/tasks/docker_helpers.rb +0 -156
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26d3e68b36ad2938d35b9f147b8b776b3eb1e25b2e2a271f5346b8b423888964
4
- data.tar.gz: 4a70c60f9ccb254e8c5edb7b9c91cc51274f11912c2c1554df61ed8d96cb3b5f
3
+ metadata.gz: 274e6609a41e03eb74e7fa94a41c6165f5db84e5cff6787c8793afdde8c56cef
4
+ data.tar.gz: 1252caf02a2a758f334ce58e8da97c21015e7477cfb8266695ae7b54b2db6e57
5
5
  SHA512:
6
- metadata.gz: 10d08cceb237bb14cd0c0559163326c3340eba5a7db7275d876f6836ec11323b37e734dff617f727c783b653cbdbf47c333952177b0cea4b2117ea4d8ba4d2a7
7
- data.tar.gz: 9c71d0e7409899b56b36d53c2a4581ea7143093bacd6dd8fbacac60c211512e7bd4118ef69f7f4e8bca651010609079f05c90f746cdb9f2fdcba41ae9e684430
6
+ metadata.gz: afa76ddef7027ba2e46f5db09114a9430b520f970ef03a8fb4989ffd383abece8629f20e3ea0ca657037b9a68b1a7cb8fff383342fced0ea4841a204c6b4389d
7
+ data.tar.gz: c3c7ef6f78b7a67e8a8cb44edd7ca7c72ee5fda00601ceee4eceba5663fb782a575933949b89389242454cef176e6ca89579380943c98a363e76db54fde5ba2c
data/CHANGELOG.md CHANGED
@@ -6,6 +6,36 @@ 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
+ ## [2.0.0] / 2021-07-26
10
+
11
+ Potentially breaking changes:
12
+
13
+ * Bump miminum cucumber version to 4 ([#814] by [mvz])
14
+ * Drop support for Ruby 2.4 ([#820] by [mvz])
15
+ * Remove deprecated ability to append to non-existent file ([#829] by [mvz])
16
+ * Make absolute file name warning an error ([#783] by [mvz])
17
+
18
+ Other changes
19
+
20
+ * Use Ruby's built-in windows platform detection ([#813] by [mvz])
21
+ * Update some step definitions to use Cucumber Expression syntax ([#822] by [mvz])
22
+ * Update cucumber dependency to allow use of cucumber 7 ([#828] by [dependabot])
23
+
24
+ ## [1.1.2] / 2021-06-20
25
+
26
+ * Add Bundler as an explicit runtime dependency ([#810] by [luke-hill])
27
+
28
+ ## [1.1.1] / 2021-05-14
29
+
30
+ * Loosen dependency on the contracts gem ([#804] by [mvz])
31
+
32
+ ## [1.1.0] / 2021-04-14
33
+
34
+ * Add step and API to add whole lines to a file ([#780] by [mvz])
35
+ * Deprecate file creation when using `append_to_file` ([#781] by [mvz])
36
+ * Update dependencies to cucumber to allow working with incoming major versions
37
+ ([#801] by [mattwynne])
38
+
9
39
  ## [1.0.4] / 2021-01-04
10
40
 
11
41
  * Update rubocop and fix new offenses (various pull requests)
@@ -964,6 +994,29 @@ Note: These are changes w.r.t. Aruba version 0.14.1.
964
994
 
965
995
  <!-- issues & pull requests -->
966
996
 
997
+ [#829]: https://github.com/cucumber/aruba/pull/829
998
+ [#828]: https://github.com/cucumber/aruba/pull/828
999
+ [#822]: https://github.com/cucumber/aruba/pull/822
1000
+ [#820]: https://github.com/cucumber/aruba/pull/820
1001
+ [#814]: https://github.com/cucumber/aruba/pull/814
1002
+ [#813]: https://github.com/cucumber/aruba/pull/813
1003
+ [#810]: https://github.com/cucumber/aruba/pull/810
1004
+ [#804]: https://github.com/cucumber/aruba/pull/804
1005
+ [#801]: https://github.com/cucumber/aruba/pull/801
1006
+ [#783]: https://github.com/cucumber/aruba/pull/783
1007
+ [#781]: https://github.com/cucumber/aruba/pull/781
1008
+ [#780]: https://github.com/cucumber/aruba/pull/780
1009
+ [#772]: https://github.com/cucumber/aruba/pull/772
1010
+ [#771]: https://github.com/cucumber/aruba/pull/771
1011
+ [#769]: https://github.com/cucumber/aruba/pull/769
1012
+ [#767]: https://github.com/cucumber/aruba/pull/767
1013
+ [#766]: https://github.com/cucumber/aruba/pull/766
1014
+ [#763]: https://github.com/cucumber/aruba/pull/763
1015
+ [#751]: https://github.com/cucumber/aruba/pull/751
1016
+ [#750]: https://github.com/cucumber/aruba/pull/750
1017
+ [#748]: https://github.com/cucumber/aruba/pull/748
1018
+ [#738]: https://github.com/cucumber/aruba/pull/738
1019
+ [#737]: https://github.com/cucumber/aruba/pull/737
967
1020
  [#727]: https://github.com/cucumber/aruba/pull/727
968
1021
  [#725]: https://github.com/cucumber/aruba/pull/725
969
1022
  [#724]: https://github.com/cucumber/aruba/pull/724
@@ -1242,7 +1295,12 @@ Note: These are changes w.r.t. Aruba version 0.14.1.
1242
1295
 
1243
1296
  <!-- Releases -->
1244
1297
 
1245
- [Unreleased]: https://github.com/cucumber/aruba/compare/v1.0.3...master
1298
+ [Unreleased]: https://github.com/cucumber/aruba/compare/v2.0.0...main
1299
+ [2.0.0]: https://github.com/cucumber/aruba/compare/v1.1.2...v2.0.0
1300
+ [1.1.2]: https://github.com/cucumber/aruba/compare/v1.1.1...v1.1.2
1301
+ [1.1.1]: https://github.com/cucumber/aruba/compare/v1.1.0...v1.1.1
1302
+ [1.1.0]: https://github.com/cucumber/aruba/compare/v1.0.4...v1.1.0
1303
+ [1.0.4]: https://github.com/cucumber/aruba/compare/v1.0.3...v1.0.4
1246
1304
  [1.0.3]: https://github.com/cucumber/aruba/compare/v1.0.2...v1.0.3
1247
1305
  [1.0.2]: https://github.com/cucumber/aruba/compare/v1.0.1...v1.0.2
1248
1306
  [1.0.1]: https://github.com/cucumber/aruba/compare/v1.0.0...v1.0.1
@@ -1346,4 +1404,4 @@ Note: These are changes w.r.t. Aruba version 0.14.1.
1346
1404
 
1347
1405
  [1]: http://semver.org
1348
1406
  [2]: http://keepachangelog.com
1349
- [3]: https://github.com/cucumber/aruba/blob/master/CONTRIBUTING.md
1407
+ [3]: https://github.com/cucumber/aruba/blob/main/CONTRIBUTING.md
data/CONTRIBUTING.md CHANGED
@@ -73,7 +73,7 @@ Please...
73
73
 
74
74
  * Use pull requests for larger or controversial changes made by yourself or
75
75
  changes you might expected to break the build.
76
- * Commit smaller changes directly to master, e.g. fixing typos, adding tests or
76
+ * Commit smaller changes directly to `main`, e.g. fixing typos, adding tests or
77
77
  adding documentation.
78
78
  * Update [`CHANGELOG.md`][] when a pull request is merged.
79
79
  * Make sure all tests are green before merging a pull request.
@@ -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,22 @@ 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]'
144
+ # Run the test suite
145
+ bundle exec rake
146
+ ```
152
147
 
153
- # Run the whole test suite in "docker"-container
154
- RUN_IN_DOCKER=1 bin/test
148
+ If you want to run the test suite against specific versions of Aruba's
149
+ dependencies, you can use [appraisal](https://github.com/thoughtbot/appraisal):
155
150
 
156
- # Run only selected scenario
157
- RUN_IN_DOCKER=1 bin/test cucumber features/steps/command/shell.feature:14
151
+ ```bash
152
+ bundle exec appraisal cucumber_6 bundle install
153
+ bundle exec appraisal cucumber_6 bundle exec rake
158
154
  ```
159
155
 
160
156
  ### Installing your own gems used for development
@@ -218,7 +214,7 @@ Now release it:
218
214
  bundle update
219
215
 
220
216
  # Run test suite
221
- bin/test
217
+ bundle exec rake
222
218
 
223
219
  # Release gem
224
220
  git commit -m "Version bump"
data/README.md CHANGED
@@ -1,11 +1,7 @@
1
- [![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/cucumber/aruba/master/LICENSE)
2
- [![Docs](https://img.shields.io/badge/cucumber.pro-aruba-3d10af.svg)](https://app.cucumber.pro/projects/aruba)
1
+ [![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/cucumber/aruba/main/LICENSE)
3
2
  [![Gem Version](https://badge.fury.io/rb/aruba.svg)](http://badge.fury.io/rb/aruba)
4
- [![Code Climate](https://codeclimate.com/github/cucumber/aruba.svg)](https://codeclimate.com/github/cucumber/aruba)
5
3
  [![Support](https://img.shields.io/badge/cucumber-support-orange.svg)](https://cucumber.io/support)
6
-
7
- [![Travis CI build status](https://travis-ci.org/cucumber/aruba.svg)](https://travis-ci.org/cucumber/aruba)
8
- [![Appveyor build status](https://ci.appveyor.com/api/projects/status/jfo2tkqhnrqqcivl?svg=true)](https://ci.appveyor.com/project/cucumberbdd/aruba)
4
+ [![Build Status](https://github.com/cucumber/aruba/actions/workflows/ruby.yml/badge.svg)](https://github.com/cucumber/aruba/actions/workflows/ruby.yml)
9
5
 
10
6
  ## Install
11
7
 
@@ -32,8 +28,7 @@ gem install aruba
32
28
  ### As a user getting started with Aruba
33
29
 
34
30
  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.
31
+ found in [./features/](https://github.com/cucumber/aruba/tree/main/features/).
37
32
 
38
33
  ### As a user getting started with a ruby testing framework
39
34
 
@@ -58,15 +53,15 @@ A full documentation of the API for developers can be found on
58
53
 
59
54
  ## Support
60
55
 
61
- ### Channels
62
-
63
56
  For support, please have a look at the [support website](https://cucumber.io/support)
64
57
  of Cucumber. You have different options to reach out for help: Recommended for
65
58
  Aruba are using the Slack channels &mdash; e.g. `committers-aruba` or `help-cucumber-ruby`
66
- &mdash; ([register account](https://cucumberbdd-slack-invite.herokuapp.com/)), and the
59
+ &mdash; ([register account](https://cucumberbdd-slack-invite.herokuapp.com/))
60
+
61
+ Concrete issues can be reported via the
67
62
  [Issues page on GitHub](https://github.com/cucumber/aruba/issues).
68
63
 
69
- ### Maintainers
64
+ ## Maintainers
70
65
 
71
66
  Currently, this gem is mainly maintained by this group of people:
72
67
 
@@ -78,8 +73,8 @@ We try to comply with [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.
78
73
 
79
74
  ## Supported Ruby versions
80
75
 
81
- Aruba is supported on Ruby 2.4 and up, and tested against CRuby 2.4, 2.5, 2.6
82
- and 2.7, and JRuby 9.2.
76
+ Aruba is supported on Ruby 2.5 and up, and tested against CRuby 2.5, 2.6 and
77
+ 2.7, and JRuby 9.2.
83
78
 
84
79
  ## Supported operating systems
85
80
 
@@ -92,10 +87,10 @@ Please see the [CONTRIBUTING](CONTRIBUTING.md) file.
92
87
 
93
88
  ## Code branches
94
89
 
95
- Development takes place in the `master` branch and currently targets the 1.x
96
- releases. If necessary, maintenance of the old 0.14.x releases takes place in
97
- the `0-14-stable` branch. Stable branches will not be created until absolutely
98
- necessary.
90
+ Development takes place in the `main` branch and currently targets the 2.x
91
+ releases. If necessary, maintenance of the old 1.1.x releases will take place
92
+ in a `1-1-stable` branch, and of 0.14.x releases in the `0-14-stable` branch.
93
+ Stable branches will not be created until absolutely necessary.
99
94
 
100
95
  ## License
101
96
 
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,18 +1,18 @@
1
- require 'rspec/expectations'
2
- require 'shellwords'
1
+ require "rspec/expectations"
2
+ require "shellwords"
3
3
 
4
- require 'aruba/version'
4
+ require "aruba/version"
5
5
 
6
- require 'aruba/platform'
7
- require 'aruba/api/core'
8
- require 'aruba/api/commands'
6
+ require "aruba/platform"
7
+ require "aruba/api/core"
8
+ require "aruba/api/commands"
9
9
 
10
- require 'aruba/api/environment'
11
- require 'aruba/api/filesystem'
12
- require 'aruba/api/text'
13
- require 'aruba/api/bundler'
10
+ require "aruba/api/environment"
11
+ require "aruba/api/filesystem"
12
+ require "aruba/api/text"
13
+ require "aruba/api/bundler"
14
14
 
15
- Aruba.platform.require_matching_files('../matchers/**/*.rb', __FILE__)
15
+ Aruba.platform.require_matching_files("../matchers/**/*.rb", __FILE__)
16
16
 
17
17
  # Aruba
18
18
  module Aruba
@@ -1,4 +1,5 @@
1
- require 'aruba/api/environment'
1
+ require "aruba/api/environment"
2
+ require "bundler"
2
3
 
3
4
  module Aruba
4
5
  module Api
@@ -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
@@ -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)
@@ -232,7 +232,7 @@ module Aruba
232
232
  @commands << cmd
233
233
 
234
234
  environment = aruba.environment
235
- working_directory = expand_path('.')
235
+ working_directory = expand_path(".")
236
236
  event_bus = aruba.event_bus
237
237
 
238
238
  cmd = Aruba.platform.detect_ruby(cmd)
@@ -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
@@ -38,8 +38,8 @@ module Aruba
38
38
  # @yield
39
39
  # The block which should be run in current directory
40
40
  def in_current_directory(&block)
41
- create_directory '.' unless directory?('.')
42
- cd('.', &block)
41
+ create_directory "." unless directory?(".")
42
+ cd(".", &block)
43
43
  end
44
44
 
45
45
  # Switch to directory
@@ -64,9 +64,9 @@ module Aruba
64
64
  "#{expand_path(dir)} is not a directory or does not exist."
65
65
  end
66
66
 
67
- old_directory = expand_path('.')
67
+ old_directory = expand_path(".")
68
68
  aruba.current_directory << dir
69
- new_directory = expand_path('.')
69
+ new_directory = expand_path(".")
70
70
 
71
71
  aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory,
72
72
  new: new_directory)
@@ -78,8 +78,8 @@ module Aruba
78
78
  Aruba.platform.chdir real_new_directory
79
79
 
80
80
  result = with_environment(
81
- 'OLDPWD' => old_dir,
82
- 'PWD' => real_new_directory,
81
+ "OLDPWD" => old_dir,
82
+ "PWD" => real_new_directory,
83
83
  &block
84
84
  )
85
85
  ensure
@@ -94,9 +94,9 @@ module Aruba
94
94
  raise ArgumentError, "#{expand_path(dir)} is not a directory or does not exist."
95
95
  end
96
96
 
97
- old_directory = expand_path('.')
97
+ old_directory = expand_path(".")
98
98
  aruba.current_directory << dir
99
- new_directory = expand_path('.')
99
+ new_directory = expand_path(".")
100
100
 
101
101
  aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory,
102
102
  new: new_directory)
@@ -117,34 +117,36 @@ module Aruba
117
117
  #
118
118
  # @example Single file name
119
119
  #
120
- # # => <path>/tmp/aruba/file
121
120
  # expand_path('file')
121
+ # # => <path>/tmp/aruba/file
122
122
  #
123
123
  # @example Single Dot
124
124
  #
125
- # # => <path>/tmp/aruba
126
125
  # expand_path('.')
126
+ # # => <path>/tmp/aruba
127
127
  #
128
128
  # @example using home directory
129
129
  #
130
- # # => <path>/home/<name>/file
131
130
  # expand_path('~/file')
131
+ # # => <path>/home/<name>/file
132
132
  #
133
133
  # @example using fixtures directory
134
134
  #
135
- # # => <path>/test/fixtures/file
136
135
  # expand_path('%/file')
136
+ # # => <path>/test/fixtures/file
137
137
  #
138
- # @example Absolute directory
138
+ # @example Absolute directory (requires aruba.config.allow_absolute_paths
139
+ # to be set)
139
140
  #
140
- # # => /foo/bar
141
141
  # expand_path('/foo/bar')
142
+ # # => /foo/bar
142
143
  #
143
144
  def expand_path(file_name, dir_string = nil)
144
145
  unless file_name.is_a?(String) && !file_name.empty?
145
146
  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."
147
+ " It cannot be nil or empty either."\
148
+ " Please use `expand_path('.')` if you want" \
149
+ " the current directory to be expanded."
148
150
 
149
151
  raise ArgumentError, message
150
152
  end
@@ -152,32 +154,32 @@ module Aruba
152
154
  unless Aruba.platform.directory? File.join(aruba.config.root_directory,
153
155
  aruba.config.working_directory)
154
156
  raise "Aruba's working directory does not exist." \
155
- ' Maybe you forgot to run `setup_aruba` before using its API.'
157
+ " Maybe you forgot to run `setup_aruba` before using its API."
156
158
  end
157
159
 
158
160
  prefix = file_name[0]
159
161
 
160
- if aruba.config.fixtures_path_prefix == prefix
162
+ if prefix == aruba.config.fixtures_path_prefix
161
163
  rest = file_name[2..-1]
162
164
  path = File.join(*[aruba.fixtures_directory, rest].compact)
163
165
  unless Aruba.platform.exist? path
164
166
  aruba_fixture_candidates = aruba.config.fixtures_directories
165
- .map { |p| format('"%s"', p) }.join(', ')
167
+ .map { |p| format('"%s"', p) }.join(", ")
166
168
 
167
169
  raise ArgumentError,
168
170
  "Fixture \"#{rest}\" does not exist" \
169
171
  " in fixtures directory \"#{aruba.fixtures_directory}\"." \
170
- ' This was the one we found first on your system from all possible' \
172
+ " This was the one we found first on your system from all possible" \
171
173
  " candidates: #{aruba_fixture_candidates}."
172
174
  end
173
175
 
174
176
  path
175
- elsif prefix == '~'
177
+ elsif prefix == "~"
176
178
  path = with_environment do
177
179
  File.expand_path(file_name)
178
180
  end
179
181
 
180
- raise ArgumentError, 'Expanding "~/" to "/" is not allowed' if path == '/'
182
+ raise ArgumentError, 'Expanding "~/" to "/" is not allowed' if path == "/"
181
183
 
182
184
  unless Aruba.platform.absolute_path? path
183
185
  raise ArgumentError,
@@ -189,11 +191,13 @@ module Aruba
189
191
  unless aruba.config.allow_absolute_paths
190
192
  caller_location = caller_locations(1, 1).first
191
193
  caller_file_line = "#{caller_location.path}:#{caller_location.lineno}"
192
- aruba.logger.warn \
194
+ message =
193
195
  "Aruba's `expand_path` method was called with an absolute path" \
194
196
  " 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'
197
+ " The path passed was '#{file_name}'." \
198
+ " Change the call to pass a relative path or set "\
199
+ "`config.allow_absolute_paths = true` to silence this warning"
200
+ raise UserError, message
197
201
  end
198
202
  file_name
199
203
  else