aruba 1.0.0.pre.alpha.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/.rubocop_todo.yml +29 -25
- data/.simplecov +7 -5
- data/.travis.yml +23 -34
- data/CHANGELOG.md +94 -28
- data/CONTRIBUTING.md +0 -1
- data/Gemfile +3 -6
- data/LICENSE +1 -1
- data/README.md +37 -30
- data/Rakefile +2 -14
- data/appveyor.yml +1 -2
- data/aruba.gemspec +22 -14
- data/cucumber.yml +3 -3
- data/lib/aruba/api/commands.rb +3 -1
- data/lib/aruba/api/core.rb +27 -30
- data/lib/aruba/api/filesystem.rb +12 -29
- data/lib/aruba/aruba_path.rb +24 -95
- data/lib/aruba/config/jruby.rb +1 -1
- data/lib/aruba/config_wrapper.rb +1 -3
- data/lib/aruba/configuration.rb +6 -4
- data/lib/aruba/contracts/absolute_path.rb +2 -2
- data/lib/aruba/contracts/relative_path.rb +2 -2
- data/lib/aruba/event_bus/name_resolver.rb +2 -2
- data/lib/aruba/initializer.rb +5 -1
- data/lib/aruba/matchers/base/message_indenter.rb +1 -1
- data/lib/aruba/matchers/base/object_formatter.rb +0 -2
- data/lib/aruba/platforms/announcer.rb +5 -3
- data/lib/aruba/platforms/determine_disk_usage.rb +56 -19
- data/lib/aruba/platforms/unix_environment_variables.rb +7 -0
- data/lib/aruba/platforms/unix_platform.rb +9 -9
- data/lib/aruba/platforms/windows_command_string.rb +1 -1
- data/lib/aruba/platforms/windows_platform.rb +1 -1
- data/lib/aruba/processes/basic_process.rb +2 -4
- data/lib/aruba/processes/spawn_process.rb +11 -8
- data/lib/aruba/version.rb +1 -1
- metadata +38 -41
- data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
data/CONTRIBUTING.md
CHANGED
@@ -186,7 +186,6 @@ Aruba's Rakefile provides the following linting tasks
|
|
186
186
|
bundle exec rake lint # Run all linters
|
187
187
|
bundle exec rake lint:coding_guidelines # Lint our code with "rubocop"
|
188
188
|
bundle exec rake lint:licenses # Check for relevant licenses in project
|
189
|
-
bundle exec rake lint:travis # Lint our .travis.yml
|
190
189
|
```
|
191
190
|
|
192
191
|
### Building and installing your local Aruba version
|
data/Gemfile
CHANGED
@@ -6,10 +6,7 @@ gemspec
|
|
6
6
|
# Load local Gemfile
|
7
7
|
load File.expand_path('Gemfile.local', __dir__) if File.file? File.expand_path('Gemfile.local', __dir__)
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
gem 'byebug', '~> 11.0'
|
13
|
-
gem 'pry-byebug', '~> 3.4'
|
14
|
-
end
|
9
|
+
unless RUBY_PLATFORM.include?('java')
|
10
|
+
gem 'byebug', '~> 11.0'
|
11
|
+
gem 'pry-byebug', '~> 3.4'
|
15
12
|
end
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2010-
|
1
|
+
Copyright (c) 2010-2020 Aslak Hellesøy, David Chelimsky, Mike Sassak, Jarl Friis, Matt Wynne, Dennis Günnewig and Matijs van Zuijlen
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -1,66 +1,70 @@
|
|
1
|
-
[![
|
1
|
+
[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/cucumber/aruba/master/LICENSE)
|
2
2
|
[![Docs](https://img.shields.io/badge/cucumber.pro-aruba-3d10af.svg)](https://app.cucumber.pro/projects/aruba)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/aruba.svg)](http://badge.fury.io/rb/aruba)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/cucumber/aruba.svg)](https://codeclimate.com/github/cucumber/aruba)
|
5
5
|
[![Support](https://img.shields.io/badge/cucumber-support-orange.svg)](https://cucumber.io/support)
|
6
6
|
|
7
|
-
[![
|
8
|
-
[![
|
9
|
-
|
10
|
-
**This is the [latest](https://github.com/cucumber/aruba/blob/master/README.md) version of our README.md (Branch: "[master](https://github.com/cucumber/aruba/tree/master)"). There is also [the README of the latest released version of "aruba"](https://github.com/cucumber/aruba/blob/still/README.md) (Branch: "[still](https://github.com/cucumber/aruba/tree/still)").**
|
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)
|
11
9
|
|
12
10
|
## Install
|
13
11
|
|
14
12
|
Add this line to your application's `Gemfile`:
|
15
13
|
|
16
|
-
|
14
|
+
```ruby
|
17
15
|
gem 'aruba'
|
18
|
-
|
16
|
+
```
|
19
17
|
|
20
18
|
And then execute:
|
21
19
|
|
22
|
-
|
20
|
+
```bash
|
23
21
|
bundle
|
24
|
-
|
22
|
+
```
|
25
23
|
|
26
24
|
Or install it yourself as:
|
27
25
|
|
28
|
-
|
26
|
+
```bash
|
29
27
|
gem install aruba
|
30
|
-
|
28
|
+
```
|
31
29
|
|
32
30
|
## Usage
|
33
31
|
|
34
|
-
### As a user getting started with
|
32
|
+
### As a user getting started with Aruba
|
35
33
|
|
36
|
-
Our most current documentation to get started with
|
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.
|
37
37
|
|
38
38
|
### As a user getting started with a ruby testing framework
|
39
39
|
|
40
40
|
* **Cucumber**:
|
41
41
|
|
42
|
-
If you're new to the
|
42
|
+
If you're new to the Cucumber ecosystem, it's worth to visit
|
43
43
|
[the project's documentation site](https://cucumber.io/docs). This also includes
|
44
|
-
information about how to write feature files in
|
44
|
+
information about how to write feature files in Gherkin.
|
45
45
|
|
46
46
|
* **RSpec**:
|
47
47
|
|
48
|
-
If you want to use
|
48
|
+
If you want to use Aruba with RSpec and you need some information about how to use RSpec, please visit [their website](http://rspec.info/documentation/).
|
49
49
|
|
50
50
|
* **minitest**:
|
51
51
|
|
52
|
-
The documentation for
|
52
|
+
The documentation for minitest can be found [here](http://docs.seattlerb.org/minitest/).
|
53
53
|
|
54
|
-
### As a developer getting started with
|
54
|
+
### As a developer getting started with Aruba
|
55
55
|
|
56
56
|
A full documentation of the API for developers can be found on
|
57
|
-
[RubyDoc](http://www.rubydoc.info/
|
57
|
+
[RubyDoc](http://www.rubydoc.info/gems/aruba).
|
58
58
|
|
59
59
|
## Support
|
60
60
|
|
61
61
|
### Channels
|
62
62
|
|
63
|
-
For support, please have a look at the [
|
63
|
+
For support, please have a look at the [support website](https://cucumber.io/support)
|
64
|
+
of Cucumber. You have different options to reach out for help: Recommended for
|
65
|
+
Aruba are using the Slack channels — e.g. `committers-aruba` or `help-cucumber-ruby`
|
66
|
+
— ([register account](https://cucumberbdd-slack-invite.herokuapp.com/)), and the
|
67
|
+
[Issues page on GitHub](https://github.com/cucumber/aruba/issues).
|
64
68
|
|
65
69
|
### Maintainers
|
66
70
|
|
@@ -74,7 +78,13 @@ We try to comply with [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.
|
|
74
78
|
|
75
79
|
## Supported Ruby versions
|
76
80
|
|
77
|
-
|
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.
|
83
|
+
|
84
|
+
## Supported operating systems
|
85
|
+
|
86
|
+
Aruba is fully tested in CI on Linux and MacOS. On Windows, only RSpec tests
|
87
|
+
are run, so YMMV. Full Windows support is a work in progress.
|
78
88
|
|
79
89
|
## Contributing
|
80
90
|
|
@@ -82,14 +92,11 @@ Please see the [CONTRIBUTING](CONTRIBUTING.md) file.
|
|
82
92
|
|
83
93
|
## Code branches
|
84
94
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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.
|
89
99
|
|
90
|
-
##
|
100
|
+
## License
|
91
101
|
|
92
|
-
|
93
|
-
| ------ | ------ | ------ |
|
94
|
-
| master | [![Build Status](https://travis-ci.org/cucumber/aruba.svg?branch=master)](https://travis-ci.org/cucumber/aruba) | [![Build status](https://ci.appveyor.com/api/projects/status/jfo2tkqhnrqqcivl/branch/master?svg=true&passingText=master%20windows%20passing&failingText=master%20windows%20failing&pendingText==master%20windows%20pending)](https://ci.appveyor.com/project/cucumberbdd/aruba/branch/master)|
|
95
|
-
| still | [![Build Status](https://travis-ci.org/cucumber/aruba.svg?branch=still)](https://travis-ci.org/cucumber/aruba) | [![Build status](https://ci.appveyor.com/api/projects/status/jfo2tkqhnrqqcivl/branch/still?svg=true&passingText=still%20windows%20passing&failingText=still%20windows%20failing&pendingText=master%20windows%20pending)](https://ci.appveyor.com/project/cucumberbdd/aruba/branch/still)
|
102
|
+
See the file [LICENSE](LICENSE).
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ Bundler.setup
|
|
9
9
|
task default: %w(spec cucumber cucumber:wip lint)
|
10
10
|
|
11
11
|
desc 'Run all linters.'
|
12
|
-
task lint: %w(lint:
|
12
|
+
task lint: %w(lint:coding_guidelines lint:licenses)
|
13
13
|
|
14
14
|
desc 'Run the whole test suite.'
|
15
15
|
task test: %w(spec cucumber cucumber:wip)
|
@@ -31,21 +31,9 @@ end
|
|
31
31
|
RSpec::Core::RakeTask.new
|
32
32
|
|
33
33
|
namespace :lint do
|
34
|
-
desc 'Lint our .travis.yml'
|
35
|
-
task :travis do
|
36
|
-
begin
|
37
|
-
require 'travis/yaml'
|
38
|
-
|
39
|
-
puts 'Linting .travis.yml ... No output is good!'
|
40
|
-
Travis::Yaml.parse! File.read('.travis.yml')
|
41
|
-
rescue LoadError => e
|
42
|
-
$stderr.puts "You ruby is not supported for linting the .travis.yml: #{e.message}"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
34
|
desc 'Lint our code with "rubocop"'
|
47
35
|
task :coding_guidelines do
|
48
|
-
sh 'bundle exec rubocop
|
36
|
+
sh 'bundle exec rubocop'
|
49
37
|
end
|
50
38
|
|
51
39
|
desc 'Check for relevant licenses in project'
|
data/appveyor.yml
CHANGED
@@ -17,14 +17,13 @@ install:
|
|
17
17
|
- gem --version
|
18
18
|
- bundler --version
|
19
19
|
- bundle install
|
20
|
-
- cinst ansicon
|
21
20
|
|
22
21
|
test_script:
|
23
22
|
- bundle exec rake spec --trace
|
24
23
|
|
25
24
|
environment:
|
26
25
|
matrix:
|
27
|
-
- ruby_version: '23'
|
28
26
|
- ruby_version: '24'
|
29
27
|
- ruby_version: '25'
|
30
28
|
- ruby_version: '26'
|
29
|
+
# Note: ruby version 2.7 is not available as of 2019-12-31
|
data/aruba.gemspec
CHANGED
@@ -13,34 +13,42 @@ to make testing commandline applications meaningful, easy and fun.'
|
|
13
13
|
spec.email = 'cukes@googlegroups.com'
|
14
14
|
spec.homepage = 'https://github.com/cucumber/aruba'
|
15
15
|
|
16
|
+
spec.metadata = {
|
17
|
+
'bug_tracker_uri' => 'https://github.com/cucumber/aruba/issues',
|
18
|
+
'changelog_uri' => 'https://www.rubydoc.info/gems/aruba/file/CHANGELOG.md',
|
19
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/aruba',
|
20
|
+
'homepage_uri' => spec.homepage,
|
21
|
+
'source_code_uri' => 'https://github.com/cucumber/aruba'
|
22
|
+
}
|
23
|
+
|
16
24
|
spec.add_runtime_dependency 'childprocess', '~> 3.0'
|
17
|
-
spec.add_runtime_dependency 'contracts', '~> 0.
|
25
|
+
spec.add_runtime_dependency 'contracts', '~> 0.16.0'
|
18
26
|
spec.add_runtime_dependency 'cucumber', ['>= 2.4', '< 4.0']
|
19
27
|
spec.add_runtime_dependency 'ffi', '~> 1.9'
|
20
28
|
spec.add_runtime_dependency 'rspec-expectations', '~> 3.4'
|
21
|
-
spec.add_runtime_dependency 'thor', '~> 0
|
29
|
+
spec.add_runtime_dependency 'thor', '~> 1.0'
|
22
30
|
|
23
31
|
spec.add_development_dependency 'json', '~> 2.1'
|
24
|
-
spec.add_development_dependency 'license_finder', '~>
|
32
|
+
spec.add_development_dependency 'license_finder', '~> 6.0'
|
25
33
|
spec.add_development_dependency 'minitest', '~> 5.10'
|
26
|
-
spec.add_development_dependency 'pry-doc', '~> 1.0
|
27
|
-
spec.add_development_dependency 'rake', '~>
|
34
|
+
spec.add_development_dependency 'pry-doc', '~> 1.0'
|
35
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
28
36
|
spec.add_development_dependency 'rspec', '~> 3.6'
|
29
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
30
|
-
spec.add_development_dependency 'rubocop-performance', '~> 1.
|
31
|
-
spec.add_development_dependency 'simplecov', '~> 0.
|
32
|
-
spec.add_development_dependency 'travis-yaml', '~> 0.2'
|
37
|
+
spec.add_development_dependency 'rubocop', '~> 0.79.0'
|
38
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.5'
|
39
|
+
spec.add_development_dependency 'simplecov', '~> 0.18.0'
|
33
40
|
spec.add_development_dependency 'yard-junk', '~> 0.0.7'
|
34
41
|
|
35
42
|
spec.rubygems_version = '>= 1.6.1'
|
36
|
-
spec.required_ruby_version = '>= 2.
|
43
|
+
spec.required_ruby_version = '>= 2.4'
|
37
44
|
|
38
45
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
39
46
|
f.match(%r{^(test|spec|features)/})
|
40
47
|
end
|
41
48
|
|
42
|
-
spec.executables
|
43
|
-
spec.rdoc_options
|
44
|
-
spec.
|
45
|
-
spec.
|
49
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
50
|
+
spec.rdoc_options = ['--charset', 'UTF-8', '--main', 'README.md']
|
51
|
+
spec.extra_rdoc_files = ['CHANGELOG.md', 'CONTRIBUTING.md', 'README.md', 'LICENSE']
|
52
|
+
spec.bindir = 'exe'
|
53
|
+
spec.require_paths = ['lib']
|
46
54
|
end
|
data/cucumber.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<%
|
2
|
-
std_opts = "--format pretty --color --exclude features/fixtures --require features --tags
|
3
|
-
ignore_opts =
|
2
|
+
std_opts = "--format pretty --color --exclude features/fixtures --require features --tags 'not @unsupported-on'"
|
3
|
+
ignore_opts = "--tags 'not @ignore'"
|
4
4
|
%>
|
5
|
-
default: <%= std_opts %> --tags
|
5
|
+
default: <%= std_opts %> --tags 'not @wip' <%= ignore_opts %>
|
6
6
|
wip: <%= std_opts %> --wip --tags @wip:3 <%= ignore_opts %>
|
data/lib/aruba/api/commands.rb
CHANGED
@@ -261,7 +261,9 @@ module Aruba
|
|
261
261
|
def start_command(command)
|
262
262
|
aruba.config.before(:command, self, command)
|
263
263
|
|
264
|
-
|
264
|
+
in_current_directory do
|
265
|
+
command.start
|
266
|
+
end
|
265
267
|
|
266
268
|
stop_signal = command.stop_signal
|
267
269
|
aruba.announcer.announce(:stop_signal, command.pid, stop_signal) if stop_signal
|
data/lib/aruba/api/core.rb
CHANGED
@@ -58,9 +58,7 @@ module Aruba
|
|
58
58
|
def cd(dir, &block)
|
59
59
|
if block_given?
|
60
60
|
begin
|
61
|
-
unless Aruba.platform.directory? expand_path(dir)
|
62
|
-
fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist."
|
63
|
-
end
|
61
|
+
fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba.platform.directory? expand_path(dir)
|
64
62
|
|
65
63
|
old_directory = expand_path('.')
|
66
64
|
aruba.current_directory << dir
|
@@ -70,11 +68,12 @@ module Aruba
|
|
70
68
|
|
71
69
|
old_dir = Aruba.platform.getwd
|
72
70
|
|
73
|
-
|
71
|
+
real_new_directory = File.expand_path(aruba.current_directory, aruba.root_directory)
|
72
|
+
Aruba.platform.chdir real_new_directory
|
74
73
|
|
75
74
|
result = with_environment(
|
76
75
|
'OLDPWD' => old_dir,
|
77
|
-
'PWD' =>
|
76
|
+
'PWD' => real_new_directory,
|
78
77
|
&block
|
79
78
|
)
|
80
79
|
ensure
|
@@ -85,9 +84,7 @@ module Aruba
|
|
85
84
|
return result
|
86
85
|
end
|
87
86
|
|
88
|
-
unless Aruba.platform.directory? expand_path(dir)
|
89
|
-
fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist."
|
90
|
-
end
|
87
|
+
fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba.platform.directory? expand_path(dir)
|
91
88
|
|
92
89
|
old_directory = expand_path('.')
|
93
90
|
aruba.current_directory << dir
|
@@ -139,16 +136,16 @@ module Aruba
|
|
139
136
|
# rubocop:disable Metrics/CyclomaticComplexity
|
140
137
|
# rubocop:disable Metrics/PerceivedComplexity
|
141
138
|
def expand_path(file_name, dir_string = nil)
|
142
|
-
# rubocop:disable
|
139
|
+
# rubocop:disable Layout/LineLength
|
143
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.)
|
144
|
-
# rubocop:enable
|
141
|
+
# rubocop:enable Layout/LineLength
|
145
142
|
|
146
143
|
fail ArgumentError, message unless file_name.is_a?(String) && !file_name.empty?
|
147
144
|
|
148
|
-
# rubocop:disable
|
145
|
+
# rubocop:disable Layout/LineLength
|
149
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)
|
150
147
|
|
151
|
-
# rubocop:enable
|
148
|
+
# rubocop:enable Layout/LineLength
|
152
149
|
|
153
150
|
prefix = file_name[0]
|
154
151
|
rest = file_name[2..-1]
|
@@ -156,31 +153,35 @@ module Aruba
|
|
156
153
|
if aruba.config.fixtures_path_prefix == prefix
|
157
154
|
path = File.join(*[aruba.fixtures_directory, rest].compact)
|
158
155
|
|
159
|
-
# rubocop:disable
|
156
|
+
# rubocop:disable Layout/LineLength
|
160
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
|
161
158
|
|
162
|
-
# rubocop:enable
|
159
|
+
# rubocop:enable Layout/LineLength
|
163
160
|
|
164
161
|
path
|
165
162
|
elsif prefix == '~'
|
166
163
|
path = with_environment do
|
167
|
-
|
164
|
+
File.expand_path(file_name)
|
168
165
|
end
|
169
166
|
|
170
|
-
fail ArgumentError, 'Expanding "~/" to "/" is not allowed' if path
|
171
|
-
fail ArgumentError, %(Expanding "~/" to a relative path "#{path}" is not allowed) unless
|
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
|
172
169
|
|
173
170
|
path.to_s
|
174
171
|
elsif absolute? file_name
|
175
172
|
unless aruba.config.allow_absolute_paths
|
176
|
-
|
177
|
-
|
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'
|
178
177
|
end
|
179
178
|
file_name
|
180
179
|
else
|
181
|
-
|
182
|
-
|
183
|
-
|
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
|
184
185
|
end
|
185
186
|
end
|
186
187
|
# rubocop:enable Metrics/MethodLength
|
@@ -195,14 +196,10 @@ module Aruba
|
|
195
196
|
# @yield
|
196
197
|
# The block of code which should be run with the changed environment variables
|
197
198
|
def with_environment(env = {}, &block)
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
ensure
|
203
|
-
# make sure the old environment is really restored in "aruba.environment"
|
204
|
-
aruba.environment.clear
|
205
|
-
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
|
206
203
|
end
|
207
204
|
end
|
208
205
|
end
|
data/lib/aruba/api/filesystem.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'pathname'
|
2
2
|
|
3
|
+
require 'aruba/platform'
|
3
4
|
require 'aruba/extensions/string/strip'
|
4
5
|
|
5
|
-
require 'aruba/aruba_path'
|
6
|
-
|
7
6
|
Aruba.platform.require_matching_files('../matchers/file/*.rb', __FILE__)
|
8
7
|
Aruba.platform.require_matching_files('../matchers/directory/*.rb', __FILE__)
|
9
8
|
Aruba.platform.require_matching_files('../matchers/path/*.rb', __FILE__)
|
@@ -54,14 +53,14 @@ module Aruba
|
|
54
53
|
#
|
55
54
|
# @return [Boolean]
|
56
55
|
def absolute?(path)
|
57
|
-
|
56
|
+
Aruba.platform.absolute_path?(path)
|
58
57
|
end
|
59
58
|
|
60
59
|
# Check if path is relative
|
61
60
|
#
|
62
61
|
# @return [Boolean]
|
63
62
|
def relative?(path)
|
64
|
-
|
63
|
+
Aruba.platform.relative_path?(path)
|
65
64
|
end
|
66
65
|
|
67
66
|
# Return all existing paths (directories, files) in current dir
|
@@ -104,14 +103,12 @@ module Aruba
|
|
104
103
|
# The content of directory
|
105
104
|
def list(name)
|
106
105
|
fail ArgumentError, %(Path "#{name}" does not exist.) unless exist? name
|
107
|
-
unless directory? name
|
108
|
-
fail ArgumentError, %(Only directories are supported. Path "#{name}" is not a directory.)
|
109
|
-
end
|
106
|
+
fail ArgumentError, %(Only directories are supported. Path "#{name}" is not a directory.) unless directory? name
|
110
107
|
|
111
108
|
existing_files = Dir.glob(expand_path(File.join(name, '**', '*')))
|
112
|
-
current_working_directory =
|
109
|
+
current_working_directory = Pathname.new(expand_path('.'))
|
113
110
|
|
114
|
-
existing_files.map { |d|
|
111
|
+
existing_files.map { |d| Pathname.new(d).relative_path_from(current_working_directory).to_s }
|
115
112
|
end
|
116
113
|
|
117
114
|
# Return content of file
|
@@ -226,9 +223,7 @@ module Aruba
|
|
226
223
|
source = args
|
227
224
|
|
228
225
|
source.each do |s|
|
229
|
-
if s.start_with? aruba.config.fixtures_path_prefix
|
230
|
-
raise ArgumentError, "Using a fixture as source (#{source}) is not supported"
|
231
|
-
end
|
226
|
+
raise ArgumentError, "Using a fixture as source (#{source}) is not supported" if s.start_with? aruba.config.fixtures_path_prefix
|
232
227
|
end
|
233
228
|
|
234
229
|
if destination.start_with? aruba.config.fixtures_path_prefix
|
@@ -386,23 +381,11 @@ module Aruba
|
|
386
381
|
# @return [FileSize]
|
387
382
|
# Bytes on disk
|
388
383
|
def disk_usage(*paths)
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
# TODO: change the API so that you could set something like
|
393
|
-
# aruba.config.fs_allocation_unit_size directly
|
394
|
-
|
395
|
-
typical_fs_unit = 4096 # very typical, except for giant or embedded filesystems
|
396
|
-
typical_dev_bsize = 512 # google dev_bsize for more info
|
397
|
-
|
398
|
-
block_multiplier = typical_fs_unit / typical_dev_bsize
|
399
|
-
fs_unit_size = aruba.config.physical_block_size * block_multiplier
|
384
|
+
paths = paths.flatten
|
385
|
+
expect(paths).to Aruba::Matchers.all be_an_existing_path
|
386
|
+
expanded = paths.map { |path| expand_path(path) }
|
400
387
|
|
401
|
-
|
402
|
-
# what the disk usage of a file is (even if Aruba.config needs to be
|
403
|
-
# read)
|
404
|
-
deprecated_block_count = fs_unit_size / block_multiplier
|
405
|
-
Aruba.platform.determine_disk_usage(expanded, deprecated_block_count)
|
388
|
+
Aruba.platform.determine_disk_usage(expanded)
|
406
389
|
end
|
407
390
|
|
408
391
|
# Get size of file
|