aruba 0.7.4 → 0.8.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.nav +12 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +12 -0
  6. data/.simplecov +2 -0
  7. data/.travis.yml +5 -6
  8. data/Gemfile +53 -26
  9. data/History.md +17 -0
  10. data/LICENSE +1 -1
  11. data/README.md +45 -19
  12. data/Rakefile +12 -2
  13. data/TODO.md +3 -0
  14. data/aruba.gemspec +19 -8
  15. data/cucumber.yml +1 -1
  16. data/features/api/cd.feature +119 -0
  17. data/features/api/command/run.feature +37 -0
  18. data/features/api/command/which.feature +37 -0
  19. data/features/api/environment/append_environment_variable.feature +118 -0
  20. data/features/api/environment/prepend_environment_variable.feature +118 -0
  21. data/features/api/environment/set_environment_variable.feature +252 -0
  22. data/features/configuration/exit_timeout.feature +51 -0
  23. data/features/configuration/fixtures_directories.feature +31 -0
  24. data/features/configuration/fixtures_path_prefix.feature +24 -0
  25. data/features/configuration/io_timeout.feature +31 -0
  26. data/features/configuration/keep_ansi.feature +31 -0
  27. data/features/configuration/root_directory.feature +31 -0
  28. data/features/configuration/working_directory.feature +32 -0
  29. data/features/fixtures/cli-app/.gitignore +9 -0
  30. data/features/fixtures/cli-app/.rspec +2 -0
  31. data/features/fixtures/cli-app/README.md +34 -0
  32. data/features/fixtures/cli-app/Rakefile +1 -0
  33. data/features/fixtures/cli-app/bin/cli +6 -0
  34. data/features/fixtures/cli-app/cli-app.gemspec +26 -0
  35. data/features/fixtures/cli-app/features/support/env.rb +1 -0
  36. data/features/fixtures/cli-app/lib/cli/app.rb +13 -0
  37. data/features/fixtures/cli-app/lib/cli/app/version.rb +5 -0
  38. data/features/fixtures/cli-app/script/console +14 -0
  39. data/features/fixtures/cli-app/spec/cli/app_spec.rb +7 -0
  40. data/features/fixtures/cli-app/spec/spec_helper.rb +10 -0
  41. data/features/fixtures/copy/file.txt +1 -1
  42. data/features/hooks/after/command.feature +34 -0
  43. data/features/hooks/before/command.feature +61 -0
  44. data/features/matchers/directory/have_sub_directory.feature +110 -0
  45. data/features/matchers/file/be_existing_file.feature +82 -0
  46. data/features/matchers/file/have_file_content.feature +123 -0
  47. data/features/matchers/file/have_file_size.feature +107 -0
  48. data/features/matchers/path/be_an_absolute_path.feature +74 -0
  49. data/features/matchers/path/be_an_existing_path.feature +97 -0
  50. data/features/matchers/path/have_permissions.feature +118 -0
  51. data/features/matchers/timeouts.feature +48 -0
  52. data/features/step_definitions/aruba_dev_steps.rb +69 -1
  53. data/features/steps/commands/exit_statuses.feature +136 -0
  54. data/features/steps/commands/in_process.feature +129 -0
  55. data/features/steps/commands/run.feature +36 -0
  56. data/features/steps/environment/home_variable.feature +49 -0
  57. data/features/steps/environment/set_environment_variable.feature +34 -0
  58. data/features/support/aruba.rb +5 -0
  59. data/features/support/env.rb +8 -4
  60. data/lib/aruba.rb +20 -8
  61. data/lib/aruba/announcer.rb +1 -0
  62. data/lib/aruba/api.rb +18 -1179
  63. data/lib/aruba/api/command.rb +351 -0
  64. data/lib/aruba/api/core.rb +141 -0
  65. data/lib/aruba/api/deprecated.rb +549 -0
  66. data/lib/aruba/api/environment.rb +61 -0
  67. data/lib/aruba/api/filesystem.rb +305 -0
  68. data/lib/aruba/api/rvm.rb +39 -0
  69. data/lib/aruba/aruba_path.rb +75 -0
  70. data/lib/aruba/basic_configuration.rb +208 -0
  71. data/lib/aruba/basic_configuration/option.rb +25 -0
  72. data/lib/aruba/config.rb +43 -30
  73. data/lib/aruba/config/jruby.rb +14 -0
  74. data/lib/aruba/config_wrapper.rb +17 -0
  75. data/lib/aruba/contracts/relative_path.rb +13 -0
  76. data/lib/aruba/creators/aruba_file_creator.rb +32 -0
  77. data/lib/aruba/creators/aruba_fixed_size_file_creator.rb +32 -0
  78. data/lib/aruba/cucumber.rb +87 -53
  79. data/lib/aruba/cucumber/hooks.rb +65 -10
  80. data/lib/aruba/environment.rb +121 -0
  81. data/lib/aruba/errors.rb +3 -0
  82. data/lib/aruba/extensions/string/strip.rb +24 -0
  83. data/lib/aruba/hooks.rb +54 -0
  84. data/lib/aruba/jruby.rb +4 -9
  85. data/lib/aruba/matchers/command.rb +1 -79
  86. data/lib/aruba/matchers/command/be_successfully_executed.rb +30 -0
  87. data/lib/aruba/matchers/command/have_exit_status.rb +47 -0
  88. data/lib/aruba/matchers/command/have_finished_in_time.rb +42 -0
  89. data/lib/aruba/matchers/directory.rb +1 -59
  90. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +34 -0
  91. data/lib/aruba/matchers/directory/have_sub_directory.rb +49 -0
  92. data/lib/aruba/matchers/file.rb +1 -177
  93. data/lib/aruba/matchers/file/be_an_existing_file.rb +34 -0
  94. data/lib/aruba/matchers/file/have_file_content.rb +58 -0
  95. data/lib/aruba/matchers/file/have_file_size.rb +43 -0
  96. data/lib/aruba/matchers/file/have_same_file_content.rb +44 -0
  97. data/lib/aruba/matchers/path.rb +1 -99
  98. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +21 -0
  99. data/lib/aruba/matchers/path/be_an_absolute_path.rb +32 -0
  100. data/lib/aruba/matchers/path/be_an_existing_path.rb +33 -0
  101. data/lib/aruba/matchers/path/have_permissions.rb +60 -0
  102. data/lib/aruba/matchers/path/match_path_pattern.rb +41 -0
  103. data/lib/aruba/matchers/rspec.rb +0 -0
  104. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +1 -1
  105. data/lib/aruba/platform.rb +230 -0
  106. data/lib/aruba/process_monitor.rb +23 -5
  107. data/lib/aruba/processes/basic_process.rb +35 -1
  108. data/lib/aruba/processes/debug_process.rb +26 -15
  109. data/lib/aruba/processes/in_process.rb +21 -9
  110. data/lib/aruba/processes/spawn_process.rb +29 -19
  111. data/lib/aruba/reporting.rb +2 -0
  112. data/lib/aruba/rspec.rb +61 -13
  113. data/lib/aruba/runtime.rb +33 -0
  114. data/script/bootstrap +4 -6
  115. data/spec/aruba/api/runtime_spec.rb +28 -0
  116. data/spec/aruba/api_spec.rb +129 -126
  117. data/spec/aruba/aruba_path_spec.rb +65 -0
  118. data/spec/aruba/basic_configuration_spec.rb +5 -0
  119. data/spec/aruba/config_wrapper_spec.rb +25 -0
  120. data/spec/aruba/configuration_spec.rb +5 -0
  121. data/spec/aruba/jruby_spec.rb +34 -18
  122. data/spec/aruba/matchers/directory_spec.rb +6 -7
  123. data/spec/aruba/matchers/file_spec.rb +16 -20
  124. data/spec/aruba/matchers/path_spec.rb +14 -11
  125. data/spec/aruba/rspec_spec.rb +15 -0
  126. data/spec/aruba/runtime_spec.rb +29 -0
  127. data/spec/aruba/spawn_process_spec.rb +2 -2
  128. data/spec/spec_helper.rb +10 -2
  129. data/spec/support/configs/rspec.rb +1 -1
  130. data/spec/support/matchers/option.rb +35 -0
  131. data/spec/support/shared_contexts/aruba.rb +10 -8
  132. data/spec/support/shared_examples/configuration.rb +116 -0
  133. metadata +182 -33
  134. data/.rvmrc +0 -1
  135. data/features/before_cmd_hooks.feature +0 -61
  136. data/features/command_environment_variables.feature +0 -31
  137. data/features/custom_ruby_process.feature +0 -12
  138. data/features/exit_statuses.feature +0 -30
  139. data/features/support/custom_main.rb +0 -28
  140. data/lib/aruba/matchers/mode.rb +0 -52
  141. data/lib/aruba/utils.rb +0 -21
