aruba 2.4.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +87 -7
  3. data/CONTRIBUTING.md +55 -33
  4. data/README.md +11 -9
  5. data/lib/aruba/api/bundler.rb +1 -5
  6. data/lib/aruba/api/commands.rb +29 -40
  7. data/lib/aruba/api/core.rb +2 -13
  8. data/lib/aruba/api/filesystem.rb +24 -44
  9. data/lib/aruba/api/text.rb +5 -2
  10. data/lib/aruba/aruba_logger.rb +3 -6
  11. data/lib/aruba/basic_configuration/option.rb +1 -7
  12. data/lib/aruba/basic_configuration.rb +7 -13
  13. data/lib/aruba/cli.rb +0 -6
  14. data/lib/aruba/command.rb +16 -16
  15. data/lib/aruba/command_monitor.rb +2 -4
  16. data/lib/aruba/configuration.rb +32 -20
  17. data/lib/aruba/cucumber/command.rb +32 -119
  18. data/lib/aruba/cucumber/environment.rb +0 -4
  19. data/lib/aruba/cucumber/file.rb +10 -10
  20. data/lib/aruba/cucumber/hooks.rb +12 -15
  21. data/lib/aruba/cucumber.rb +0 -1
  22. data/lib/aruba/events.rb +50 -14
  23. data/lib/aruba/generators/script_file.rb +5 -5
  24. data/lib/aruba/initializer.rb +7 -2
  25. data/lib/aruba/matchers/command/have_output.rb +1 -1
  26. data/lib/aruba/matchers/command/have_output_on_stderr.rb +1 -1
  27. data/lib/aruba/matchers/command/have_output_on_stdout.rb +1 -1
  28. data/lib/aruba/matchers/command/have_output_size.rb +7 -20
  29. data/lib/aruba/matchers/string/match_output_string.rb +0 -2
  30. data/lib/aruba/platforms/unix_platform.rb +3 -3
  31. data/lib/aruba/platforms/unix_which.rb +2 -4
  32. data/lib/aruba/platforms/windows_which.rb +2 -4
  33. data/lib/aruba/processes/basic_process.rb +4 -4
  34. data/lib/aruba/processes/debug_process.rb +2 -1
  35. data/lib/aruba/processes/in_process.rb +3 -1
  36. data/lib/aruba/processes/spawn_process.rb +32 -21
  37. data/lib/aruba/rspec.rb +18 -25
  38. data/lib/aruba/runtime.rb +39 -21
  39. data/lib/aruba/setup.rb +20 -21
  40. data/lib/aruba/version.rb +1 -1
  41. metadata +76 -63
  42. data/lib/aruba/console/help.rb +0 -34
  43. data/lib/aruba/console.rb +0 -67
  44. data/lib/aruba/contracts/absolute_path.rb +0 -22
  45. data/lib/aruba/contracts/enum.rb +0 -29
  46. data/lib/aruba/contracts/is_power_of_two.rb +0 -24
  47. data/lib/aruba/contracts/relative_path.rb +0 -22
  48. data/lib/aruba/cucumber/testing_frameworks.rb +0 -219
  49. data/lib/aruba/matchers/string/include_output_string.rb +0 -36
  50. data/lib/aruba/matchers/string/output_string_eq.rb +0 -35
@@ -8,4 +8,3 @@ require 'aruba/cucumber/parameter_types'
8
8
  require 'aruba/cucumber/command'
9
9
  require 'aruba/cucumber/environment'
10
10
  require 'aruba/cucumber/file'
11
- require 'aruba/cucumber/testing_frameworks'
data/lib/aruba/events.rb CHANGED
@@ -6,34 +6,70 @@ require 'cucumber/core/event'
6
6
  module Aruba
7
7
  # Events
8
8
  module Events
