aruba 0.8.1 → 0.9.0.pre

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 (101) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +3 -1
  4. data/Gemfile +13 -10
  5. data/History.md +25 -7
  6. data/README.md +6 -1
  7. data/Rakefile +16 -3
  8. data/aruba.gemspec +10 -2
  9. data/bin/aruba +7 -0
  10. data/cucumber.yml +11 -2
  11. data/features/api/command/extract_text.feature +97 -0
  12. data/features/api/command/unescape_text.feature +119 -0
  13. data/features/api/core/expand_path.feature +16 -0
  14. data/features/api/{cd.feature → filesystem/cd.feature} +2 -1
  15. data/features/api/filesystem/create_directory.feature +57 -0
  16. data/features/api/filesystem/disk_usage.feature +151 -0
  17. data/features/api/filesystem/does_exist.feature +62 -0
  18. data/features/api/filesystem/is_absolute.feature +48 -0
  19. data/features/api/filesystem/is_directory.feature +53 -0
  20. data/features/api/filesystem/is_file.feature +54 -0
  21. data/features/api/filesystem/is_relative.feature +48 -0
  22. data/features/cli/console.feature +52 -0
  23. data/features/configuration/console_history_file.feature +38 -0
  24. data/features/configuration/exit_timeout.feature +2 -1
  25. data/features/configuration/fixtures_path_prefix.feature +0 -1
  26. data/features/configuration/home_directory.feature +0 -1
  27. data/features/configuration/io_timeout.feature +0 -1
  28. data/features/configuration/keep_ansi.feature +1 -2
  29. data/features/configuration/log_level.feature +38 -0
  30. data/features/configuration/physical_block_size.feature +53 -0
  31. data/features/configuration/remove_ansi_escape_sequences.feature +38 -0
  32. data/features/configuration/root_directory.feature +0 -1
  33. data/features/configuration/working_directory.feature +2 -1
  34. data/features/fixtures/cli-app/README.md +5 -0
  35. data/features/fixtures/cli-app/lib/cli/app.rb +1 -1
  36. data/features/fixtures/cli-app/spec/spec_helper.rb +1 -2
  37. data/features/fixtures/cli-app/spec/support/aruba.rb +1 -0
  38. data/features/fixtures/empty-app/lib/cli/app.rb +1 -1
  39. data/features/fixtures/empty-app/spec/spec_helper.rb +1 -1
  40. data/features/step_definitions/aruba_dev_steps.rb +12 -1
  41. data/features/support/env.rb +1 -1
  42. data/lib/aruba/announcer.rb +1 -14
  43. data/lib/aruba/api.rb +6 -6
  44. data/lib/aruba/api/command.rb +74 -12
  45. data/lib/aruba/api/core.rb +18 -11
  46. data/lib/aruba/api/deprecated.rb +60 -72
  47. data/lib/aruba/api/filesystem.rb +41 -16
  48. data/lib/aruba/aruba_logger.rb +77 -0
  49. data/lib/aruba/aruba_path.rb +33 -0
  50. data/lib/aruba/basic_configuration.rb +2 -2
  51. data/lib/aruba/cli.rb +11 -0
  52. data/lib/aruba/config.rb +13 -3
  53. data/lib/aruba/config/jruby.rb +5 -2
  54. data/lib/aruba/console.rb +66 -0
  55. data/lib/aruba/console/help.rb +33 -0
  56. data/lib/aruba/contracts/is_power_of_two.rb +15 -0
  57. data/lib/aruba/cucumber.rb +27 -10
  58. data/lib/aruba/cucumber/hooks.rb +15 -8
  59. data/lib/aruba/disk_usage_calculator.rb +7 -0
  60. data/lib/aruba/file_size.rb +52 -0
  61. data/lib/aruba/in_process.rb +1 -1
  62. data/lib/aruba/jruby.rb +1 -1
  63. data/lib/aruba/matchers/command.rb +1 -1
  64. data/lib/aruba/matchers/directory.rb +1 -1
  65. data/lib/aruba/matchers/environment.rb +1 -1
  66. data/lib/aruba/matchers/file.rb +1 -1
  67. data/lib/aruba/matchers/path.rb +1 -1
  68. data/lib/aruba/matchers/path/match_path_pattern.rb +1 -1
  69. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +1 -1
  70. data/lib/aruba/platform.rb +14 -242
  71. data/lib/aruba/{creators → platforms}/aruba_file_creator.rb +3 -3
  72. data/lib/aruba/{creators → platforms}/aruba_fixed_size_file_creator.rb +2 -2
  73. data/lib/aruba/platforms/simple_table.rb +36 -0
  74. data/lib/aruba/platforms/unix_command_string.rb +24 -0
  75. data/lib/aruba/platforms/unix_environment_variables.rb +130 -0
  76. data/lib/aruba/platforms/unix_platform.rb +226 -0
  77. data/lib/aruba/platforms/unix_which.rb +83 -0
  78. data/lib/aruba/platforms/windows_command_string.rb +23 -0
  79. data/lib/aruba/platforms/windows_environment_variables.rb +83 -0
  80. data/lib/aruba/platforms/windows_platform.rb +39 -0
  81. data/lib/aruba/platforms/windows_which.rb +104 -0
  82. data/lib/aruba/process_monitor.rb +3 -3
  83. data/lib/aruba/processes/basic_process.rb +23 -3
  84. data/lib/aruba/processes/debug_process.rb +2 -2
  85. data/lib/aruba/processes/in_process.rb +1 -1
  86. data/lib/aruba/processes/spawn_process.rb +10 -4
  87. data/lib/aruba/reporting.rb +1 -1
  88. data/lib/aruba/rspec.rb +8 -6
  89. data/lib/aruba/runtime.rb +8 -5
  90. data/lib/aruba/version.rb +1 -1
  91. data/spec/aruba/api_spec.rb +25 -23
  92. data/spec/aruba/aruba_path_spec.rb +37 -0
  93. data/spec/aruba/jruby_spec.rb +1 -1
  94. data/spec/aruba/matchers/file_spec.rb +2 -2
  95. data/spec/aruba/matchers/path_spec.rb +3 -3
  96. data/spec/aruba/platform/simple_table_spec.rb +23 -0
  97. data/spec/aruba/platform/windows_environment_variables_spec.rb +500 -0
  98. data/spec/aruba/spawn_process_spec.rb +3 -1
  99. metadata +90 -12
  100. data/lib/aruba/contracts/is_a.rb +0 -21
  101. data/lib/aruba/environment.rb +0 -121