@@ -7,8 +7,6 @@ require 'aruba/processes/basic_process'
7
7
  module Aruba
8
8
  module Processes
9
9
  class SpawnProcess < BasicProcess
10
- attr_reader :exit_status
11
-
12
10
  # Create process
13
11
  #
14
12
  # @params [String] cmd
@@ -22,30 +20,29 @@ module Aruba
22
20
  #
23
21
  # @params [String] working_directory
24
22
  # The directory where the command will be executed
25
- def initialize(cmd, exit_timeout, io_wait, working_directory)
26
- @exit_timeout = exit_timeout
27
- @io_wait = io_wait
28
-
29
- @cmd = cmd
30
- @process = nil
31
- @exit_status = nil
32
- @output_cache = nil
33
- @error_cache = nil
34
-
23
+ def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash)
35
24
  super
36
- end
37
25
 
38
- # Return command line
39
- def commandline
40
- @cmd
26
+ @exit_timeout = exit_timeout
27
+ @io_wait = io_wait
28
+ @process = nil
29
+ @output_cache = nil
30
+ @error_cache = nil
41
31
  end
42
32
 
43
33
  # Run the command
44
34
  #
45
35
  # @yield [SpawnProcess]
46
36
  # Run code for process which was started
37
+ #
38
+ # rubocop:disable Metrics/MethodLength
39
+ # rubocop:disable Metrics/CyclomaticComplexity
47
40
  def run!
48
- @process = ChildProcess.build(*Shellwords.split(@cmd))
41
+ # rubocop:disable Metrics/LineLength
42
+ fail LaunchError, %(Command "#{command}" not found in PATH-variable "#{environment['PATH']}".) unless which(command, environment['PATH'])
43
+ # rubocop:enable Metrics/LineLength
44
+
45
+ @process = ChildProcess.build(which(command, environment['PATH']), *arguments)
49
46
  @out = Tempfile.new("aruba-out")
50
47
  @err = Tempfile.new("aruba-err")
51
48
  @exit_status = nil
@@ -58,6 +55,8 @@ module Aruba
58
55
  @process.duplex = @duplex
59
56
  @process.cwd = @working_directory
60
57
 
58
+ @process.environment.update(environment)
59
+
61
60
  begin
62
61
  @process.start
63
62
  rescue ChildProcess::LaunchError => e
@@ -68,6 +67,8 @@ module Aruba
68
67
 
69
68
  yield self if block_given?
70
69
  end
70
+ # rubocop:enable Metrics/MethodLength
71
+ # rubocop:enable Metrics/CyclomaticComplexity
71
72
 
72
73
  def stdin
73
74
  @process.io.stdin
@@ -98,7 +99,11 @@ module Aruba
98
99
  end
99
100
 
100
101
  def close_io(name)
101
- @process.io.public_send(name.to_sym).close
102
+ if RUBY_VERSION < '1.9'
103
+ @process.io.send(name.to_sym).close
104
+ else
105
+ @process.io.public_send(name.to_sym).close
106
+ end
102
107
  end
103
108
 
104
109
  def stop(reader)
@@ -106,7 +111,12 @@ module Aruba
106
111
 
107
112
  return @exit_status unless @process
108
113
 
109
- @process.poll_for_exit(@exit_timeout) unless @process.exited?
114
+ begin
115
+ @process.poll_for_exit(@exit_timeout) unless @process.exited?
116
+ rescue ChildProcess::TimeoutError
117
+ @timed_out = true
118
+ @process.stop
119
+ end
110
120
 
111
121
  @exit_status = @process.exit_code
112
122
  @process = nil
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  if(ENV['ARUBA_REPORT_DIR'])
2
4
  ENV['ARUBA_REPORT_TEMPLATES'] ||= File.dirname(__FILE__) + '/../../templates'
3
5
 
@@ -1,26 +1,74 @@
1
1
  require 'rspec/core'
2
+
3
+ require 'aruba'
2
4
  require 'aruba/api'
3
- require 'aruba/reporting'
4
5
 
5
6
  RSpec.configure do |config|
6
- config.include Aruba::Api, type: :aruba
7
+ config.include Aruba::Api, :type => :aruba
7
8
 
8
9
  config.before :each do
9
- next unless self.class.include?(Aruba::Api)
10
+ next unless self.class.include? Aruba::Api
10
11
 
11
12
  restore_env
12
- clean_current_directory
13
+ setup_aruba
13
14
  end
14
15
 
15
- # config.before do
16
- # next unless self.class.include?(Aruba::Api)
16
+ # Activate on 1.0.0
17
+ # config.around :each do |example|
18
+ # old_env = ENV.to_hash
19
+ # example.run
20
+ # ENV.update old_env
21
+ # end
22
+
23
+ config.around :each do |example|
24
+ project_bin = Aruba::ArubaPath.new(Aruba.config.root_directory)
25
+ project_bin << 'bin'
17
26
 
18
- # current_example = context.example
27
+ old_path = ENV.fetch 'PATH', ''
19
28
 