9
- # Basic event
10
- #
11
- # This is not meant for direct use - BasicEvent.new - by users. It is
12
- # inherited by normal events
13
- #
14
- # @private
15
- class BasicEvent < Cucumber::Core::Event.new(:entity); end
9
+ # cucumber-core version 19 and up
10
+ if defined? Cucumber::Core::Event::Base
11
+ # @private
12
+ class BasicEvent < Cucumber::Core::Event::Base
13
+ attr_reader :entity
14
+
15
+ def initialize(entity)
16
+ @entity = entity
17
+ super()
18
+ end
19
+ end
20
+ else
21
+ # @private
22
+ class BasicEvent < Cucumber::Core::Event.new(:entity); end
23
+ end
16
24
 
17
25
  # Command was stopped
18
- class CommandStopped < BasicEvent; end
26
+ class CommandStopped < BasicEvent
27
+ def self.event_id
28
+ :command_stopped
29
+ end
30
+ end
19
31
 
20
32
  # Command was started
21
- class CommandStarted < BasicEvent; end
33
+ class CommandStarted < BasicEvent
34
+ def self.event_id
35
+ :command_started
36
+ end
37
+ end
22
38
 
23
39
  # An environment variable was changed
24
- class ChangedEnvironmentVariable < BasicEvent; end
40
+ class ChangedEnvironmentVariable < BasicEvent
41
+ def self.event_id
42
+ :changed_environment_variable
43
+ end
44
+ end
25
45
 
26
46
  # An environment variable was added
27
- class AddedEnvironmentVariable < BasicEvent; end
47
+ class AddedEnvironmentVariable < BasicEvent
48
+ def self.event_id
49
+ :added_environment_variable
50
+ end
51
+ end
28
52
 
29
53
  # An environment variable was deleted
30
- class DeletedEnvironmentVariable < BasicEvent; end
54
+ class DeletedEnvironmentVariable < BasicEvent
55
+ def self.event_id
56
+ :deleted_environment_variable
57
+ end
58
+ end
31
59
 
32
60
  # The working directory has changed
33
- class ChangedWorkingDirectory < BasicEvent; end
61
+ class ChangedWorkingDirectory < BasicEvent
62
+ def self.event_id
63
+ :changed_working_directory
64
+ end
65
+ end
34
66
 
35
67
  # The configuration was changed
36
- class ChangedConfiguration < BasicEvent; end
68
+ class ChangedConfiguration < BasicEvent
69
+ def self.event_id
70
+ :changed_configuration
71
+ end
72
+ end
37
73
 
38
74
  def self.registry