@@ -80,7 +80,7 @@ module Aruba
80
80
  output_format :command, '$ %s'
81
81
  output_format :environment, '$ export %s=%s"'
82
82
  output_format :modified_environment, '$ export %s=%s"'
83
- output_format :full_environment, proc { |h| environment_table(h) }
83
+ output_format :full_environment, proc { |h| Aruba.platform.simple_table(h) }
84
84
  output_format :timeout, '# %s-timeout: %s seconds'
85
85
 
86
86
  # rubocop:disable Metrics/LineLength
@@ -120,19 +120,6 @@ module Aruba
120
120
  self
121
121
  end
122
122
 
123
- def environment_table(h)
124
- name_size = h.keys.max_by(&:length).length
125
- value_size = h.values.max_by(&:length).length
126
-
127
- result = []
128
-
129
- h.each do |k,v|
130
- result << format('%s => %s', k + ' ' * (name_size - k.to_s.size), v + ' ' * (value_size - v.to_s.size))
131
- end
132
-
133
- result
134
- end
135
-
136
123
  public
137
124
 
138
125
  # Reset announcer
@@ -16,7 +16,7 @@ require 'aruba/api/environment'
16
16
  require 'aruba/api/filesystem'
17
17
  require 'aruba/api/rvm'
18
18
 
19
- Aruba::Platform.require_matching_files('../matchers/**/*.rb', __FILE__)
19
+ Aruba.platform.require_matching_files('../matchers/**/*.rb', __FILE__)
20
20
 
21
21
  module Aruba
22
22
  module Api
@@ -31,11 +31,11 @@ module Aruba
31
31
  def announcer
32
32
  @announcer ||= Announcer.new(
33
33
  self,
34
- :stdout => @announce_stdout,
35
- :stderr => @announce_stderr,
36
- :dir => @announce_dir,
37
- :cmd => @announce_cmd,
38
- :env => @announce_env
34
+ :stdout => defined?(@announce_stdout),
35
+ :stderr => defined?(@announce_stderr),
36
+ :dir => defined?(@announce_dir),
37
+ :cmd => defined?(@announce_cmd),
38
+ :env => defined?(@announce_env)
39
39
  )
40
40
 
41
41
  @announcer
@@ -19,6 +19,25 @@ end
19
19
  module Aruba
20
20
  module Api
21
21
  module Commands