20
- # announcer.activate(:environment) if current_example.metadata[:announce_env]
21
- # announcer.activate(:command) if current_example.metadata[:announce_cmd]
22
- # announcer.activate(:directory) if current_example.metadata[:announce_dir]
23
- # announcer.activate(:stdout) if current_example.metadata[:announce_stdout]
24
- # announcer.activate(:stderr) if current_example.metadata[:announce_stderr]
25
- # end
29
+ paths = old_path.split(File::PATH_SEPARATOR)
30
+ paths.unshift project_bin
31
+
32
+ ENV['PATH'] = paths.join(File::PATH_SEPARATOR)
33
+
34
+ example.run
35
+
36
+ ENV['PATH'] = old_path
37
+ end
38
+
39
+ config.before :each do |example|
40
+ next unless self.class.include? Aruba::Api
41
+
42
+ example.metadata.each { |k, v| aruba.config.set_if_option(k, v) }
43
+ end
44
+
45
+ config.before :each do |example|
46
+ next unless self.class.include?(Aruba::Api)
47
+
48
+ announcer.activate(:environment) if example.metadata[:announce_environment]
49
+ announcer.activate(:command) if example.metadata[:announce_command]
50
+ announcer.activate(:directory) if example.metadata[:announce_directory]
51
+ announcer.activate(:stdout) if example.metadata[:announce_stdout]
52
+ announcer.activate(:stderr) if example.metadata[:announce_stderr]
53
+
54
+ if example.metadata[:announce_output]
55
+ announcer.activate(:stderr)
56
+ announcer.activate(:stdout)
57
+ end
58
+
59
+ if example.metadata[:announce]
60
+ announcer.activate(:stderr)
61
+ announcer.activate(:stdout)
62
+ announcer.activate(:environment)
63
+ announcer.activate(:command)
64
+ announcer.activate(:directory)
65
+ end
66
+ end
67
+
68
+ config.before :each do
69
+ next unless self.class.include? Aruba::Api
70
+
71
+ aruba.environment.update aruba.config.command_runtime_environment
72
+ aruba.environment.prepend 'PATH', aruba.config.command_search_paths.join(':') + ':'
73
+ end
26
74
  end
@@ -0,0 +1,33 @@
1
+ require 'aruba/config'
2
+ require 'aruba/environment'
3
+
4
+ module Aruba
5
+ class Runtime
6
+ attr_reader :config, :current_directory, :environment, :root_directory
7
+
8
+ def initialize
9
+ @config = Aruba.config.make_copy
10
+ @current_directory = ArubaPath.new(@config.working_directory)
11
+ @root_directory = ArubaPath.new(@config.root_directory)
12
+ @environment = Environment.new
13
+ end
14
+
15
+ # The path to the directory which contains fixtures
16
+ # You might want to overwrite this method to place your data else where.
17
+ #
18
+ # @return [ArubaPath]
19
+ # The directory to where your fixtures are stored
20
+ def fixtures_directory
21
+ unless @fixtures_directory
22
+ candidates = config.fixtures_directories.map { |dir| File.join(root_directory, dir) }
23
+ @fixtures_directory = candidates.find { |d| Aruba::Platform.directory? d }
24
+
25
+ fail "No existing fixtures directory found in #{candidates.map { |d| format('"%s"', d) }.join(', ')}. " unless @fixtures_directory
26
+ end
27
+
28
+ fail %(Fixtures directory "#{@fixtures_directory}" is not a directory) unless Aruba::Platform.directory?(@fixtures_directory)
29
+
30
+ ArubaPath.new(@fixtures_directory)
31
+ end
32
+ end
33
+ end
@@ -13,10 +13,8 @@ echo -ne "$info_msg Checking if ruby installed? "
13
13
  which 'ruby' >/dev/null 2>error.log || ( echo -e "$error_msg\n\nCould not find \`ruby\`. Please install ruby or add it to PATH"; output_error_log; exit 1 )
14
14
  echo OK
15
15
 
16
- echo -en "$info_msg rubygem \"bundler\" "
17
- gem install bundler >/dev/null 2>error.log || ( echo -e "$error_msg\n\nAn error occurred during installation of bundler. Run \`gem install bundler\` yourself."; output_error_log; exit 1 )
18
- echo OK
16
+ echo -e "$info_msg rubygem \"bundler\" "
17
+ gem install bundler
19
18
 
20
- echo -en "$info_msg \"bundle install\" "
21
- bundle install $* >/dev/null 2>error.log || ( echo -e "$error_msg\n\nAn error occurred during bundle install. Run \`bundle install\` yourself."; output_error_log; exit 1 )
22
- echo OK
19
+ echo -e "$info_msg \"bundle install\" "
20
+ bundle install $*
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'aruba' do
4
+ describe '#config' do
5
+ subject(:config) { aruba.config }
6
+
7
+ if RUBY_VERSION >= '1.9'
8
+ context 'when initialized' do
9
+ it { is_expected.to eq Aruba.config }
10
+ end
11
+ end
12
+
13
+ context 'when changed earlier' do
14
+ context 'values when init' do
15
+ let(:value) { 20 }
16
+ before(:each) { aruba.config.io_wait_timeout = value }
17
+
18
+ it { expect(config.io_wait_timeout).to eq value }
19
+ end
20
+
21
+ context 'default value' do
22
+ let(:value) { 0.1 } # Aruba.config.io_wait_timeout
23
+
24
+ it { expect(config.io_wait_timeout).to eq value }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,25 +1,27 @@
1
1
  require 'spec_helper'
2
2
  require 'securerandom'
3
+ require 'aruba/api'
4
+ require 'fileutils'
3
5
 
4
6
  describe Aruba::Api do
5
7
  include_context 'uses aruba API'
6
8
 
7
9
  describe 'current_directory' do
8
10
  it "should return the current dir as 'tmp/aruba'" do
9
- expect(@aruba.current_directory).to match(/^tmp\/aruba$/)
11
+ expect(@aruba.aruba.current_directory.to_s).to match(/^tmp\/aruba$/)
10
12
  end
11
13
 
12
14
  it "can be cleared" do
13
15
  write_file('test', 'test test test')
14
16
 
15
- in_current_directory do
16
- expect(File.exist?('test')).to be_truthy
17
+ cd('.') do
18
+ expect(File.exist?('test')).to be true
17
19
  end
18
20
 
19
- clean_current_directory
21
+ setup_aruba
20
22
 
21
- in_current_directory do
22
- expect(File.exist?('test')).to be_falsey
23
+ cd('.') do
24
+ expect(File.exist?('test')).to be false
23
25
  end
24
26
  end
25
27
  end
@@ -30,7 +32,7 @@ describe Aruba::Api do
30
32
 
31
33
  context 'when file exist' do
32
34
  before :each do
33
- File.write(path, '')
35
+ Aruba::Platform.write_file(path, '')
34
36
  end
35
37
 
36
38
  it { expect(all_paths).to include expand_path(name) }
@@ -38,10 +40,10 @@ describe Aruba::Api do
38
40
 