39
75
  [CommandStarted,
@@ -10,15 +10,15 @@ module Aruba
10
10
 
11
11
  public
12
12
 
13
- def initialize(opts = {})
14
- @path = opts[:path]
15
- @content = opts[:content]
16
- @interpreter = opts[:interpreter]
13
+ def initialize(path: nil, content: nil, interpreter: nil)
14
+ @path = path
15
+ @content = content
16
+ @interpreter = interpreter
17
17
  end
18
18
 
19
19
  def call
20
20
  Aruba.platform.write_file(path, "#{header}#{content}")
21
- Aruba.platform.chmod(0o755, path, {})
21
+ Aruba.platform.chmod(0o755, path)
22
22
  end
23
23
 
24
24
  private
@@ -3,7 +3,8 @@
3
3
  require 'thor/group'
4
4
  require 'thor/actions'
5
5
 
6
- # Aruba
6
+ require 'aruba/version'
7
+
7
8
  module Aruba
8
9
  # Initializers
9
10
  #
@@ -154,7 +155,11 @@ module Aruba
154
155
  include Aruba::Api
155
156
 
156
157
  def setup
157
- setup_aruba
158
+ aruba.setup
159
+ end
160
+
161
+ def teardown
162
+ aruba.teardown
158
163
  end
159
164
 
160
165
  def test_dummy
@@ -27,7 +27,7 @@ RSpec::Matchers.define :have_output do |expected|
27
27
 
28
28
  @old_actual.stop
29
29
 
30
- @actual = sanitize_text(actual.output)
30
+ @actual = extract_text(actual.output)
31
31
 
32
32
  values_match?(expected, @actual)
33
33
  end
@@ -25,7 +25,7 @@ RSpec::Matchers.define :have_output_on_stderr do |expected|
25
25
 
26
26
  @old_actual.stop
27
27
 
28
- @actual = sanitize_text(actual.stderr)
28
+ @actual = extract_text(actual.stderr)
29
29
 
30
30
  values_match?(expected, @actual)
31
31
  end
@@ -25,7 +25,7 @@ RSpec::Matchers.define :have_output_on_stdout do |expected|
25
25
 
26
26
  @old_actual.stop
27
27
 
28
- @actual = sanitize_text(actual.stdout)
28
+ @actual = extract_text(actual.stdout)
29
29
 
30
30
  values_match?(expected, @actual)
31
31
  end
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # @!method have_output_size(output)
4
- # This matchers checks if output has size.
3
+ # @!method have_output_size
4
+ # This matcher checks if the process has produced output of a given size.
5
5
  #
6
- # @param [String,Aruba::Process:BasicProcess] output or process
7
- # The content which should be checked, or the process whose output should be checked
8
- #
9
- # Use of this matcher with a string is deprecated.
6
+ # @param [Aruba::Process:BasicProcess] process
7
+ # The process whose output should be checked
10
8
  #
11
9
  # @return [Boolean] The result
12
10
  #
@@ -18,24 +16,13 @@
18
16
  # @example Use matcher
19
17
  #
20
18
  # RSpec.describe do
21
- # it { expect(file1).to have_output_size(256) }
22
- # end
23
- #
24
- # RSpec.describe do
25
19
  # it { expect(last_command_started).to have_output_size(256) }
26
20
  # end
27
21
  RSpec::Matchers.define :have_output_size do |expected|
28
22
  match do |actual|
29
- if actual.respond_to? :size
30
- Aruba.platform.deprecated \
31
- 'Application of the have_output_size matcher to a string is deprecated. ' \
32
- 'Apply the matcher directly to the process object instead'
33
- actual_size = actual.size
34
- elsif actual.respond_to? :output
35
- actual_size = actual.output.size
36
- else
37
- raise "Expected #{actual} to respond to #size or #output"
38
- end
23
+ raise "Expected #{actual} to respond to #output" unless actual.respond_to? :output
24
+
25
+ actual_size = actual.output.size
39
26
 
40
27
  values_match? expected, actual_size
41
28
  end
@@ -33,5 +33,3 @@ RSpec::Matchers.define :match_output_string do |expected|
33
33
  end
34
34
 
35
35
  RSpec::Matchers.alias_matcher :an_output_string_matching, :match_output_string
36
- RSpec::Matchers.alias_matcher :a_file_name_matching, :match_output_string
37
- RSpec::Matchers.alias_matcher :file_content_matching, :match_output_string
@@ -112,7 +112,7 @@ module Aruba
112
112
  end
113
113
 
114
114
  # Remove file, directory + sub-directories
115
- def rm(paths, options = {})
115
+ def rm(paths, **options)
116
116
  paths = Array(paths).map { |p| ::File.expand_path(p) }
117
117
 
118
118
  FileUtils.rm_r(paths, **options)
@@ -133,7 +133,7 @@ module Aruba
133
133
  end
134
134
 
135
135
  # Touch file, directory
136
- def touch(args, options)
136
+ def touch(args, **options)
137
137
  FileUtils.touch(args, **options)
138
138
  end
139
139
 
@@ -148,7 +148,7 @@ module Aruba
148
148
  end
149
149
 
150
150
  # Change mode of file/directory
151
- def chmod(mode, args, options)
151
+ def chmod(mode, args, **options)
152
152
  FileUtils.chmod_R(mode, args, **options)
153
153
  end
154
154
 
@@ -40,7 +40,7 @@ module Aruba
40
40
 
41
41
  def call(program, path)
42
42
  # Iterate over each path glob the dir + program.
43
- path.split(File::PATH_SEPARATOR).each do |dir|
43
+ path&.split(File::PATH_SEPARATOR)&.each do |dir|
44
44
  dir = Aruba.platform.expand_path(dir, Dir.getwd)
45
45
  next unless Aruba.platform.exist?(dir) # In case of bogus second argument
46
46
 
@@ -65,7 +65,7 @@ module Aruba
65
65
  @whiches << DefaultWhich
66
66
  end
67
67
 
68
- # Find fully quallified path for program
68
+ # Find fully qualified path for program
69
69
  #
70
70
  # @param [String] program
71
71
  # Name of program
@@ -73,8 +73,6 @@ module Aruba
73
73
  # @param [String] path
74
74
  # ENV['PATH']
75
75
  def call(program, path = ENV['PATH'])
76
- raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty?
77
-
78
76
  program = program.to_s
79
77
 
80
78
  whiches.find { |w| w.match? program }.new.call(program, path)
@@ -43,7 +43,7 @@ module Aruba
43
43
 
44
44
  def call(program, path)
45
45
  # Iterate over each path glob the dir + program.
46
- path.split(File::PATH_SEPARATOR).each do |dir|
46
+ path&.split(File::PATH_SEPARATOR)&.each do |dir|
47
47
  dir = Aruba.platform.expand_path(dir, Dir.getwd)
48
48
 
49
49
  next unless Aruba.platform.exist?(dir) # In case of bogus second argument
@@ -79,7 +79,7 @@ module Aruba
79
79
  @whiches << DefaultWhich
80
80
  end
81
81
 
82
- # Find fully quallified path for program
82
+ # Find fully qualified path for program
83
83
  #
84
84
  # @param [String] program
85
85
  # Name of program
@@ -87,8 +87,6 @@ module Aruba
87
87
  # @param [String] path
88
88
  # ENV['PATH']
89
89
  def call(program, path = ENV['PATH'])
90
- raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty?
91
-
92
90
  program = program.to_s
93
91
  program += windows_executable_extentions if File.extname(program).empty?
94
92
 
@@ -9,13 +9,13 @@ module Aruba
9
9
  module Processes
10
10
  # Basic Process
11
11
  #
12
- # `BasicProcess` is not meant for direct use - `BasicProcess.new` - by users.
12
+ # Base class for all Aruba process runners.
13
13
  #
14
- # @private
15
14
  class BasicProcess
16
15
  attr_reader :exit_status, :environment, :working_directory, :main_class,
17
16
  :io_wait_timeout, :exit_timeout, :startup_wait_time, :stop_signal
18
17
 
18
+ # @private
19
19
  def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, # rubocop:disable Metrics/ParameterLists
20
20
  environment = Aruba.platform.environment_variables.hash_from_env,
21
21
  main_class = nil, stop_signal = nil, startup_wait_time = 0)
