aruba 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +29 -8
  3. data/.rubocop_todo.yml +100 -146
  4. data/CHANGELOG.md +23 -1
  5. data/CONTRIBUTING.md +0 -8
  6. data/Gemfile +3 -1
  7. data/Rakefile +6 -4
  8. data/appveyor.yml +0 -1
  9. data/aruba.gemspec +7 -4
  10. data/fixtures/cli-app/cli-app.gemspec +3 -2
  11. data/fixtures/cli-app/spec/spec_helper.rb +2 -1
  12. data/fixtures/empty-app/cli-app.gemspec +3 -2
  13. data/lib/aruba/api/bundler.rb +1 -1
  14. data/lib/aruba/api/commands.rb +8 -11
  15. data/lib/aruba/api/core.rb +48 -33
  16. data/lib/aruba/api/environment.rb +12 -4
  17. data/lib/aruba/api/filesystem.rb +27 -23
  18. data/lib/aruba/api/text.rb +15 -3
  19. data/lib/aruba/basic_configuration.rb +5 -6
  20. data/lib/aruba/basic_configuration/option.rb +2 -2
  21. data/lib/aruba/cli.rb +4 -1
  22. data/lib/aruba/config_wrapper.rb +17 -2
  23. data/lib/aruba/configuration.rb +27 -12
  24. data/lib/aruba/console.rb +0 -2
  25. data/lib/aruba/console/help.rb +5 -2
  26. data/lib/aruba/contracts/absolute_path.rb +1 -1
  27. data/lib/aruba/contracts/is_power_of_two.rb +2 -2
  28. data/lib/aruba/contracts/relative_path.rb +1 -1
  29. data/lib/aruba/cucumber/command.rb +83 -64
  30. data/lib/aruba/cucumber/file.rb +42 -22
  31. data/lib/aruba/cucumber/hooks.rb +4 -1
  32. data/lib/aruba/cucumber/testing_frameworks.rb +14 -12
  33. data/lib/aruba/event_bus.rb +4 -2
  34. data/lib/aruba/event_bus/name_resolver.rb +9 -8
  35. data/lib/aruba/events.rb +2 -1
  36. data/lib/aruba/hooks.rb +2 -4
  37. data/lib/aruba/in_config_wrapper.rb +8 -5
  38. data/lib/aruba/initializer.rb +5 -3
  39. data/lib/aruba/matchers/base/base_matcher.rb +2 -11
  40. data/lib/aruba/matchers/base/object_formatter.rb +0 -3
  41. data/lib/aruba/matchers/collection/include_an_object.rb +4 -4
  42. data/lib/aruba/matchers/command/be_successfully_executed.rb +3 -1
  43. data/lib/aruba/matchers/command/have_exit_status.rb +3 -1
  44. data/lib/aruba/matchers/command/have_finished_in_time.rb +3 -1
  45. data/lib/aruba/matchers/command/have_output.rb +3 -1
  46. data/lib/aruba/matchers/command/have_output_on_stderr.rb +3 -1
  47. data/lib/aruba/matchers/command/have_output_on_stdout.rb +3 -1
  48. data/lib/aruba/matchers/directory/have_sub_directory.rb +8 -3
  49. data/lib/aruba/matchers/file/have_file_size.rb +4 -2
  50. data/lib/aruba/matchers/path/have_permissions.rb +4 -2
  51. data/lib/aruba/platforms/announcer.rb +18 -6
  52. data/lib/aruba/platforms/aruba_file_creator.rb +3 -1
  53. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +7 -2
  54. data/lib/aruba/platforms/command_monitor.rb +3 -3
  55. data/lib/aruba/platforms/unix_environment_variables.rb +2 -4
  56. data/lib/aruba/platforms/unix_which.rb +1 -1
  57. data/lib/aruba/platforms/windows_environment_variables.rb +2 -1
  58. data/lib/aruba/platforms/windows_which.rb +6 -2
  59. data/lib/aruba/processes/debug_process.rb +4 -2
  60. data/lib/aruba/processes/in_process.rb +4 -2
  61. data/lib/aruba/processes/spawn_process.rb +18 -10
  62. data/lib/aruba/rspec.rb +25 -15
  63. data/lib/aruba/runtime.rb +11 -4
  64. data/lib/aruba/setup.rb +23 -10
  65. data/lib/aruba/tasks/docker_helpers.rb +3 -1
  66. data/lib/aruba/version.rb +1 -1
  67. metadata +22 -8