39
41
  context 'when directory exist' do
40
42
  let(:name) { 'test_dir' }
41
- let(:path) { File.join(@aruba.current_directory, name) }
43
+ let(:path) { File.join(@aruba.aruba.current_directory, name) }
42
44
 
43
45
  before :each do
44
- FileUtils.mkdir_p path
46
+ Aruba::Platform.mkdir(path)
45
47
  end
46
48
 
47
49
  it { expect(all_paths).to include expand_path(name) }
@@ -58,7 +60,7 @@ describe Aruba::Api do
58
60
 
59
61
  context 'when file exist' do
60
62
  before :each do
61
- File.write(path, '')
63
+ Aruba::Platform.write_file(path, '')
62
64
  end
63
65
 
64
66
  it { expect(all_files).to include expand_path(name) }
@@ -66,10 +68,10 @@ describe Aruba::Api do
66
68
 
67
69
  context 'when directory exist' do
68
70
  let(:name) { 'test_dir' }
69
- let(:path) { File.join(@aruba.current_directory, name) }
71
+ let(:path) { File.join(@aruba.aruba.current_directory, name) }
70
72
 
71
73
  before :each do
72
- FileUtils.mkdir_p path
74
+ Aruba::Platform.mkdir(path)
73
75
  end
74
76
 
75
77
  it { expect(all_files).to eq [] }
@@ -86,7 +88,7 @@ describe Aruba::Api do
86
88
 
87
89
  context 'when file exist' do
88
90
  before :each do
89
- File.write(path, '')
91
+ Aruba::Platform.write_file(path, '')
90
92
  end
91
93
 
92
94
  it { expect(all_directories).to eq [] }
@@ -94,10 +96,10 @@ describe Aruba::Api do
94
96
 
95
97
  context 'when directory exist' do
96
98
  let(:name) { 'test_dir' }
97
- let(:path) { File.join(@aruba.current_directory, name) }
99
+ let(:path) { File.join(@aruba.aruba.current_directory, name) }
98
100
 
99
101
  before :each do
100
- FileUtils.mkdir_p path
102
+ Aruba::Platform.mkdir(path)
101
103
  end
102
104
 
103
105
  it { expect(all_directories).to include expand_path(name) }
@@ -111,7 +113,7 @@ describe Aruba::Api do
111
113
  describe 'directories' do
112
114
  before(:each) do
113
115
  @directory_name = 'test_dir'
114
- @directory_path = File.join(@aruba.current_directory, @directory_name)
116
+ @directory_path = File.join(@aruba.aruba.current_directory, @directory_name)
115
117
  end
116
118
 
117
119
  context '#create_directory' do
@@ -124,11 +126,11 @@ describe Aruba::Api do
124
126
 
125
127
  describe '#read' do
126
128
  let(:name) { 'test.txt'}
127
- let(:path) { File.join(@aruba.current_directory, name) }
129
+ let(:path) { File.join(@aruba.aruba.current_directory, name) }
128
130
  let(:content) { 'asdf' }
129
131
 
130
132
  before :each do
131
- set_env 'HOME', File.expand_path(@aruba.current_directory)
133
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
132
134
  end
133
135
 
134
136
  context 'when does not exist' do
@@ -158,7 +160,7 @@ describe Aruba::Api do
158
160
  context 'when path contains ~' do
159
161
  let(:string) { random_string }
160
162
  let(:name) { File.join('~', string) }
161
- let(:path) { File.join(@aruba.current_directory, string) }
163
+ let(:path) { File.join(@aruba.aruba.current_directory, string) }
162
164
 
163
165
  it { expect(@aruba.read(name)).to eq [content] }
164
166
  end
@@ -168,7 +170,7 @@ describe Aruba::Api do
168
170
  let(:name) { 'test.d' }
169
171
 
170
172
  before :each do
171
- Array(path).each { |p| Dir.mkdir p }
173
+ Array(path).each { |p| Aruba::Platform.mkdir p }
172
174
  end
173
175
 
174
176
  it { expect { @aruba.read(name) }.to raise_error ArgumentError }
@@ -179,10 +181,10 @@ describe Aruba::Api do
179
181
  describe '#list' do
180
182
  let(:name) { 'test.d' }
181
183
  let(:content) { %w(subdir.1.d subdir.2.d) }
182
- let(:path) { File.join(@aruba.current_directory, name) }
184
+ let(:path) { File.join(@aruba.aruba.current_directory, name) }
183
185
 
184
186
  before :each do
185
- set_env 'HOME', File.expand_path(@aruba.current_directory)
187
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
186
188
  end
187
189
 
188
190
  context 'when does not exist' do
@@ -204,11 +206,11 @@ describe Aruba::Api do
204
206
 
205
207
  context 'when directory' do
206
208
  before :each do
207
- Array(path).each { |p| Dir.mkdir p }
209
+ Array(path).each { |p| Aruba::Platform.mkdir p }
208
210
  end
209
211
 
210
212
  before :each do
211
- Array(content).each { |p| Dir.mkdir File.join(path, p) }
213
+ Array(content).each { |p| Aruba::Platform.mkdir File.join(path, p) }
212
214
  end
213
215
 
214
216
  context 'when has subdirectories' do
@@ -222,7 +224,7 @@ describe Aruba::Api do
222
224
  context 'when path contains ~' do
223
225
  let(:string) { random_string }
224
226
  let(:name) { File.join('~', string) }
225
- let(:path) { File.join(@aruba.current_directory, string) }
227
+ let(:path) { File.join(@aruba.aruba.current_directory, string) }
226
228
 
227
229
  let(:existing_files) { @aruba.list(name) }
228
230
  let(:expected_files) { content.map { |c| File.join(string, c) } }
@@ -241,11 +243,11 @@ describe Aruba::Api do
241
243
 
242
244
  describe '#remove' do
243
245
  let(:name) { 'test.txt'}
244
- let(:path) { File.join(@aruba.current_directory, name) }
246
+ let(:path) { File.join(@aruba.aruba.current_directory, name) }
245
247
  let(:options) { {} }
246
248
 
247
249
  before :each do
248
- set_env 'HOME', File.expand_path(@aruba.current_directory)
250
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
249
251
  end
250
252
 
251
253
  context 'when file' do
@@ -264,7 +266,7 @@ describe Aruba::Api do
264
266
 
265
267
  context 'when are multiple files' do
266
268
  let(:file_name) { %w(file1 file2 file3) }
267
- let(:file_path) { %w(file1 file2 file3).map { |p| File.join(@aruba.current_directory, p) } }
269
+ let(:file_path) { %w(file1 file2 file3).map { |p| File.join(@aruba.aruba.current_directory, p) } }
268
270
 
269
271
  it_behaves_like 'a non-existing file'
270
272
  end
@@ -272,7 +274,7 @@ describe Aruba::Api do
272
274
  context 'when path contains ~' do
273
275
  let(:string) { random_string }