@@ -45,8 +45,8 @@ module Aruba
45
45
  end
46
46
 
47
47
  # Output stderr and stdout
48
- def output(opts = {})
49
- stdout(opts) + stderr(opts)
48
+ def output(**opts)
49
+ stdout(**opts) + stderr(**opts)
50
50
  end
51
51
 
52
52
  def write(*)
@@ -16,9 +16,10 @@ module Aruba
16
16
  # users. Only its public methods are part of the public API of aruba, e.g.
17
17
  # `#stdin`, `#stdout`.
18
18
  #
19
- # @private
20
19
  class DebugProcess < BasicProcess
21
20
  # Use only if mode is :debug
21
+ #
22
+ # @private
22
23
  def self.match?(mode)
23
24
  mode == :debug || (mode.is_a?(Class) && mode <= DebugProcess)
24
25
  end
@@ -15,9 +15,10 @@ module Aruba
15
15
  # users. Only it's public methods are part of the public API of aruba, e.g.
16
16
  # `#stdin`, `#stdout`.
17
17
  #
18
- # @private
19
18
  class InProcess < BasicProcess
20
19
  # Use only if mode is in_process
20
+ #
21
+ # @private
21
22
  def self.match?(mode)
22
23
  mode == :in_process || (mode.is_a?(Class) && mode <= InProcess)