@@ -210,8 +210,6 @@ bundle exec rake install:local
210
210
  entries for all fixes.
211
211
  * No need to add a [`CHANGELOG.md`] header at this point - this should be done
212
212
  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
213
 
216
214
  Now release it:
217
215
 
@@ -225,12 +223,6 @@ bin/test
225
223
  # Release gem
226
224
  git commit -m "Version bump"
227
225
  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
226
  ```
235
227
 
236
228
  Now send a PR to [cucumber/website] adding an article
data/Gemfile CHANGED
@@ -4,7 +4,9 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  # Load local Gemfile
7
- load File.expand_path('Gemfile.local', __dir__) if File.file? File.expand_path('Gemfile.local', __dir__)
7
+ if File.file? File.expand_path('Gemfile.local', __dir__)
8
+ load File.expand_path('Gemfile.local', __dir__)
9
+ end
8
10
 
9
11
  unless RUBY_PLATFORM.include?('java')
10
12
  gem 'byebug', '~> 11.0'
data/Rakefile CHANGED
@@ -18,13 +18,13 @@ require 'cucumber/rake/task'
18
18
  require 'rspec/core/rake_task'
19
19
 
20
20
  Cucumber::Rake::Task.new do |t|
21
- t.cucumber_opts = %w{--format progress}
21
+ t.cucumber_opts = %w(--format progress)
22
22
  end
23
23
 
24
24
  Cucumber::Rake::Task.new('cucumber:wip', 'Run Cucumber features '\
25
25
  'which are "WORK IN PROGRESS" and '\
26
26
  'are allowed to fail') do |t|
27
- t.cucumber_opts = %w{--format progress}
27
+ t.cucumber_opts = %w(--format progress)
28
28
  t.profile = 'wip'
29
29
  end
30
30
 
@@ -53,7 +53,8 @@ namespace :docker do
53
53
  args.with_defaults(version: 'latest')
54
54
  args.with_defaults(cache: true)
55
55
 
56
- docker_compose_file = Aruba::DockerComposeFile.new(File.expand_path('docker-compose.yml', __dir__))
56
+ docker_compose_file =
57
+ Aruba::DockerComposeFile.new(File.expand_path('docker-compose.yml', __dir__))
57
58
  docker_run_instance = Aruba::DockerRunInstance.new(docker_compose_file, :base)
58
59
 
59
60
  builder = Aruba::DockerBuildCommandLineBuilder.new(
@@ -67,7 +68,8 @@ namespace :docker do
67
68
 
68
69
  desc 'Run docker container'
69
70
  task :run, :command do |_, args|
70
- docker_compose_file = Aruba::DockerComposeFile.new(File.expand_path('docker-compose.yml', __dir__))
71
+ docker_compose_file =
72
+ Aruba::DockerComposeFile.new(File.expand_path('docker-compose.yml', __dir__))
71
73
  docker_run_instance = Aruba::DockerRunInstance.new(docker_compose_file, :base)
72
74
 
73
75
  builder = Aruba::DockerRunCommandLineBuilder.new(
@@ -6,7 +6,6 @@ version: "{build}"
6
6
  branches:
7
7
  only:
8
8
  - master
9
- - still
10
9
 
11
10
  # Disable normal Windows builds in favor of our test script.
12
11
  build: off
@@ -6,8 +6,10 @@ Gem::Specification.new do |spec|
6
6
  spec.name = 'aruba'
7
7
  spec.version = Aruba::VERSION
8
8
  spec.author = 'Aslak Hellesøy, Matt Wynne and other Aruba Contributors'
9
- spec.description = 'Extension for popular TDD and BDD frameworks like "Cucumber", "RSpec" and "Minitest",
10
- to make testing commandline applications meaningful, easy and fun.'
9
+ spec.description = <<~TEXT
10
+ Extension for popular TDD and BDD frameworks like "Cucumber", "RSpec" and "Minitest",
11
+ to make testing commandline applications meaningful, easy and fun.
12
+ TEXT
11
13
  spec.summary = "aruba-#{spec.version}"
12
14
  spec.license = 'MIT'
13
15
  spec.email = 'cukes@googlegroups.com'
@@ -23,7 +25,7 @@ to make testing commandline applications meaningful, easy and fun.'
23
25
 
24
26
  spec.add_runtime_dependency 'childprocess', '~> 3.0'
25
27
  spec.add_runtime_dependency 'contracts', '~> 0.16.0'
26
- spec.add_runtime_dependency 'cucumber', ['>= 2.4', '< 4.0']
28
+ spec.add_runtime_dependency 'cucumber', ['>= 2.4', '< 5.0']
27
29
  spec.add_runtime_dependency 'ffi', '~> 1.9'
28
30
  spec.add_runtime_dependency 'rspec-expectations', '~> 3.4'
29
31
  spec.add_runtime_dependency 'thor', '~> 1.0'
@@ -34,8 +36,9 @@ to make testing commandline applications meaningful, easy and fun.'
34
36
  spec.add_development_dependency 'pry-doc', '~> 1.0'
35
37
  spec.add_development_dependency 'rake', '~> 13.0'
36
38
  spec.add_development_dependency 'rspec', '~> 3.6'
37
- spec.add_development_dependency 'rubocop', '~> 0.79.0'
39
+ spec.add_development_dependency 'rubocop', '~> 0.84.0'
38
40
  spec.add_development_dependency 'rubocop-performance', '~> 1.5'
41
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.39'
39
42
  spec.add_development_dependency 'simplecov', '~> 0.18.0'
40
43
  spec.add_development_dependency 'yard-junk', '~> 0.0.7'
41
44
 
@@ -15,11 +15,12 @@ Gem::Specification.new do |spec|
15
15
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
16
16
  # delete this section to allow pushing this gem to any host.
17
17
 
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
19
20
  spec.bindir = 'exe'
20
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
22
  spec.require_paths = ['lib']
22
23
 
23
24
  spec.add_development_dependency 'bundler', '~> 1.9'
24
- spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rake', '~> 13.0'
25
26
  end
@@ -4,4 +4,5 @@ require 'cli/app'
4
4
 
5
5
  require_relative 'support/aruba'
6
6
 
7
- ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
7
+ ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__))
8
+ .each { |f| require_relative f }
@@ -15,11 +15,12 @@ Gem::Specification.new do |spec|
15
15
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
16
16
  # delete this section to allow pushing this gem to any host.
17
17
 
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
19
20
  spec.bindir = 'exe'
20
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
22
  spec.require_paths = ['lib']
22
23
 
23
24
  spec.add_development_dependency 'bundler', '~> 1.9'
24
- spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rake', '~> 13.0'
25
26
  end
@@ -7,7 +7,7 @@ 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|
10
+ %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE).each do |key|
11
11
  delete_environment_variable(key)
12
12
  end
13
13
  end
@@ -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
 
@@ -256,8 +255,6 @@ module Aruba
256
255
  )
257
256
  end
258
257
 
259
- # rubocop:enable Metrics/MethodLength
260
-
261
258
  def start_command(command)
262
259
  aruba.config.before(:command, self, command)
263
260
 
@@ -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
 
@@ -54,21 +56,25 @@ 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
60
  if block_given?
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
67
  old_directory = expand_path('.')
64
68
  aruba.current_directory << dir
65
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(
@@ -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
97
  old_directory = expand_path('.')
90
98
  aruba.current_directory << dir
91
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,31 +140,34 @@ 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
+ message = "Filename #{file_name} needs to be a string." \
145
+ ' It cannot be nil or empty either. '\
146
+ "Please use `expand_path('.')` if you want the current directory to be expanded."
144
147
 
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)
148
+ raise ArgumentError, message unless file_name.is_a?(String) && !file_name.empty?
147
149
 
148
- # rubocop:enable Layout/LineLength
150
+ unless Aruba.platform.directory? File.join(aruba.config.root_directory,
151
+ aruba.config.working_directory)
152
+ raise "Aruba's working directory does not exist." \
153
+ ' Maybe you forgot to run `setup_aruba` before using its API.'
154
+ end
149
155
 
150
156
  prefix = file_name[0]
151
157
  rest = file_name[2..-1]
152
158
 
153
159
  if aruba.config.fixtures_path_prefix == prefix
154
160
  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
161
+ unless Aruba.platform.exist? path
162
+ aruba_fixture_candidates = aruba.config.fixtures_directories
163
+ .map { |p| format('"%s"', p) }.join(', ')
164
+
165
+ raise ArgumentError,
166
+ "Fixture \"#{rest}\" does not exist" \
167
+ " in fixtures directory \"#{aruba.fixtures_directory}\"." \
168
+ ' This was the one we found first on your system from all possible' \
169
+ " candidates: #{aruba_fixture_candidates}."
170
+ end
160
171
 
161
172
  path
162
173
  elsif prefix == '~'
@@ -164,16 +175,23 @@ module Aruba
164
175
  File.expand_path(file_name)
165
176
  end
166
177
 
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
178
+ raise ArgumentError, 'Expanding "~/" to "/" is not allowed' if path == '/'
179
+
180
+ unless Aruba.platform.absolute_path? path
181
+ raise ArgumentError,
182
+ "Expanding \"~\" to a relative path \"#{path}\" is not allowed"
183
+ end
169
184
 
170
185
  path.to_s
171
- elsif absolute? file_name
186
+ elsif absolute?(file_name)
172
187
  unless aruba.config.allow_absolute_paths
173
188
  caller_location = caller_locations(1, 1).first
174
189
  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'
190
+ aruba.logger.warn \
191
+ "Aruba's `expand_path` method was called with an absolute path" \
192
+ " at #{caller_file_line}, which is not recommended." \
193
+ ' Change the call to pass a relative path or set '\
194
+ '`config.allow_absolute_paths = true` to silence this warning'
177
195
  end
178
196
  file_name
179
197
  else
@@ -184,9 +202,6 @@ module Aruba
184
202
  end
185
203
  end
186
204
  end
187
- # rubocop:enable Metrics/MethodLength
188
- # rubocop:enable Metrics/CyclomaticComplexity
189
- # rubocop:enable Metrics/PerceivedComplexity
190
205
 
191
206
  # Run block with environment
192
207
  #
@@ -23,7 +23,9 @@ module Aruba
23
23
  aruba.environment[name] = value
24
24
  new_environment = aruba.environment.to_h
25
25
 
26
- environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: value } }
26
+ environment_change = { old: old_environment,
27
+ new: new_environment,
28
+ changed: { name: name, value: value } }
27
29
  aruba.event_bus.notify Events::AddedEnvironmentVariable.new(environment_change)
28
30
 
29
31
  self
@@ -46,7 +48,9 @@ module Aruba
46
48
  aruba.environment.append name, value
47
49
  new_environment = aruba.environment.to_h
48
50
 
49
- environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: value } }
51
+ environment_change = { old: old_environment,
52
+ new: new_environment,
53
+ changed: { name: name, value: value } }
50
54
  aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(environment_change)
51
55
 
52
56
  self
@@ -69,7 +73,9 @@ module Aruba
69
73
  aruba.environment.prepend name, value
70
74
  new_environment = aruba.environment.to_h
71
75
 
72
- environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: value } }
76
+ environment_change = { old: old_environment,
77
+ new: new_environment,
78
+ changed: { name: name, value: value } }
73
79
  aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(environment_change)
74
80
 
75
81
  self
@@ -88,7 +94,9 @@ module Aruba
88
94
  aruba.environment.delete name
89
95
  new_environment = aruba.environment.to_h
90
96
 
91
- environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: '' } }
97
+ environment_change = { old: old_environment,
98
+ new: new_environment,
99
+ changed: { name: name, value: '' } }
92
100
  aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(environment_change)
93
101
 
94
102
  self
@@ -92,7 +92,7 @@ module Aruba
92
92
  # @return [Dir]
93
93
  # The directory object
94
94
  def directory(path)
95
- fail ArgumentError, %(Path "#{name}" does not exist.) unless exist? name
95
+ raise ArgumentError, %(Path "#{name}" does not exist.) unless exist? name
96
96
 
97
97
  Dir.new(expand_path(path))
98
98
  end
@@ -102,22 +102,31 @@ module Aruba
102
102
  # @return [Array]
103
103
  # The content of directory
104
104
  def list(name)
105
- fail ArgumentError, %(Path "#{name}" does not exist.) unless exist? name
106
- fail ArgumentError, %(Only directories are supported. Path "#{name}" is not a directory.) unless directory? name
105
+ raise ArgumentError, %(Path "#{name}" does not exist.) unless exist? name
106
+
107
+ unless directory? name
108
+ raise ArgumentError,
109
+ %(Only directories are supported. Path "#{name}" is not a directory.)
110
+ end
107
111
 
108
112
  existing_files = Dir.glob(expand_path(File.join(name, '**', '*')))
109
113
  current_working_directory = Pathname.new(expand_path('.'))
110
114
 
111
- existing_files.map { |d| Pathname.new(d).relative_path_from(current_working_directory).to_s }
115
+ existing_files.map do |d|
116
+ Pathname.new(d).relative_path_from(current_working_directory).to_s
117
+ end
112
118
  end
113
119
 
114
120
  # Return content of file
115
121
  #
116
122
  # @return [Array]
117
- # The content of file, without "\n" or "\r\n" at the end. To rebuild the file use `content.join("\n")`
123
+ # The content of file, without "\n" or "\r\n" at the end.
124
+ # To rebuild the file use `content.join("\n")`
118
125
  def read(name)
119
- fail ArgumentError, %(Path "#{name}" does not exist.) unless exist? name
120
- fail ArgumentError, %(Only files are supported. Path "#{name}" is not a file.) unless file? name
126
+ raise ArgumentError, %(Path "#{name}" does not exist.) unless exist? name
127
+ unless file? name
128
+ raise ArgumentError, %(Only files are supported. Path "#{name}" is not a file.)
129
+ end
121
130
 
122
131
  File.readlines(expand_path(name)).map(&:chomp)
123
132
  end
@@ -145,7 +154,7 @@ module Aruba
145
154
  def touch(*args)
146
155
  args = args.flatten
147
156
 
148
- options = if args.last.kind_of? Hash
157
+ options = if args.last.is_a? Hash
149
158
  args.pop
150
159
  else
151
160
  {}
@@ -168,9 +177,6 @@ module Aruba
168
177
  # @param [String] destination
169
178
  # A file or directory name. If multiple sources are given the destination
170
179
  # needs to be a directory
171
- #
172
- # rubocop:disable Metrics/CyclomaticComplexity
173
- # def copy(*source, destination)
174
180
  def copy(*args)
175
181
  args = args.flatten
176
182
  destination = args.pop
@@ -181,7 +187,8 @@ module Aruba
181
187
  end
182
188
 
183
189
  if destination.start_with? aruba.config.fixtures_path_prefix
184
- raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported"
190
+ raise ArgumentError,
191
+ "Using a fixture as destination (#{destination}) is not supported"
185
192
  end
186
193
 
187
194
  if source.count > 1 && exist?(destination) && !directory?(destination)
@@ -202,7 +209,6 @@ module Aruba
202
209
 
203
210
  self
204
211
  end
205
- # rubocop:enable Metrics/CyclomaticComplexity
206
212
 
207
213
  # Move a file and/or directory
208
214
  #
@@ -214,20 +220,20 @@ module Aruba
214
220
  # @param [String] destination
215
221
  # A file or directory name. If multiple sources are given the destination
216
222
  # needs to be a directory
217
- #
218
- # rubocop:disable Metrics/CyclomaticComplexity
219
- # rubocop:disable Metrics/MethodLength
220
223
  def move(*args)
221
224
  args = args.flatten
222
225
  destination = args.pop
223
226
  source = args
224
227
 
225
228
  source.each do |s|
226
- raise ArgumentError, "Using a fixture as source (#{source}) is not supported" if s.start_with? aruba.config.fixtures_path_prefix
229
+ if s.start_with? aruba.config.fixtures_path_prefix
230
+ raise ArgumentError, "Using a fixture as source (#{source}) is not supported"
231
+ end
227
232
  end
228
233
 
229
234
  if destination.start_with? aruba.config.fixtures_path_prefix
230
- raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported"
235
+ raise ArgumentError,
236
+ "Using a fixture as destination (#{destination}) is not supported"
231
237
  end
232
238
 
233
239
  source.each do |s|
@@ -252,8 +258,6 @@ module Aruba
252
258
 
253
259
  self
254
260
  end
255
- # rubocop:enable Metrics/MethodLength
256
- # rubocop:enable Metrics/CyclomaticComplexity
257
261
 
258
262
  # Create a file with the given size
259
263
  #
@@ -292,14 +296,14 @@ module Aruba
292
296
  def chmod(*args)
293
297
  args = args.flatten
294
298
 
295
- options = if args.last.kind_of? Hash
299
+ options = if args.last.is_a? Hash
296
300
  args.pop
297
301
  else
298
302
  {}
299
303
  end
300
304
 
301
305
  mode = args.shift
302
- mode = if mode.kind_of? String
306
+ mode = if mode.is_a? String
303
307
  mode.to_i(8)
304
308
  else
305
309
  mode
@@ -344,7 +348,7 @@ module Aruba
344
348
  def remove(*args)
345
349
  args = args.flatten
346
350
 
347
- options = if args.last.kind_of? Hash
351
+ options = if args.last.is_a? Hash
348
352
  args.pop
349
353
  else
350
354
  {}