274
276
  let(:file_name) { File.join('~', string) }
275
- let(:file_path) { File.join(@aruba.current_directory, string) }
277
+ let(:file_path) { File.join(@aruba.aruba.current_directory, string) }
276
278
 
277
279
  it_behaves_like 'a non-existing file'
278
280
  end
@@ -284,7 +286,7 @@ describe Aruba::Api do
284
286
  end
285
287
 
286
288
  context 'when is forced to delete file' do
287
- let(:options) { { force: true } }
289
+ let(:options) { { :force => true } }
288
290
 
289
291
  it_behaves_like 'a non-existing file'
290
292
  end
@@ -296,7 +298,7 @@ describe Aruba::Api do
296
298
 
297
299
  context 'when exists' do
298
300
  before :each do
299
- Array(path).each { |p| Dir.mkdir p }
301
+ Array(path).each { |p| Aruba::Platform.mkdir p }
300
302
  end
301
303
 
302
304
  before :each do
@@ -309,7 +311,7 @@ describe Aruba::Api do
309
311
 
310
312
  context 'when are multiple directorys' do
311
313
  let(:directory_name) { %w(directory1 directory2 directory3) }
312
- let(:directory_path) { %w(directory1 directory2 directory3).map { |p| File.join(@aruba.current_directory, p) } }
314
+ let(:directory_path) { %w(directory1 directory2 directory3).map { |p| File.join(@aruba.aruba.current_directory, p) } }
313
315
 
314
316
  it_behaves_like 'a non-existing directory'
315
317
  end
@@ -317,7 +319,7 @@ describe Aruba::Api do
317
319
  context 'when path contains ~' do
318
320
  let(:string) { random_string }
319
321
  let(:directory_name) { File.join('~', string) }
320
- let(:directory_path) { File.join(@aruba.current_directory, string) }
322
+ let(:directory_path) { File.join(@aruba.aruba.current_directory, string) }
321
323
 
322
324
  it_behaves_like 'a non-existing directory'
323
325
  end
@@ -329,7 +331,7 @@ describe Aruba::Api do
329
331
  end
330
332
 
331
333
  context 'when is forced to delete directory' do
332
- let(:options) { { force: true } }
334
+ let(:options) { { :force => true } }
333
335
 
334
336
  it_behaves_like 'a non-existing directory'
335
337
  end
@@ -344,7 +346,7 @@ describe Aruba::Api do
344
346
  let(:options) { {} }
345
347
 
346
348
  before :each do
347
- set_env 'HOME', File.expand_path(@aruba.current_directory)
349
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
348
350
  end
349
351
 
350
352
  context 'when file' do
@@ -360,7 +362,7 @@ describe Aruba::Api do
360
362
 
361
363
  context 'and should be created in non-existing directory' do
362
364
  let(:name) { 'directory/test' }
363
- let(:path) { File.join(@aruba.current_directory, 'directory/test') }
365
+ let(:path) { File.join(@aruba.aruba.current_directory, 'directory/test') }
364
366
 
365
367
  it_behaves_like 'an existing file'
366
368
  end
@@ -368,14 +370,14 @@ describe Aruba::Api do
368
370
  context 'and path includes ~' do
369
371
  let(:string) { random_string }
370
372
  let(:name) { File.join('~', string) }
371
- let(:path) { File.join(@aruba.current_directory, string) }
373
+ let(:path) { File.join(@aruba.aruba.current_directory, string) }
372
374
 
373
375
  it_behaves_like 'an existing file'
374
376
  end
375
377
 
376
378
  context 'and the mtime should be set statically' do
377
379
  let(:time) { Time.parse('2014-01-01 10:00:00') }
378
- let(:options) { { mtime: Time.parse('2014-01-01 10:00:00') } }
380
+ let(:options) { { :mtime => Time.parse('2014-01-01 10:00:00') } }
379
381
 
380
382
  it_behaves_like 'an existing file'
381
383
  it { expect(File.mtime(path)).to eq time }
@@ -383,7 +385,7 @@ describe Aruba::Api do
383
385
 
384
386
  context 'and multiple file names are given' do
385
387
  let(:name) { %w(file1 file2 file3) }
386
- let(:path) { %w(file1 file2 file3).map { |p| File.join(@aruba.current_directory, p) } }
388
+ let(:path) { %w(file1 file2 file3).map { |p| File.join(@aruba.aruba.current_directory, p) } }
387
389
  it_behaves_like 'an existing file'
388
390
  end
389
391
  end
@@ -391,10 +393,10 @@ describe Aruba::Api do
391
393
 
392
394
  context 'when directory' do
393
395
  let(:name) { %w(directory1) }
394
- let(:path) { Array(name).map { |p| File.join(@aruba.current_directory, p) } }
396
+ let(:path) { Array(name).map { |p| File.join(@aruba.aruba.current_directory, p) } }
395
397
 
396
398
  context 'when exist' do
397
- before(:each) { Array(path).each { |p| FileUtils.mkdir_p p } }
399
+ before(:each) { Array(path).each { |p| Aruba::Platform.mkdir p } }
398
400
 
399
401
  before :each do
400
402
  @aruba.touch(name, options)
@@ -402,7 +404,7 @@ describe Aruba::Api do
402
404
 
403
405
  context 'and the mtime should be set statically' do
404
406
  let(:time) { Time.parse('2014-01-01 10:00:00') }
405
- let(:options) { { mtime: Time.parse('2014-01-01 10:00:00') } }
407
+ let(:options) { { :mtime => Time.parse('2014-01-01 10:00:00') } }
406
408
 
407
409
  it_behaves_like 'an existing directory'
408
410
  it { Array(path).each { |p| expect(File.mtime(p)).to eq time } }
@@ -413,7 +415,7 @@ describe Aruba::Api do
413
415
 
414
416
  describe '#absolute?' do
415
417
  let(:name) { @file_name }
416
- let(:path) { File.expand_path(File.join(@aruba.current_directory, name)) }
418
+ let(:path) { File.expand_path(File.join(@aruba.aruba.current_directory, name)) }
417
419
 
418
420
  context 'when is absolute path' do
419
421
  it { expect(@aruba).to be_absolute(path) }
@@ -426,7 +428,7 @@ describe Aruba::Api do
426
428
 
427
429
  describe '#relative?' do
428
430
  let(:name) { @file_name }
429
- let(:path) { File.expand_path(File.join(@aruba.current_directory, name)) }
431
+ let(:path) { File.expand_path(File.join(@aruba.aruba.current_directory, name)) }
430
432
 
431
433
  context 'when is absolute path' do
432
434
  it { expect(@aruba).not_to be_relative(path) }
@@ -444,7 +446,7 @@ describe Aruba::Api do
444
446
 
445
447
  context 'when exists' do
446
448
  before :each do
447
- File.write(path, '')
449
+ Aruba::Platform.write_file(path, '')
448
450
  end
449
451
 
450
452
  it { expect(@aruba).to be_exist(name) }