23
24
  end
@@ -48,6 +49,7 @@ module Aruba
48
49
  # @private
49
50
  attr_reader :main_class
50
51
 
52
+ # @private
51
53
  def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, # rubocop:disable Metrics/ParameterLists
52
54
  environment = Aruba.platform.environment_variables.hash_from_env,
53
55
  main_class = nil, stop_signal = nil, startup_wait_time = 0)
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'marcel'
3
4
  require 'tempfile'
4
5
  require 'shellwords'
5
6
 
@@ -74,7 +75,7 @@ module Aruba
74
75
  return true if exited?
75
76
  break if Time.now >= wait_until
76
77
 
77
- sleep 0.1
78
+ sleep 0.01
78
79
  end
79
80
  false
80
81
  end
@@ -96,9 +97,9 @@ module Aruba
96
97
  # users. Only it's public methods are part of the public API of aruba, e.g.
97
98
  # `#stdin`, `#stdout`.
98
99
  #
99
- # @private
100
100
  class SpawnProcess < BasicProcess
101
101
  # Use as default launcher
102
+ # @private
102
103
  def self.match?(_mode)
103
104
  true
104
105
  end
@@ -128,6 +129,8 @@ module Aruba
128
129
  #
129
130
  # @param [Numeric] startup_wait_time
130
131
  # The amount of seconds to wait after Aruba has started a command.
132
+ #
133
+ # @private
131
134
  def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, # rubocop:disable Metrics/ParameterLists
132
135
  environment = Aruba.platform.environment_variables.hash_from_env,
133
136
  main_class = nil, stop_signal = nil, startup_wait_time = 0)
@@ -156,8 +159,8 @@ module Aruba
156
159
 
157
160
  @process = ProcessRunner.new(command_string.to_a)
158
161
 
159
- @stdout_file = Tempfile.new('aruba-stdout-')
160
- @stderr_file = Tempfile.new('aruba-stderr-')
162
+ @stdout_file = Tempfile.create('aruba-stdout-', anonymous: true)
163
+ @stderr_file = Tempfile.create('aruba-stderr-', anonymous: true)
161
164
 
162
165
  @stdout_file.sync = true
163
166
  @stderr_file.sync = true
@@ -196,39 +199,35 @@ module Aruba
196
199
 
197
200
  # Access to stdout of process
198
201
  #
199
- # @param [Hash] opts
200
- # Options
201
- #
202
- # @option [Integer] wait_for_io
202
+ # @param [Integer] wait_for_io
203
203
  # Wait for IO to be finished
204
204
  #
205
205
  # @return [String]
206
206
  # The content of stdout
207
- def stdout(opts = {})
207
+ def stdout(wait_for_io: io_wait_timeout)
208
208
  return @stdout_cache if stopped?
209
209
 
210
- wait_for_io opts.fetch(:wait_for_io, io_wait_timeout) do
210
+ wait_for_io wait_for_io do
211
211
  @process.stdout.flush
212
- File.read(@stdout_file.path)
212
+ @stdout_file.rewind
213
+ @stdout_file.read
213
214
  end
214
215
  end
215
216
 
216
217
  # Access to stderr of process
217
218
  #
218
- # @param [Hash] opts
219
- # Options
220
- #
221
- # @option [Integer] wait_for_io
219
+ # @param [Integer] wait_for_io
222
220
  # Wait for IO to be finished
223
221
  #
224
222
  # @return [String]
225
223
  # The content of stderr