22
+ # Unescape text
23
+ #
24
+ # '\n' => "\n"
25
+ # '\e' => "\e"
26
+ # '\033' => "\e"
27
+ # '\"' => '"'
28
+ def unescape_text(text)
29
+ text.gsub('\n', "\n").gsub('\"', '"').gsub('\e', "\e").gsub('\033', "\e").gsub('\016', "\016").gsub('\017', "\017").gsub('\t', "\t")
30
+ end
31
+
32
+ # Remove ansi characters from text
33
+ def extract_text(text)
34
+ if Aruba::VERSION < '1'
35
+ text.gsub(/(?:\e|\033)\[\d+(?>(;\d+)*)m/, '')
36
+ else
37
+ text.gsub(/(?:\e|\033)\[\d+(?>(;\d+)*)m/, '').gsub(/\\\[|\\\]/, '').gsub(/\007|\016|\017/, '')
38
+ end
39
+ end
40
+
22
41
  # Resolve path for command using the PATH-environment variable
23
42
  #
24
43
  # @param [#to_s] program
@@ -32,7 +51,7 @@ module Aruba
32
51
  # ENV is set within this block
33
52
  path = ENV['PATH'] if path.nil?
34
53
 
35
- Aruba::Platform.which(program, path)
54
+ Aruba.platform.which(program, path)
36
55
  end
37
56
  end
38
57
 
@@ -102,7 +121,14 @@ module Aruba
102
121
  # If arg1 is exactly the same as arg2 return true, otherwise false
103
122
  def assert_exact_output(expected, actual)
104
123
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
105
- expect(Aruba::Platform.unescape(actual, aruba.config.keep_ansi)).to eq Aruba::Platform.unescape(expected, aruba.config.keep_ansi)
124
+
125
+ actual = unescape_text(actual)
126
+ actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
127
+
128
+ expected = unescape_text(expected)
129
+ expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
130
+
131
+ expect(actual).to eq expected
106
132
  end
107
133
 
108
134
  # Partial compare arg1 and arg2
@@ -111,7 +137,14 @@ module Aruba
111
137
  # If arg2 contains arg1 return true, otherwise false
112
138
  def assert_partial_output(expected, actual)
113
139
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
114
- expect(Aruba::Platform.unescape(actual, aruba.config.keep_ansi)).to include(Aruba::Platform.unescape(expected, aruba.config.keep_ansi))
140
+
141
+ actual = unescape_text(actual)
142
+ actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
143
+
144
+ expected = unescape_text(expected)
145
+ expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
146
+
147
+ expect(actual).to include expected
115
148
  end
116
149
 
117
150
  # Regex Compare arg1 and arg2
@@ -120,7 +153,14 @@ module Aruba
120
153
  # If arg2 matches arg1 return true, otherwise false
121
154
  def assert_matching_output(expected, actual)
122
155
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
123
- expect(Aruba::Platform.unescape(actual, aruba.config.keep_ansi)).to match(/#{Aruba::Platform.unescape(expected, aruba.config.keep_ansi)}/m)
156
+
157
+ actual = unescape_text(actual)
158
+ actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
159
+
160
+ expected = unescape_text(expected)
161
+ expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
162
+
163
+ expect(actual).to match Regexp.new(expected, Regexp::MULTILINE)
124
164
  end
125
165
 
126
166
  # Negative regex compare arg1 and arg2
@@ -129,28 +169,50 @@ module Aruba
129
169
  # If arg2 does not match arg1 return true, otherwise false
130
170
  def assert_not_matching_output(expected, actual)
131
171
  actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
132
- expect(Aruba::Platform.unescape(actual, aruba.config.keep_ansi)).not_to match(/#{Aruba::Platform.unescape(expected, aruba.config.keep_ansi)}/m)
172
+
173
+ actual = unescape_text(actual)
174
+ actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
175
+
176
+ expected = unescape_text(expected)
177
+ expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
178
+
179
+ expect(actual).not_to match Regexp.new(expected, Regexp::MULTILINE)
133
180
  end
134
181
 
135
182
  # Negative partial compare arg1 and arg2
136
183
  #
137
184
  # @return [TrueClass, FalseClass]
138
185
  # If arg2 does not match/include arg1 return true, otherwise false
186
+ # rubocop:disable Metrics/CyclomaticComplexity
139
187
  def assert_no_partial_output(unexpected, actual)
140
188
  actual.force_encoding(unexpected.encoding) if RUBY_VERSION >= "1.9"
189
+
190
+ actual = unescape_text(actual)
191
+ actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
192
+
141
193
  if Regexp === unexpected
142
- expect(Aruba::Platform.unescape(actual, aruba.config.keep_ansi)).not_to match unexpected
194
+ expect(actual).not_to match unexpected
143
195
  else
144
- expect(Aruba::Platform.unescape(actual, aruba.config.keep_ansi)).not_to include(unexpected)
196
+ unexpected = unescape_text(unexpected)
197
+ unexpected = extract_text(unexpected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
198
+
199
+ expect(actual).not_to include(unexpected)
145
200
  end
146
201
  end
202
+ # rubocop:enable Metrics/CyclomaticComplexity
147
203
 
148
204
  # Partial compare output of interactive command and arg1
149
205
  #
150
206
  # @return [TrueClass, FalseClass]
151
207
  # If output of interactive command includes arg1 return true, otherwise false
152
208
  def assert_partial_output_interactive(expected)
153
- Aruba::Platform.unescape(last_command.stdout, aruba.config.keep_ansi).include?(Aruba::Platform.unescape(expected, aruba.config.keep_ansi)) ? true : false
209
+ actual = unescape_text(last_command.stdout)
210
+ actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
211
+
212
+ expected = unescape_text(expected)
213
+ expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
214
+
215
+ actual.include?(expected) ? true : false
154
216
  end
155
217
 
156
218
  # Check if command succeeded and if arg1 is included in output
@@ -255,7 +317,7 @@ module Aruba
255
317
  @commands ||= []
256
318
  @commands << cmd
257
319
 
258
- cmd = Aruba::Platform.detect_ruby(cmd)
320
+ cmd = Aruba.platform.detect_ruby(cmd)
259
321
 
260
322
  announcer.announce(:directory, Dir.pwd)
261
323
  announcer.announce(:command, cmd)
@@ -264,7 +326,7 @@ module Aruba
264
326
 
265
327
  mode = if Aruba.process
266
328
  # rubocop:disable Metrics/LineLength
267
- Aruba::Platform.deprecated('The use of "Aruba.process = <process>" and "Aruba.process.main_class" is deprecated. Use "Aruba.configure { |config| config.command_launcher = :in_process|:debug|:spawn }" and "Aruba.configure { |config| config.main_class = <klass> }" instead.')
329
+ Aruba.platform.deprecated('The use of "Aruba.process = <process>" and "Aruba.process.main_class" is deprecated. Use "Aruba.configure { |config| config.command_launcher = :in_process|:debug|:spawn }" and "Aruba.configure { |config| config.main_class = <klass> }" instead.')
268
330
  # rubocop:enable Metrics/LineLength
269
331
  Aruba.process
270
332
  else
@@ -273,7 +335,7 @@ module Aruba
273
335
 
274
336
  main_class = if Aruba.process.respond_to?(:main_class) && Aruba.process.main_class
275
337
  # rubocop:disable Metrics/LineLength
276
- Aruba::Platform.deprecated('The use of "Aruba.process = <process>" and "Aruba.process.main_class" is deprecated. Use "Aruba.configure { |config| config.command_launcher = :in_process|:debug|:spawn }" and "Aruba.configure { |config| config.main_class = <klass> }" instead.')
338
+ Aruba.platform.deprecated('The use of "Aruba.process = <process>" and "Aruba.process.main_class" is deprecated. Use "Aruba.configure { |config| config.command_launcher = :in_process|:debug|:spawn }" and "Aruba.configure { |config| config.main_class = <klass> }" instead.')
277
339
  # rubocop:enable Metrics/LineLength
278
340
  Aruba.process.main_class
279
341
  else
@@ -291,7 +353,7 @@ module Aruba
291
353
 
292
354
  if aruba.config.before? :cmd
293
355
  # rubocop:disable Metrics/LineLength
294
- Aruba::Platform.deprecated('The use of "before"-hook" ":cmd" is deprecated. Use ":command" instead. Please be aware that this hook gets the command passed in not the cmdline itself. To get the commandline use "#cmd.commandline"')
356
+ Aruba.platform.deprecated('The use of "before"-hook" ":cmd" is deprecated. Use ":command" instead. Please be aware that this hook gets the command passed in not the cmdline itself. To get the commandline use "#cmd.commandline"')
295
357
  # rubocop:enable Metrics/LineLength
296
358
  aruba.config.before(:cmd, self, cmd)
297
359
  end
@@ -4,6 +4,7 @@ require 'aruba/runtime'
4
4
  require 'aruba/errors'
5
5
 
6
6
  require 'aruba/config/jruby'
7
+ require 'aruba/aruba_logger'
7
8
 
8
9
  module Aruba
9
10
  module Api
@@ -24,9 +25,9 @@ module Aruba
24
25
  # artifacts of your tests. This does NOT clean up the current working
25
26
  # directory.
26
27
  def setup_aruba
27
- Aruba::Platform.rm File.join(Aruba.config.root_directory, Aruba.config.working_directory), :force => true
28
- Aruba::Platform.mkdir File.join(Aruba.config.root_directory, Aruba.config.working_directory)
29
- Aruba::Platform.chdir Aruba.config.root_directory
28
+ Aruba.platform.rm File.join(Aruba.config.root_directory, Aruba.config.working_directory), :force => true
29
+ Aruba.platform.mkdir File.join(Aruba.config.root_directory, Aruba.config.working_directory)
30
+ Aruba.platform.chdir Aruba.config.root_directory
30
31
 
31
32
  self
32
33
  end
@@ -49,23 +50,23 @@ module Aruba
49
50
  def cd(dir, &block)
50
51
  if block_given?
51
52
  begin
52
- fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba::Platform.directory? expand_path(dir)
53
+ fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba.platform.directory? expand_path(dir)
53
54
 
54
55
  aruba.current_directory << dir
55
56
 
56
- old_dir = Aruba::Platform.getwd
57
+ old_dir = Aruba.platform.getwd
57
58
  old_oldpwd = ENV['OLDPWD']
58
59
  old_pwd = ENV['PWD']
59
60
 
60
- ENV['OLDPWD'] = Aruba::Platform.getwd
61
+ ENV['OLDPWD'] = Aruba.platform.getwd
61
62
  ENV['PWD'] = File.join(aruba.root_directory, aruba.current_directory).sub(%r{/$}, '')
62
63
 
63
- Aruba::Platform.chdir File.join(aruba.root_directory, aruba.current_directory)
64
+ Aruba.platform.chdir File.join(aruba.root_directory, aruba.current_directory)
64
65
 
65
66
  result = block.call
66
67
  ensure
67
68
  aruba.current_directory.pop
68
- Aruba::Platform.chdir old_dir
69
+ Aruba.platform.chdir old_dir
69
70
  ENV['OLDPWD'] = old_oldpwd
70
71
  ENV['PWD'] = old_pwd
71
72
  end
@@ -73,7 +74,7 @@ module Aruba
73
74
  return result
74
75
  end
75
76
 
76
- fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba::Platform.directory? expand_path(dir)
77
+ fail ArgumentError, "#{expand_path(dir)} is not a directory or does not exist." unless Aruba.platform.directory? expand_path(dir)
77
78
 
78
79
  aruba.current_directory << dir
79
80
 
@@ -115,12 +116,18 @@ module Aruba
115
116
  # rubocop:disable Metrics/MethodLength
116
117
  # rubocop:disable Metrics/CyclomaticComplexity
117
118
  def expand_path(file_name, dir_string = nil)
119
+ check_for_deprecated_variables if Aruba::VERSION < '1'
120
+
118
121
  # rubocop:disable Metrics/LineLength
119
122
  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.)
120
123
  # rubocop:enable Metrics/LineLength
121
124
 
122
125
  fail ArgumentError, message unless file_name.is_a?(String) && !file_name.empty?
123
126
 
127
+ # rubocop:disable Metrics/LineLength
128
+ aruba.logger.warn %(`aruba`'s working directory does not exist. Maybe you forgot to run `setup_aruba` before using it's API. This warning will be an error from 1.0.0) unless Aruba.platform.directory? File.join(aruba.config.root_directory, aruba.config.working_directory)
129
+ # rubocop:enable Metrics/LineLength
130
+
124
131
  if RUBY_VERSION < '1.9'
125
132
  prefix = file_name.chars.to_a[0]
126
133
  rest = file_name.chars.to_a[1..-1].join('')
@@ -157,9 +164,9 @@ module Aruba
157
164
  # The block of code which should be run with the modified environment variables
158
165
  def with_environment(env = {}, &block)
159
166
  if RUBY_VERSION <= '1.9.3'
160
- old_env = ENV.to_hash
167
+ old_env = ENV.to_hash.dup
161
168
  else
162
- old_env = ENV.to_h
169
+ old_env = ENV.to_h.dup
163
170
  end
164
171
 
165
172
  old_aruba_env = aruba.environment.to_h
@@ -8,8 +8,8 @@ module Aruba
8
8
  # @return [Array]
9
9
  # The directory path: Each subdirectory is a member of an array
10
10
  def dirs
11
- Aruba::Platform.deprecated('The use of "@dirs" is deprecated. Use "Aruba.configure { |c| c.current_directory = \'path/to/dir\' }" instead to set the "current_directory') if defined? @dirs
12
- Aruba::Platform.deprecated('The use of "dirs" deprecated. Use "Aruba.configure { |c| c.current_directory = \'path/to/dir\' }" instead to set the "current_directory and "expand_path(".")" to get the current directory or use "#cd(\'.\') { # your code }" to run code in the current directory')
11
+ Aruba.platform.deprecated('The use of "@dirs" is deprecated. Use "Aruba.configure { |c| c.current_directory = \'path/to/dir\' }" instead to set the "current_directory') if defined? @dirs
12
+ Aruba.platform.deprecated('The use of "dirs" deprecated. Use "Aruba.configure { |c| c.current_directory = \'path/to/dir\' }" instead to set the "current_directory and "expand_path(".")" to get the current directory or use "#cd(\'.\') { # your code }" to run code in the current directory')
13
13
 
14
14
  @dirs ||= aruba.current_directory
15
15
  end
@@ -20,7 +20,7 @@ module Aruba
20
20
  # @return
21
21
  # Current directory
22
22
  def current_directory
23
- Aruba::Platform.deprecated(%(The use of "current_directory" deprecated. Use "expand_path(".")" to get the current directory or "#cd" to run code in the current directory. #{caller.first}))
23
+ Aruba.platform.deprecated(%(The use of "current_directory" deprecated. Use "expand_path(".")" to get the current directory or "#cd" to run code in the current directory. #{caller.first}))
24
24
 
25
25
  aruba.current_directory.to_s
26
26
  end
@@ -28,7 +28,7 @@ module Aruba
28
28
  # @deprecated
29
29
  # Clean the current directory
30
30
  def clean_current_directory
31
- Aruba::Platform.deprecated('The use of "clean_current_directory" is deprecated. Either use "#setup_aruba" or `#remove(\'.\') to clean up aruba\'s working directory before your tests are run')
31
+ Aruba.platform.deprecated('The use of "clean_current_directory" is deprecated. Either use "#setup_aruba" or `#remove(\'.\') to clean up aruba\'s working directory before your tests are run')
32
32
 
33
33
  setup_aruba
34
34
  end
@@ -39,7 +39,7 @@ module Aruba
39
39
  # @yield
40
40
  # The block which should be run in current directory
41
41
  def in_current_directory(&block)
42
- Aruba::Platform.deprecated('The use of "in_current_directory" deprecated. Use "#cd(\'.\') { # your code }" instead. But be aware, `cd` requires a previously created directory')
42
+ Aruba.platform.deprecated('The use of "in_current_directory" deprecated. Use "#cd(\'.\') { # your code }" instead. But be aware, `cd` requires a previously created directory')
43
43
 
44
44
  create_directory '.' unless directory?('.')
45
45
  cd('.', &block)
@@ -47,42 +47,42 @@ module Aruba
47
47
 
48
48
  # @deprecated
49
49
  def detect_ruby(cmd)
50
- Aruba::Platform.deprecated('The use of "#detect_ruby" is deprecated. Use "Aruba::Platform.detect_ruby" instead')
50
+ Aruba.platform.deprecated('The use of "#detect_ruby" is deprecated')
51
51
 
52
- Aruba::Platform.detect_ruby cmd
52
+ Aruba.platform.detect_ruby cmd
53
53
  end
54
54
 
55
55
  # @deprecated
56
56
  def current_ruby
57
- Aruba::Platform.deprecated('The use of "#current_ruby" is deprecated. Use "Aruba::Platform.current_ruby" instead')
57
+ Aruba.platform.deprecated('The use of "#current_ruby" is deprecated')
58
58
 
59
- Aruba::Platform.current_ruby cmd
59
+ Aruba.platform.current_ruby cmd
60
60
  end
61
61
 
62
62
  # @deprecated
63
63
  def _ensure_newline(str)
64
- Aruba::Platform.deprecated('The use of "#_ensure_newline" is deprecated. Use "Aruba::Platform.ensure_newline" instead')
64
+ Aruba.platform.deprecated('The use of "#_ensure_newline" is deprecated')
65
65
 
66
- Aruba::Platform.ensure_newline cmd
66
+ Aruba.platform.ensure_newline cmd
67
67
  end
68
68
 
69
69
  # @deprecated
70
70
  def absolute_path(*args)
71
- Aruba::Platform.deprecated('The use of "absolute_path" is deprecated. Use "expand_path" instead. But be aware that "expand_path" uses a different implementation')
71
+ Aruba.platform.deprecated('The use of "absolute_path" is deprecated. Use "expand_path" instead. But be aware that "expand_path" uses a different implementation')
72
72
 
73
73
  File.expand_path File.join(*args), aruba.current_directory
74
74
  end
75
75
 
76
76
  # @deprecated
77
77
  def _read_interactive
78
- Aruba::Platform.deprecated('The use of "#_read_interactive" is deprecated. Please use "last_command.stdout" instead')
78
+ Aruba.platform.deprecated('The use of "#_read_interactive" is deprecated. Please use "last_command.stdout" instead')
79
79
 
80
80
  last_command.stdout
81
81
  end
82
82
 
83
83
  # @deprecated
84
84
  def announce_or_puts(msg)
85
- Aruba::Platform.deprecated('The use of "#announce_or_puts" is deprecated. Please use "#announcer.mode = :kernel" or "#announcer.mode = :puts" instead')
85
+ Aruba.platform.deprecated('The use of "#announce_or_puts" is deprecated. Please use "#announcer.mode = :kernel" or "#announcer.mode = :puts" instead')
86
86
 
87
87
  if(@puts)
88
88
  Kernel.puts(msg)
@@ -93,14 +93,14 @@ module Aruba
93
93
 
94
94
  # @deprecated
95
95
  def _write_interactive(input)
96
- Aruba::Platform.deprecated('The use of "#_write_interactive" is deprecated. Please use "#last_command.write()" instead')
96
+ Aruba.platform.deprecated('The use of "#_write_interactive" is deprecated. Please use "#last_command.write()" instead')
97
97
 
98
98
  last_command.write(input)
99
99
  end
100
100
 
101
101
  # @deprecated
102
102
  def eot
103
- Aruba::Platform.deprecated(%{\e[35m The \"#eot\"-method is deprecated. It will be deleted with the next major version. Please use \"#close_input\"-method instead.\e[0m})
103
+ Aruba.platform.deprecated(%{\e[35m The \"#eot\"-method is deprecated. It will be deleted with the next major version. Please use \"#close_input\"-method instead.\e[0m})
104
104
 
105
105
  close_input
106
106
  end
@@ -113,7 +113,7 @@ module Aruba
113
113
  # @see #cmd
114
114
  # @deprectated
115
115
  def run_interactive(cmd)
116
- Aruba::Platform.deprecated('The use of "#run_interactive" is deprecated. You can simply use "run" instead')
116
+ Aruba.platform.deprecated('The use of "#run_interactive" is deprecated. You can simply use "run" instead')
117
117
 
118
118
  run(cmd)
119
119
  end
@@ -124,14 +124,14 @@ module Aruba
124
124
  # @param [String] file_name
125
125
  # The name of the file
126
126
  def touch_file(*args)
127
- Aruba::Platform.deprecated('The use of "#touch_file" is deprecated. Use "#touch" instead')
127
+ Aruba.platform.deprecated('The use of "#touch_file" is deprecated. Use "#touch" instead')
128
128
 
129
129
  touch(*args)
130
130
  end
131
131
 
132
132
  # @deprecated
133
133
  def mod?(file, perms, &block)
134
- Aruba::Platform.deprecated('The use of "#mod?" is deprecated. Use "expect().to have_permissions()" instead')
134
+ Aruba.platform.deprecated('The use of "#mod?" is deprecated. Use "expect().to have_permissions()" instead')
135
135
 
136
136
  expect(Array(file)).to all have_permissions(perms)
137
137
  end
@@ -142,14 +142,14 @@ module Aruba
142
142
  # @param [String] file_name
143
143
  # The file which should be deleted in current directory
144
144
  def remove_file(*args)
145
- Aruba::Platform.deprecated('The use of "#remove_file" is deprecated. Use "#remove" instead')
145
+ Aruba.platform.deprecated('The use of "#remove_file" is deprecated. Use "#remove" instead')
146
146
 
147
147
  remove(*args)
148
148
  end
149
149
 
150
150
  # @deprecated
151
151
  def create_dir(*args)
152
- Aruba::Platform.deprecated('The use of "#create_dir" is deprecated. Use "#create_directory" instead')
152
+ Aruba.platform.deprecated('The use of "#create_dir" is deprecated. Use "#create_directory" instead')
153
153
  create_directory(*args)
154
154
  end
155
155
 
@@ -159,13 +159,13 @@ module Aruba
159
159
  # @param [String] directory_name
160
160
  # The name of the directory which should be removed
161
161
  def remove_directory(*args)
162
- Aruba::Platform.deprecated('The use of "remove_directory" is deprecated. Use "remove" instead')
162
+ Aruba.platform.deprecated('The use of "remove_directory" is deprecated. Use "remove" instead')
163
163
  remove(*args)
164
164
  end
165
165
 
166
166
  # @deprecated
167
167
  def remove_dir(*args)
168
- Aruba::Platform.deprecated('The use of "remove_dir" is deprecated. Use "remove" instead')
168
+ Aruba.platform.deprecated('The use of "remove_dir" is deprecated. Use "remove" instead')
169
169
  remove(*args)
170
170
  end
171
171
 
@@ -179,7 +179,7 @@ module Aruba
179
179
  # @param [true,false] expect_presence
180
180
  # Should the given paths be present (true) or absent (false)
181
181
  def check_file_presence(paths, expect_presence = true)
182
- Aruba::Platform.deprecated('The use of "check_file_presence" is deprecated. Use "expect().to be_existing_file or expect(all_paths).to match_path_pattern() instead" ')
182
+ Aruba.platform.deprecated('The use of "check_file_presence" is deprecated. Use "expect().to be_an_existing_file" or "expect(all_paths).to all match /pattern/" instead')
183
183
 
184
184
  stop_processes!
185
185
 
@@ -215,7 +215,7 @@ module Aruba
215
215
  # check_file_size(paths_and_sizes)
216
216
  #
217
217
  def check_file_size(paths_and_sizes)
218
- Aruba::Platform.deprecated('The use of "#check_file_size" is deprecated. Use "expect(file).to have_file_size(size)", "expect(all_files).to all have_file_size(1)", "expect(all_files).to include a_file_with_size(1)" instead')
218
+ Aruba.platform.deprecated('The use of "#check_file_size" is deprecated. Use "expect(file).to have_file_size(size)", "expect(all_files).to all have_file_size(1)", "expect(all_files).to include a_file_with_size(1)" instead')
219
219
  stop_processes!
220
220
 
221
221
  paths_and_sizes.each do |path, size|
@@ -225,7 +225,7 @@ module Aruba
225
225
 
226
226
  # @deprecated
227
227
  def check_exact_file_content(file, exact_content, expect_match = true)
228
- Aruba::Platform.deprecated('The use of "#check_exact_file_content" is deprecated. Use "expect(file).to have_file_content(content)" with a string')
228
+ Aruba.platform.deprecated('The use of "#check_exact_file_content" is deprecated. Use "expect(file).to have_file_content(content)" with a string')
229
229
 
230
230
  check_file_content(file, exact_content, expect_match)
231
231
  end
@@ -242,7 +242,7 @@ module Aruba
242
242
  # @param [true, false] expect_match
243
243
  # Must the content be in the file or not
244
244
  def check_binary_file_content(file, reference_file, expect_match = true)
245
- Aruba::Platform.deprecated('The use of "#check_binary_file_content" is deprecated. Use "expect(file).to have_same_file_content_like(file)"')
245
+ Aruba.platform.deprecated('The use of "#check_binary_file_content" is deprecated. Use "expect(file).to have_same_file_content_like(file)"')
246
246
 
247
247
  stop_processes!
248
248
 
@@ -262,7 +262,7 @@ module Aruba
262
262
  # @param [true, false] expect_presence
263
263
  # Should the directory be there or should the directory not be there
264
264
  def check_directory_presence(paths, expect_presence)
265
- Aruba::Platform.deprecated('The use of "#check_directory_presence" is deprecated. Use "expect(directory).to be_an_existing_directory"')
265
+ Aruba.platform.deprecated('The use of "#check_directory_presence" is deprecated. Use "expect(directory).to be_an_existing_directory"')
266
266
 
267
267
  stop_processes!
268
268
 
@@ -279,15 +279,15 @@ module Aruba
279
279
 
280
280
  # @deprecated
281
281
  def prep_for_fs_check(&block)
282
- Aruba::Platform.deprecated('The use of "prep_for_fs_check" is deprecated. Use apropriate methods and the new rspec matchers instead')
282
+ Aruba.platform.deprecated('The use of "prep_for_fs_check" is deprecated. Use apropriate methods and the new rspec matchers instead')
283
283
 
284
284
  process_monitor.stop_processes!
285
- cd('') { block.call }
285
+ cd('.') { block.call }
286
286
  end
287
287
 
288
288
  # @deprecated
289
289
  def assert_exit_status_and_partial_output(expect_to_pass, expected)
290
- Aruba::Platform.deprecated('The use of "assert_exit_status_and_partial_output" is deprecated. Use "#assert_access" and "#assert_partial_output" instead')
290
+ Aruba.platform.deprecated('The use of "assert_exit_status_and_partial_output" is deprecated. Use "#assert_access" and "#assert_partial_output" instead')
291
291
 
292
292
  assert_success(expect_to_pass)
293
293
  assert_partial_output(expected, all_output)
@@ -320,7 +320,7 @@ module Aruba
320
320
  # @param [true, false] expect_match
321
321
  # Must the content be in the file or not
322
322
  def check_file_content(file, content, expect_match = true)
323
- Aruba::Platform.deprecated('The use of "#check_file_content" is deprecated. Use "expect(file).to have_file_content(content)" instead. For eq match use string, for partial match use /regex/')
323
+ Aruba.platform.deprecated('The use of "#check_file_content" is deprecated. Use "expect(file).to have_file_content(content)" instead. For eq match use string, for partial match use /regex/')
324
324
 
325
325
  stop_processes!
326
326
 
@@ -333,35 +333,35 @@ module Aruba
333
333
 
334
334
  # @deprecated
335
335
  def _mkdir(dir_name)
336
- Aruba::Platform.deprecated('The use of "#_mkdir" is deprecated')
336
+ Aruba.platform.deprecated('The use of "#_mkdir" is deprecated')
337
337
 
338
- Aruba::Platform.mkdir(dir_name)
338
+ Aruba.platform.mkdir(dir_name)
339
339
  end
340
340
 
341
341
  # @deprecated
342
342
  def _rm(dir_name)
343
- Aruba::Platform.deprecated('The use of "#_rm_rf" is deprecated')
343
+ Aruba.platform.deprecated('The use of "#_rm_rf" is deprecated')
344
344
 
345
- Aruba::Platform.rm(dir_name)
345
+ Aruba.platform.rm(dir_name)
346
346
  end
347
347
 
348
348
  # @deprecated
349
349
  def current_dir(*args, &block)
350
- Aruba::Platform.deprecated('The use of "#current_dir" is deprecated. Use "#current_directory" instead')
350
+ Aruba.platform.deprecated('The use of "#current_dir" is deprecated. Use "#current_directory" instead')
351
351
 
352
352
  current_directory(*args, &block)
353
353
  end
354
354
 
355
355
  # @deprecated
356
356
  def clean_current_dir(*args, &block)
357
- Aruba::Platform.deprecated('The use of "clean_current_dir" is deprecated. Either use "#setup_aruba" or `#remove(\'.\') to clean up aruba\'s working directory before your tests are run')
357
+ Aruba.platform.deprecated('The use of "clean_current_dir" is deprecated. Either use "#setup_aruba" or `#remove(\'.\') to clean up aruba\'s working directory before your tests are run')
358
358
 
359
359
  setup_aruba
360
360
  end
361
361
 
362
362
  # @deprecated
363
363
  def in_current_dir(&block)
364
- Aruba::Platform.deprecated('The use of "in_current_dir" is deprecated. Use "#cd(\'.\') { }" instead')
364
+ Aruba.platform.deprecated('The use of "in_current_dir" is deprecated. Use "#cd(\'.\') { }" instead')
365
365
 
366
366
  create_directory '.' unless directory?('.')
367
367
  cd('.', &block)
@@ -376,7 +376,7 @@ module Aruba
376
376
  # @yield
377
377
  # The block of code which should be run with the modified environment variables
378
378
  def with_env(env = {}, &block)
379
- Aruba::Platform.deprecated('The use of "#with_env" is deprecated. Use "#with_environment {}" instead. But be careful this uses a different implementation')
379
+ Aruba.platform.deprecated('The use of "#with_env" is deprecated. Use "#with_environment {}" instead. But be careful this uses a different implementation')
380
380
 
381
381
  env.each do |k,v|
382
382
  set_env k, v
@@ -389,7 +389,7 @@ module Aruba
389
389
  # Restore original process environment
390
390
  def restore_env
391
391
  # No output because we need to reset env on each scenario/spec run
392
- # Aruba::Platform.deprecated('The use of "#restore_env" is deprecated. If you use "set_environment_variable" there\'s no need to restore the environment')
392
+ # Aruba.platform.deprecated('The use of "#restore_env" is deprecated. If you use "set_environment_variable" there\'s no need to restore the environment')
393
393
 
394
394
  original_env.each do |key, value|
395
395
  if value
@@ -409,7 +409,7 @@ module Aruba
409
409
  # @param [String] value
410
410
  # The value of the environment variable. Needs to be a string.
411
411
  def set_env(key, value)
412
- Aruba::Platform.deprecated('The use of "#set_env" is deprecated. Please use "set_environment_variable" instead. But be careful, this method uses a different kind of implementation')
412
+ Aruba.platform.deprecated('The use of "#set_env" is deprecated. Please use "set_environment_variable" instead. But be careful, this method uses a different kind of implementation')
413
413
 
414
414
  announcer.announce(:environment, key, value)
415
415
  original_env[key] = ENV.delete(key) unless original_env.key? key
@@ -418,14 +418,14 @@ module Aruba
418
418
 
419
419
  # @deprecated
420
420
  def original_env
421
- # Aruba::Platform.deprecated('The use of "#original_env" is deprecated.')
421
+ # Aruba.platform.deprecated('The use of "#original_env" is deprecated')
422
422
 
423
423
  @original_env ||= {}
424
424
  end
425
425
 
426
426
  # @deprecated
427
427
  def filesystem_permissions(*args)
428
- Aruba::Platform.deprecated('The use of "#filesystem_permissions" is deprecated. Please use "#chmod" instead.')
428
+ Aruba.platform.deprecated('The use of "#filesystem_permissions" is deprecated. Please use "#chmod" instead')
429
429
 
430
430
  chmod(*args)
431
431
  end
@@ -439,7 +439,7 @@ module Aruba
439
439
  # @param [Boolean] expected_result
440
440
  # Are the permissions expected to be mode or are they expected not to be mode?
441
441
  def check_filesystem_permissions(*args)
442
- Aruba::Platform.deprecated('The use of "#check_filesystem_permissions" is deprecated. Please use "expect().to have_permissions perms" instead.')
442
+ Aruba.platform.deprecated('The use of "#check_filesystem_permissions" is deprecated. Please use "expect().to have_permissions perms" instead')
443
443
 
444
444
  args = args.flatten
445
445
 
@@ -459,7 +459,7 @@ module Aruba
459
459
 
460
460
  # @deprecated
461
461
  def _create_file(name, content, check_presence)
462
- Aruba::Platform.deprecated('The use of "#_create_file" is deprecated. It will be removed soon.')
462
+ Aruba.platform.deprecated('The use of "#_create_file" is deprecated. It will be removed soon')
463
463
 
464
464
  ArubaFileCreator.new.write(expand_path(name), content, check_presence)
465
465
 
@@ -468,7 +468,7 @@ module Aruba
468
468
 
469
469
  # @deprecated
470
470
  def _create_fixed_size_file(file_name, file_size, check_presence)
471
- Aruba::Platform.deprecated('The use of "#_create_fixed_size_file" is deprecated. It will be removed soon.')
471
+ Aruba.platform.deprecated('The use of "#_create_fixed_size_file" is deprecated. It will be removed soon')
472
472
 
473
473
  ArubaFixedSizeFileCreator.new.write(expand_path(name), size, check_presence)
474
474
 
@@ -483,16 +483,19 @@ module Aruba
483
483
  #
484
484
  # @return
485
485
  # The string stripped from escape sequences
486
- def unescape(string)
487
- Aruba::Platform.deprecated('The use of "#unescape" is deprecated. Use "Aruba::Platform.unescape" instead')
486
+ def unescape(string, keep_ansi = false)
487
+ Aruba.platform.deprecated('The use of "#unescape" is deprecated. Please use "#unescape_text" and "#extract_text" intead')
488
488
 
489
- Aruba::Platform.unescape(string, aruba.config.keep_ansi)
489
+ string = unescape_text(string)
490
+ string = extract_text(string) if !keep_ansi || !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
491
+
492
+ string
490
493
  end
491
494
 
492
495
  # @deprecated
493
496
  # The root directory of aruba
494
497
  def root_directory
495
- Aruba::Platform.deprecated('The use of "#root_directory" is deprecated. Use "aruba.root_directory" instead')
498
+ Aruba.platform.deprecated('The use of "#root_directory" is deprecated. Use "aruba.root_directory" instead')
496
499
 
497
500
  aruba.root_directory
498
501
  end
@@ -502,7 +505,7 @@ module Aruba
502
505
  # @return [String]
503
506
  # The directory to where your fixtures are stored
504
507
  def fixtures_directory
505
- Aruba::Platform.deprecated('The use of "#fixtures_directory" is deprecated. Use "aruba.fixtures_directory" instead')
508
+ Aruba.platform.deprecated('The use of "#fixtures_directory" is deprecated. Use "aruba.fixtures_directory" instead')
506
509
 
507
510
  aruba.fixtures_directory
508
511
  end
@@ -512,33 +515,18 @@ module Aruba
512
515
  # rubocop:disable Metrics/MethodLength
513
516
  def check_for_deprecated_variables
514
517
  if defined? @aruba_io_wait_seconds
515
- Aruba::Platform.deprecated('The use of "@aruba_io_wait_seconds" is deprecated. Use "#aruba.config.io_wait_timeout = <numeric>" instead')
518
+ Aruba.platform.deprecated('The use of "@aruba_io_wait_seconds" is deprecated. Use "#aruba.config.io_wait_timeout = <numeric>" instead')
516
519
  aruba.config.io_wait_timeout = @aruba_io_wait_seconds
517
520
  end
518
521
 
519
- if root_directory != aruba.config.root_directory
520
- Aruba::Platform.deprecated('Overwriting of methods for configuration is deprecated. Use "#aruba.config.root_directory = <string>" instead')
521
- aruba.config.root_directory = root_directory
522
- end
523
-
524
- if current_directory != aruba.config.current_directory
525
- Aruba::Platform.deprecated('Overwriting of methods for configuration is deprecated. Use "#aruba.config.current_directory = <string>" instead')
526
- aruba.config.current_directory = current_directory
527
- end
528
-
529
522
  if defined? @keep_ansi
530
- Aruba::Platform.deprecated('The use of "@aruba_keep_ansi" is deprecated. Use "#aruba.config.keep_ansi = <true|false>" instead')
531
- aruba.config.keep_ansi = @keep_ansi
523
+ Aruba.platform.deprecated('The use of "@aruba_keep_ansi" is deprecated. Use "#aruba.config.remove_ansi_escape_sequences = <true|false>" instead. Be aware that it uses an inverted logic')
524
+ aruba.config.remove_ansi_escape_sequences = false
532
525
  end
533
526
 
534
527
  if defined? @aruba_root_directory
535
- Aruba::Platform.deprecated('The use of "@aruba_root_directory" is deprecated. Use "#aruba.config.root_directory = <string>" instead')
536
- aruba.config.keep_ansi = @aruba_root_directory
537
- end
538
-
539
- if root_directory != aruba.config.root_directory
540
- Aruba::Platform.deprecated('Overwriting of methods for configuration of "root_directory" is deprecated.')
541
- aruba.config.root_directory = root_directory
528
+ Aruba.platform.deprecated('The use of "@aruba_root_directory" is deprecated. Use "#aruba.config.root_directory = <string>" instead')
529
+ aruba.config.root_directory = @aruba_root_directory.to_s
542
530
  end
543
531
  end
544
532
  # rubocop:enable Metrics/CyclomaticComplexity