@@ -457,11 +459,11 @@ describe Aruba::Api do
457
459
 
458
460
  context 'when is directory' do
459
461
  let(:name) { 'test.d' }
460
- let(:path) { File.join(@aruba.current_directory, name) }
462
+ let(:path) { File.join(@aruba.aruba.current_directory, name) }
461
463
 
462
464
  context 'when exists' do
463
465
  before :each do
464
- FileUtils.mkdir_p path
466
+ Aruba::Platform.mkdir(path)
465
467
  end
466
468
 
467
469
  it { expect(@aruba).to be_exist(name) }
@@ -480,7 +482,7 @@ describe Aruba::Api do
480
482
 
481
483
  context 'when exists' do
482
484
  before :each do
483
- File.write(path, '')
485
+ Aruba::Platform.write_file(path, '')
484
486
  end
485
487
 
486
488
  it { expect(@aruba).to be_file(name) }
@@ -493,11 +495,11 @@ describe Aruba::Api do
493
495
 
494
496
  context 'when is directory' do
495
497
  let(:name) { 'test.d' }
496
- let(:path) { File.join(@aruba.current_directory, name) }
498
+ let(:path) { File.join(@aruba.aruba.current_directory, name) }
497
499
 
498
500
  context 'when exists' do
499
501
  before :each do
500
- FileUtils.mkdir_p path
502
+ Aruba::Platform.mkdir(path)
501
503
  end
502
504
 
503
505
  it { expect(@aruba).not_to be_file(name) }
@@ -516,7 +518,7 @@ describe Aruba::Api do
516
518
 
517
519
  context 'when exists' do
518
520
  before :each do
519
- File.write(path, '')
521
+ Aruba::Platform.write_file(path, '')
520
522
  end
521
523
 
522
524
  it { expect(@aruba).not_to be_directory(name) }
@@ -529,11 +531,11 @@ describe Aruba::Api do
529
531
 
530
532
  context 'when is directory' do
531
533
  let(:name) { 'test.d' }
532
- let(:path) { File.join(@aruba.current_directory, name) }
534
+ let(:path) { File.join(@aruba.aruba.current_directory, name) }
533
535
 
534
536
  context 'when exists' do
535
537
  before :each do
536
- FileUtils.mkdir_p path
538
+ Aruba::Platform.mkdir(path)
537
539
  end
538
540
 
539
541
  it { expect(@aruba).to be_directory(name) }
@@ -559,18 +561,18 @@ describe Aruba::Api do
559
561
  end
560
562
 
561
563
  context 'when source is plain file' do
562
- it { expect(destination).to be_existing_file }
564
+ it { expect(destination).to be_an_existing_file }
563
565
  end
564
566
 
565
567
  context 'when source is contains "~" in path' do
566
568
  let(:source) { '~/file.txt' }
567
- it { expect(destination).to be_existing_file }
569
+ it { expect(destination).to be_an_existing_file }
568
570
  end
569
571
 
570
572
  context 'when source is fixture' do
571
573
  let(:source) { '%/copy/file.txt' }
572
574
  let(:destination) { 'file.txt' }
573
- it { expect(destination).to be_existing_file }
575
+ it { expect(destination).to be_an_existing_file }
574
576
  end
575
577
 
576
578
  context 'when source is list of files' do
@@ -578,7 +580,7 @@ describe Aruba::Api do
578
580
  let(:destination) { 'file.d' }
579
581
  let(:destination_files) { source.map { |s| File.join(destination, s) } }
580
582
 
581
- it { expect(destination_files).to be_existing_files }
583
+ it { expect(destination_files).to all be_an_existing_file }
582
584
  end
583
585
  end
584
586
 
@@ -587,7 +589,7 @@ describe Aruba::Api do
587
589
  let(:destination) { 'dst.d' }
588
590
 
589
591
  before :each do
590
- FileUtils.mkdir_p File.join(@aruba.current_directory, source)
592
+ Aruba::Platform.mkdir(File.join(@aruba.aruba.current_directory, source))
591
593
  end
592
594
 
593
595
  before :each do
@@ -595,14 +597,14 @@ describe Aruba::Api do
595
597
  end
596
598
 
597
599
  context 'when source is single directory' do
598
- it { expect(destination).to be_existing_directory }
600
+ it { expect(destination).to be_an_existing_directory }
599
601
  end
600
602
 
601
603
  context 'when source is nested directory' do
602
604
  let(:source) { 'src.d/subdir.d' }
603
605
  let(:destination) { 'dst.d/' }
604
606
 
605
- it { expect(destination).to be_existing_directory }
607
+ it { expect(destination).to be_an_existing_directory }
606
608
  end
607
609
  end
608
610
  end
@@ -617,14 +619,14 @@ describe Aruba::Api do
617
619
  let(:destination_files) { source.map { |s| File.join(destination, s) } }
618
620
 
619
621
  before :each do
620
- FileUtils.mkdir_p File.join(@aruba.current_directory, destination)
622
+ Aruba::Platform.mkdir(File.join(@aruba.aruba.current_directory, destination))
621
623
  end
622
624
 
623
625
  before :each do
624
626
  @aruba.copy source, destination
625
627
  end
626
628
 
627
- it { source.each { |s| expect(destination_files).to be_existing_files } }
629
+ it { source.each { |s| expect(destination_files).to all be_an_existing_file } }
628
630
  end
629
631
 
630
632
  context 'when destination is not a directory' do
@@ -643,7 +645,7 @@ describe Aruba::Api do
643
645
  before(:each) { create_test_files(source) }
644
646
 
645
647
  # rubocop:disable Metrics/LineLength