226
- def stderr(opts = {})
224
+ def stderr(wait_for_io: io_wait_timeout)
227
225
  return @stderr_cache if stopped?
228
226
 
229
- wait_for_io opts.fetch(:wait_for_io, io_wait_timeout) do
227
+ wait_for_io wait_for_io do
230
228
  @process.stderr.flush
231
- File.read(@stderr_file.path)
229
+ @stderr_file.rewind
230
+ @stderr_file.read
232
231
  end
233
232
  end
234
233
 
@@ -322,10 +321,16 @@ module Aruba
322
321
  # Content of command
323
322
  #
324
323
  # @return [String]
325
- # The content of the script/command. This might be binary output as
326
- # string if your command is a binary executable.
324
+ # The content of the script/command. If your command is a binary
325
+ # executable, a human-readable message is returned instead.
327
326
  def content
328
- File.read command_path
327
+ return unless command_path
328
+
329
+ if binary_file?(command_path)
330
+ "Binary content of '#{command_path}' not displayed"
331
+ else
332
+ File.read command_path
333
+ end
329
334
  end
330
335
 
331
336
  def interactive?
@@ -352,6 +357,12 @@ module Aruba
352
357
  end
353
358
  end
354
359
 
360
+ def binary_file?(file_path)
361
+ mime_type = Marcel::MimeType.for Pathname.new(file_path)
362
+ magic = Marcel::Magic.new mime_type
363
+ !magic.text?
364
+ end
365
+
355
366
  def wait_for_io(time_to_wait)
356
367
  sleep time_to_wait
357
368
  yield
data/lib/aruba/rspec.rb CHANGED
@@ -10,47 +10,40 @@ RSpec.configure do |config|
10
10
  config.include Aruba::Api, type: :aruba
11
11
 
12
12
  # Setup environment for aruba
13
- config.around :each do |example|
14
- if self.class.include? Aruba::Api
15
- setup_aruba
13
+ config.around :each, type: :aruba do |example|
14
+ aruba.setup
16
15
 
17
- # Modify PATH to include project/bin
18
- prepend_environment_variable(
19
- 'PATH',
20
- aruba.config.command_search_paths.join(File::PATH_SEPARATOR) + File::PATH_SEPARATOR
21
- )
16
+ # Modify PATH to include project/bin
17
+ prepend_environment_variable(
18
+ 'PATH',
19
+ aruba.config.command_search_paths.join(File::PATH_SEPARATOR) + File::PATH_SEPARATOR
20
+ )
22
21
 
23
- # Use configured home directory as HOME
24
- set_environment_variable 'HOME', aruba.config.home_directory
25
- end
22
+ # Use configured home directory as HOME
23
+ set_environment_variable 'HOME', aruba.home_directory
26
24
 
27
25
  example.run
28
26
 
29
- next unless self.class.include? Aruba::Api
30
-
31
27
  stop_all_commands
28
+ if example.exception
29
+ warn "Find the Aruba working directory for inspection at #{aruba.home_directory}"
30
+ else
31
+ aruba.teardown
32
+ end
32
33
  end
33
34
 
34
- config.around :each do |example|
35
- if self.class.include? Aruba::Api
36
- with_environment do
37
- example.run
38
- end
39
- else
35
+ config.around :each, type: :aruba do |example|
36
+ with_environment do
40
37
  example.run
41
38
  end
42
39
  end
43
40
 
44
- config.before :each do |example|
45
- next unless self.class.include? Aruba::Api
46
-
41
+ config.before :each, type: :aruba do |example|
47
42
  example.metadata.each { |k, v| aruba.config.set_if_option(k, v) }
48
43
  end
49
44
 
50
45
  # Activate announcers based on rspec metadata
51
- config.before :each do |example|
52
- next unless self.class.include?(Aruba::Api)
53
-
46
+ config.before :each, type: :aruba do |example|
54
47
  if example.metadata[:announce_full_environment]
55
48
  aruba.announcer.activate(:full_environment)
56
49
  end