646
- it { expect { @aruba.copy source, destination }.to raise_error ArgumentError, %(same file: #{File.expand_path(File.join(@aruba.current_directory, source))} and #{File.expand_path(File.join(@aruba.current_directory, destination))}) }
648
+ it { expect { @aruba.copy source, destination }.to raise_error ArgumentError, %(same file: #{File.expand_path(File.join(@aruba.aruba.current_directory, source))} and #{File.expand_path(File.join(@aruba.aruba.current_directory, destination))}) }
647
649
  # rubocop:enable Metrics/LineLength
648
650
  end
649
651
 
@@ -664,7 +666,7 @@ describe Aruba::Api do
664
666
 
665
667
  context '#absolute_path' do
666
668
  context 'when file_name is array of path names' do
667
- it { silence(:stderr) { expect(@aruba.absolute_path(['path', @file_name])).to eq File.expand_path(File.join(current_directory, 'path', @file_name)) } }
669
+ it { silence(:stderr) { expect(@aruba.absolute_path(['path', @file_name])).to eq File.expand_path(File.join(aruba.current_directory, 'path', @file_name)) } }
668
670
  end
669
671
  end
670
672
 
@@ -674,11 +676,11 @@ describe Aruba::Api do
674
676
  end
675
677
 
676
678
  context 'when path contains "."' do
677
- it { expect(@aruba.expand_path('.')).to eq File.expand_path(current_directory) }
679
+ it { expect(@aruba.expand_path('.')).to eq File.expand_path(aruba.current_directory) }
678
680
  end
679
681
 
680
682
  context 'when path contains ".."' do
681
- it { expect(@aruba.expand_path('path/..')).to eq File.expand_path(File.join(current_directory)) }
683
+ it { expect(@aruba.expand_path('path/..')).to eq File.expand_path(File.join(aruba.current_directory)) }
682
684
  end
683
685
 
684
686
  context 'when path is nil' do
@@ -690,26 +692,49 @@ describe Aruba::Api do
690
692
  end
691
693
 
692
694
  context 'when dir_path is given similar to File.expand_path ' do
693
- it { expect(@aruba.expand_path(@file_name, 'path')).to eq File.expand_path(File.join(current_directory, 'path', @file_name)) }
695
+ it { expect(@aruba.expand_path(@file_name, 'path')).to eq File.expand_path(File.join(aruba.current_directory, 'path', @file_name)) }
694
696
  end
695
697
 
696
698
  context 'when file_name contains fixtures "%" string' do
699
+ let(:runtime) { instance_double('Aruba::Runtime') }
700
+ let(:config) { double('Aruba::Config') }
701
+ let(:environment) { instance_double('Aruba::Environment') }
702
+
697
703
  let(:klass) do
698
704
  Class.new do
699
705
  include Aruba::Api
700
706
 
701
- def root_directory
702
- File.expand_path(current_directory)
707
+ attr_reader :aruba
708
+
709
+ def initialize(aruba)
710
+ @aruba = aruba
703
711
  end
704
712
  end
705
713
  end
706
714
 
707
715
  before :each do
708
- @aruba = klass.new
709
- @aruba.touch_file 'spec/fixtures/file1'
716
+ allow(config).to receive(:fixtures_path_prefix).and_return('%')
717
+ end
718
+
719
+ before :each do
720
+ allow(environment).to receive(:clear)
721
+ allow(environment).to receive(:update).and_return(environment)
722
+ allow(environment).to receive(:to_h).and_return('PATH' => aruba.current_directory.to_s)
723
+ end
724
+
725
+ before :each do
726
+ allow(runtime).to receive(:config).and_return config
727
+ allow(runtime).to receive(:environment).and_return environment
728
+ allow(runtime).to receive(:current_directory).and_return aruba.current_directory
729
+ allow(runtime).to receive(:fixtures_directory).and_return File.join(aruba.root_directory, aruba.current_directory, 'spec', 'fixtures')
710
730
  end
711
731
 
712
- it { expect(@aruba.expand_path('%/file1')).to eq File.expand_path(File.join(current_directory, 'spec', 'fixtures', 'file1')) }
732
+ before :each do
733
+ @aruba = klass.new(runtime)
734
+ @aruba.touch 'spec/fixtures/file1'
735
+ end
736
+
737
+ it { expect(@aruba.expand_path('%/file1')).to eq File.expand_path(File.join(aruba.current_directory, 'spec', 'fixtures', 'file1')) }
713
738
  end
714
739
  end
715
740
 
@@ -731,7 +756,7 @@ describe Aruba::Api do
731
756
  it "works with ~ in path name" do
732
757
  file_path = File.join('~', random_string)
733
758
 
734
- with_env 'HOME' => File.expand_path(current_directory) do
759
+ @aruba.with_environment 'HOME' => File.expand_path(aruba.current_directory) do
735
760
  @aruba.write_fixed_size_file(file_path, @file_size)
736
761
 
737
762
  expect(File.exist?(File.expand_path(file_path))).to eq true
@@ -754,7 +779,7 @@ describe Aruba::Api do
754
779
  it "works with ~ in path name" do
755
780
  file_path = File.join('~', random_string)
756
781
 
757
- with_env 'HOME' => File.expand_path(current_directory) do
782
+ @aruba.with_environment 'HOME' => File.expand_path(aruba.current_directory) do
758
783
  @aruba.write_fixed_size_file(file_path, @file_size)
759
784
  @aruba.check_file_size([[file_path, @file_size]])
760
785
  end
@@ -767,7 +792,7 @@ describe Aruba::Api do
767
792
  end
768
793
 
769
794
  describe '#filesystem_permissions' do
770
- def actuctual_permissions
795
+ def actual_permissions
771
796
  format( "%o" , File::Stat.new(file_path).mode )[-4,4]
772
797
  end
773
798
 
@@ -775,6 +800,10 @@ describe Aruba::Api do
775
800
  let(:file_path) { @file_path }
776
801
  let(:permissions) { '0655' }
777
802
 
803
+ before :each do
804
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
805
+ end
806
+
778
807
  before(:each) do
779
808
  File.open(file_path, 'w') { |f| f << "" }
780
809
  end
@@ -785,20 +814,20 @@ describe Aruba::Api do
785
814
 
786
815
  context 'when file exists' do
787
816
  context 'and permissions are given as string' do
788
- it { expect(actuctual_permissions).to eq('0655') }
817
+ it { expect(actual_permissions).to eq('0655') }
789
818
  end
790
819
 
791
820
  context 'and permissions are given as octal number' do
792
821
  let(:permissions) { 0655 }
793
- it { expect(actuctual_permissions).to eq('0655') }
822
+ it { expect(actual_permissions).to eq('0655') }
794
823
  end
795
824
 
796
825
  context 'and path has ~ in it' do
797
- let(:string) { random_string }
798
- let(:file_name) { File.join('~', string) }
799
- let(:file_path) { File.join(@aruba.current_directory, string) }
826
+ let(:path) { random_string }
827
+ let(:file_name) { File.join('~', path) }
828
+ let(:file_path) { File.join(@aruba.aruba.current_directory, path) }
800
829
 
801
- it { expect(actuctual_permissions).to eq('0655') }
830
+ it { expect(actual_permissions).to eq('0655') }
802
831
  end
803
832
  end
804
833
  end
@@ -810,7 +839,7 @@ describe Aruba::Api do
810
839
  let(:permissions) { '0655' }
811
840
 
812
841
  before :each do
813
- set_env 'HOME', File.expand_path(@aruba.current_directory)
842
+ @aruba.set_environment_variable 'HOME', File.expand_path(@aruba.aruba.current_directory)
814
843
  end
815
844
 
816
845
  before(:each) do
@@ -836,7 +865,7 @@ describe Aruba::Api do
836
865
  context 'and path includes ~' do
837
866
  let(:string) { random_string }
838
867
  let(:file_name) { File.join('~', string) }
839
- let(:file_path) { File.join(@aruba.current_directory, string) }
868
+ let(:file_path) { File.join(@aruba.aruba.current_directory, string) }
840
869
 
841
870
  it { @aruba.check_filesystem_permissions(permissions, file_name, true) }
842
871
  end
@@ -869,9 +898,9 @@ describe Aruba::Api do
869
898
 
870
899
  it "should check existence using plain match" do
871
900
  file_name = 'nested/dir/hello_world.txt'
872
- file_path = File.join(@aruba.current_directory, file_name)
901
+ file_path = File.join(@aruba.aruba.current_directory, file_name)
873
902
 
874
- FileUtils.mkdir_p File.dirname( file_path )
903
+ Aruba::Platform.mkdir(File.dirname(file_path))
875
904
  File.open(file_path, 'w') { |f| f << "" }
876
905
 
877
906
  @aruba.check_file_presence(file_name)
@@ -882,9 +911,9 @@ describe Aruba::Api do
882
911
 
883
912
  it "should check existence using regex" do
884
913
  file_name = 'nested/dir/hello_world.txt'
885
- file_path = File.join(@aruba.current_directory, file_name)
914
+ file_path = File.join(@aruba.aruba.current_directory, file_name)
886
915
 
887
- FileUtils.mkdir_p File.dirname( file_path )
916
+ Aruba::Platform.mkdir(File.dirname(file_path))
888
917
  File.open(file_path, 'w') { |f| f << "" }
889
918
 
890
919
  @aruba.check_file_presence([ /test123/ ], false )
@@ -895,9 +924,9 @@ describe Aruba::Api do
895
924
 
896
925
  it "is no problem to mix both" do
897
926
  file_name = 'nested/dir/hello_world.txt'
898
- file_path = File.join(@aruba.current_directory, file_name)
927
+ file_path = File.join(@aruba.aruba.current_directory, file_name)
899
928
 
900
- FileUtils.mkdir_p File.dirname( file_path )
929
+ Aruba::Platform.mkdir(File.dirname(file_path))
901
930
  File.open(file_path, 'w') { |f| f << "" }
902
931
 
903
932
  @aruba.check_file_presence([ file_name, /nested/ ], true )
@@ -907,8 +936,8 @@ describe Aruba::Api do
907
936
  it "works with ~ in path name" do
908
937
  file_path = File.join('~', random_string)
909
938
 
910
- with_env 'HOME' => File.expand_path(current_directory) do
911
- FileUtils.mkdir_p File.dirname(File.expand_path(file_path))
939
+ @aruba.with_environment 'HOME' => File.expand_path(@aruba.aruba.current_directory) do
940
+ Aruba::Platform.mkdir(File.dirname(File.expand_path(file_path)))
912
941
  File.open(File.expand_path(file_path), 'w') { |f| f << "" }
913
942
 
914
943
  @aruba.check_file_presence( [ file_path ], true )
@@ -972,7 +1001,7 @@ describe Aruba::Api do
972
1001
  it "works with ~ in path name" do
973
1002
  file_path = File.join('~', random_string)
974
1003
 
975
- with_env 'HOME' => File.expand_path(current_directory) do
1004
+ @aruba.with_environment 'HOME' => File.expand_path(aruba.current_directory) do
976
1005
  @aruba.write_file(file_path, "foo bar baz")
977
1006
  @aruba.check_file_content(file_path, non_matching_content, false)
978
1007
  end
@@ -993,7 +1022,7 @@ describe Aruba::Api do
993
1022
  it "works with ~ in path name" do
994
1023
  file_path = File.join('~', random_string)
995
1024
 
996
- with_env 'HOME' => File.expand_path(current_directory) do
1025
+ @aruba.with_environment 'HOME' => File.expand_path(aruba.current_directory) do
997
1026
  @aruba.write_file(file_path, "foo bar baz")
998
1027
  @aruba.check_file_content(file_path, non_matching_content, false)
999
1028
  end
@@ -1016,7 +1045,7 @@ describe Aruba::Api do
1016
1045
  it "works with ~ in path name" do
1017
1046
  file_path = File.join('~', random_string)
1018
1047
 
1019
- with_env 'HOME' => File.expand_path(current_directory) do
1048
+ @aruba.with_environment 'HOME' => File.expand_path(aruba.current_directory) do
1020
1049
  @aruba.write_file(file_path, "foo bar baz")
1021
1050
 
1022
1051
  @aruba.with_file_content file_path do |full_content|
@@ -1048,12 +1077,12 @@ describe Aruba::Api do
1048
1077
  end
1049
1078
 
1050
1079
  describe 'process environment' do
1051
- context '#with_env' do
1080
+ context '#with_environment' do
1052
1081
  it 'modifies env for block' do
1053
1082
  variable = 'THIS_IS_A_ENV_VAR'
1054
1083
  ENV[variable] = '1'
1055
1084
 
1056
- with_env variable => '0' do
1085
+ @aruba.with_environment variable => '0' do
1057
1086
  expect(ENV[variable]).to eq '0'
1058
1087
  end
1059
1088
 
@@ -1107,8 +1136,8 @@ describe Aruba::Api do
1107
1136
  end
1108
1137
  end
1109
1138
 
1110
- describe "#run_interactive" do
1111
- before(:each){@aruba.run_interactive "cat"}
1139
+ describe '#run' do
1140
+ before(:each){@aruba.run "cat"}
1112
1141
  after(:each){@aruba.stop_processes!}
1113
1142
  it "respond to input" do
1114
1143
  @aruba.type "Hello"
@@ -1147,7 +1176,7 @@ describe Aruba::Api do
1147
1176
  end
1148
1177
 
1149
1178
  describe 'fixtures' do
1150
- let(:aruba) do
1179
+ let(:api) do
1151
1180
  klass = Class.new do
1152
1181
  include Aruba::Api
1153
1182
 
@@ -1158,35 +1187,9 @@ describe Aruba::Api do
1158
1187
 
1159
1188
  klass.new
1160
1189
  end
1161
-
1162
- describe '#fixtures_directory' do
1163
- context 'when no fixtures directories exist' do
1164
- it "should raise exception" do
1165
- expect { aruba.fixtures_directory }.to raise_error
1166
- end
1167
- end
1168
-
1169
- context 'when "/features/fixtures"-directory exist' do
1170
- before(:each) { aruba.create_directory('features/fixtures') }
1171
-
1172
- it { expect(aruba.fixtures_directory).to eq expand_path('features/fixtures') }
1173
- end
1174
-
1175
- context 'when "/spec/fixtures"-directory exist' do
1176
- before(:each) { aruba.create_directory('spec/fixtures') }
1177
-
1178
- it { expect(aruba.fixtures_directory).to eq expand_path('spec/fixtures') }
1179
- end
1180
-
1181
- context 'when "/test/fixtures"-directory exist' do
1182
- before(:each) { aruba.create_directory('test/fixtures') }
1183
-
1184
- it { expect(aruba.fixtures_directory).to eq expand_path('test/fixtures') }
1185
- end
1186
- end
1187
1190
  end
1188
1191
 
1189
- describe "#set_env" do
1192
+ describe "#set_environment_variable" do
1190
1193
  after(:each) do
1191
1194
  @aruba.stop_processes!
1192
1195
  @aruba.restore_env