data/lib/aruba/runtime.rb CHANGED
@@ -17,9 +17,15 @@ module Aruba
17
17
  # @!attribute [r] current_directory
18
18
  # Returns the current working directory
19
19
  #
20
+ # @!attribute [r] working_directory
21
+ # Returns the working directory
22
+ #
20
23
  # @!attribute [r] root_directory
21
24
  # Returns the root directory of aruba
22
- attr_reader :current_directory, :root_directory
25
+ #
26
+ # @!attribute [r] home_directory
27
+ # Returns the home directory used to mock HOME by aruba
28
+ attr_reader :current_directory, :working_directory, :root_directory, :home_directory
23
29
 
24
30
  # @!attribute [r] config
25
31
  # Access configuration of aruba
@@ -39,40 +45,46 @@ module Aruba
39
45
  # @!attribute [r] event_bus
40
46
  # Handle events (private)
41
47
  #
42
- attr_accessor :config, :environment, :logger, :command_monitor, :announcer, :event_bus
48
+ attr_reader :config, :environment, :logger, :command_monitor, :announcer, :event_bus
43
49
 
44
- def initialize(opts = {})
50
+ def initialize(config: Aruba.config)
45
51
  @event_bus = EventBus.new(Aruba::Events.registry)
46
- @announcer = opts.fetch(:announcer, Aruba.platform.announcer.new)
47
- @config = opts.fetch(:config,
48
- ConfigWrapper.new(Aruba.config.make_copy, @event_bus))
49
- @environment = opts.fetch(:environment, Aruba.platform.environment_variables.new)
50
- @current_directory = ArubaPath.new(@config.working_directory)
51
- @root_directory = ArubaPath.new(@config.root_directory)
52
+ @announcer = Aruba.platform.announcer.new
53
+ @config = ConfigWrapper.new(config.make_copy, @event_bus)
54
+ @environment = Aruba.platform.environment_variables.new
55
+
56
+ @root_directory = ArubaPath.new(@config.root_directory)
52
57
 
53
58
  @environment.update(@config.command_runtime_environment)
54
59
 
55
- @command_monitor = opts.fetch(:command_monitor,
56
- Aruba.platform.command_monitor.new(announcer: @announcer))
60
+ @command_monitor = Aruba.platform.command_monitor.new(announcer: @announcer)
57
61
 
58
- @logger = opts.fetch(:logger, Aruba.platform.logger.new)
62
+ @logger = Aruba.platform.logger.new
59
63
  @logger.mode = @config.log_level
60
64
 
65
+ @setup = Aruba::Setup.new(self)
61
66
  @setup_done = false
62
67
  end
63
68
 
64
- # @private
65
- #
66
- # Setup of aruba is finshed. Should be used only internally.
67
- def setup_done
69
+ # Set up Aruba's workspace and event bus. Cleans out the workspace as well.
70
+ def setup
71
+ return if @setup_done
72
+
73
+ @setup.setup
74
+
75
+ @home_directory = @setup.workspace_directory
76
+ @working_directory = Pathname.new(@home_directory)
77
+ .relative_path_from(@config.root_directory).to_s
78
+ @current_directory = ArubaPath.new(@working_directory)
79
+
68
80
  @setup_done = true
69
81
  end
70
82
 
71
- # @private
72
- #
73
- # Has aruba already been setup. Should be used only internally.
74
- def setup_already_done?
75
- @setup_done == true
83
+ def teardown
84
+ return unless @setup_done
85
+
86
+ @setup.teardown
87
+ @setup_done = false
76
88
  end
77
89
 
78
90
  # The path to the directory which contains fixtures
@@ -99,5 +111,11 @@ module Aruba
99
111
 
100
112
  ArubaPath.new(@fixtures_directory)
101
113
  end
114
+
115
+ private
116
+
117
+ def setup_already_done?
118
+ @setup_done == true
119
+ end
102
120
  end
103
121
  end