aruba 1.0.0.pre.alpha.2 → 1.0.0.pre.alpha.3

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 (113) hide show
  1. checksums.yaml +5 -5
  2. data/.github/PULL_REQUEST_TEMPLATE.md +2 -1
  3. data/.rubocop.yml +6 -181
  4. data/.rubocop_todo.yml +364 -0
  5. data/.travis.yml +63 -34
  6. data/.yardopts +3 -0
  7. data/CHANGELOG.md +1121 -0
  8. data/CONTRIBUTING.md +179 -78
  9. data/Gemfile +29 -44
  10. data/README.md +41 -11
  11. data/Rakefile +35 -35
  12. data/appveyor.yml +6 -5
  13. data/aruba.gemspec +14 -16
  14. data/bin/console +2 -11
  15. data/cucumber.yml +0 -7
  16. data/fixtures/cli-app/README.md +1 -1
  17. data/fixtures/cli-app/Rakefile +1 -1
  18. data/fixtures/cli-app/cli-app.gemspec +1 -0
  19. data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +3 -3
  20. data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
  21. data/fixtures/empty-app/Rakefile +1 -1
  22. data/fixtures/empty-app/cli-app.gemspec +1 -0
  23. data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
  24. data/fixtures/getting-started-app/Gemfile +1 -1
  25. data/lib/aruba/api.rb +3 -10
  26. data/lib/aruba/api/bundler.rb +16 -0
  27. data/lib/aruba/api/commands.rb +249 -0
  28. data/lib/aruba/api/core.rb +24 -10
  29. data/lib/aruba/api/environment.rb +12 -7
  30. data/lib/aruba/api/filesystem.rb +22 -20
  31. data/lib/aruba/api/text.rb +3 -9
  32. data/lib/aruba/aruba_path.rb +3 -18
  33. data/lib/aruba/basic_configuration.rb +3 -19
  34. data/lib/aruba/cli.rb +1 -1
  35. data/lib/aruba/colorizer.rb +33 -33
  36. data/lib/aruba/command.rb +4 -0
  37. data/lib/aruba/config_wrapper.rb +1 -1
  38. data/lib/aruba/configuration.rb +78 -0
  39. data/lib/aruba/console.rb +5 -5
  40. data/lib/aruba/console/help.rb +1 -1
  41. data/lib/aruba/cucumber.rb +0 -1
  42. data/lib/aruba/cucumber/command.rb +55 -115
  43. data/lib/aruba/cucumber/environment.rb +1 -1
  44. data/lib/aruba/cucumber/file.rb +9 -21
  45. data/lib/aruba/cucumber/hooks.rb +6 -62
  46. data/lib/aruba/event_bus/name_resolver.rb +1 -2
  47. data/lib/aruba/hooks.rb +1 -1
  48. data/lib/aruba/initializer.rb +3 -3
  49. data/lib/aruba/matchers/base/base_matcher.rb +2 -2
  50. data/lib/aruba/matchers/base/message_indenter.rb +19 -0
  51. data/lib/aruba/matchers/base/object_formatter.rb +2 -2
  52. data/lib/aruba/matchers/collection/include_an_object.rb +7 -9
  53. data/lib/aruba/matchers/command/be_successfully_executed.rb +2 -4
  54. data/lib/aruba/matchers/command/have_exit_status.rb +1 -1
  55. data/lib/aruba/matchers/command/have_finished_in_time.rb +2 -4
  56. data/lib/aruba/matchers/command/have_output.rb +9 -4
  57. data/lib/aruba/matchers/command/have_output_on_stderr.rb +1 -1
  58. data/lib/aruba/matchers/command/have_output_on_stdout.rb +1 -1
  59. data/lib/aruba/matchers/command/have_output_size.rb +1 -1
  60. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +4 -6
  61. data/lib/aruba/matchers/directory/have_sub_directory.rb +4 -6
  62. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
  63. data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
  64. data/lib/aruba/matchers/file/be_an_existing_file.rb +4 -6
  65. data/lib/aruba/matchers/file/have_file_content.rb +4 -4
  66. data/lib/aruba/matchers/file/have_file_size.rb +6 -8
  67. data/lib/aruba/matchers/file/have_same_file_content.rb +9 -12
  68. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
  69. data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
  70. data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
  71. data/lib/aruba/matchers/path/have_permissions.rb +6 -8
  72. data/lib/aruba/matchers/string/include_output_string.rb +8 -10
  73. data/lib/aruba/matchers/string/match_output_string.rb +9 -11
  74. data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
  75. data/lib/aruba/platform.rb +0 -1
  76. data/lib/aruba/platforms/announcer.rb +26 -70
  77. data/lib/aruba/platforms/aruba_file_creator.rb +1 -1
  78. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +2 -2
  79. data/lib/aruba/platforms/aruba_logger.rb +22 -2
  80. data/lib/aruba/platforms/command_monitor.rb +2 -125
  81. data/lib/aruba/platforms/filesystem_status.rb +9 -9
  82. data/lib/aruba/platforms/local_environment.rb +2 -2
  83. data/lib/aruba/platforms/simple_table.rb +3 -3
  84. data/lib/aruba/platforms/unix_command_string.rb +7 -4
  85. data/lib/aruba/platforms/unix_environment_variables.rb +9 -13
  86. data/lib/aruba/platforms/unix_platform.rb +2 -27
  87. data/lib/aruba/platforms/unix_which.rb +2 -1
  88. data/lib/aruba/platforms/windows_command_string.rb +20 -7
  89. data/lib/aruba/platforms/windows_environment_variables.rb +35 -30
  90. data/lib/aruba/platforms/windows_which.rb +4 -3
  91. data/lib/aruba/processes/basic_process.rb +11 -15
  92. data/lib/aruba/processes/debug_process.rb +5 -0
  93. data/lib/aruba/processes/in_process.rb +17 -8
  94. data/lib/aruba/processes/spawn_process.rb +35 -23
  95. data/lib/aruba/rspec.rb +9 -22
  96. data/lib/aruba/runtime.rb +7 -5
  97. data/lib/aruba/setup.rb +6 -4
  98. data/lib/aruba/tasks/docker_helpers.rb +1 -1
  99. data/lib/aruba/version.rb +1 -1
  100. metadata +37 -57
  101. data/History.md +0 -612
  102. data/bin/bootstrap +0 -34
  103. data/fixtures/spawn_process/stderr.sh +0 -3
  104. data/lib/aruba/api/command.rb +0 -309
  105. data/lib/aruba/api/deprecated.rb +0 -895
  106. data/lib/aruba/api/rvm.rb +0 -44
  107. data/lib/aruba/config.rb +0 -101
  108. data/lib/aruba/cucumber/rvm.rb +0 -3
  109. data/lib/aruba/in_process.rb +0 -14
  110. data/lib/aruba/jruby.rb +0 -4
  111. data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
  112. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
  113. data/lib/aruba/spawn_process.rb +0 -11
@@ -15,7 +15,7 @@ module Aruba
15
15
  # @param [Object] content
16
16
  # The content of the file
17
17
  #
18
- # @param [TrueClass, FalseClass] check_presence (false)
18
+ # @param [Boolean] check_presence (false)
19
19
  # Check if file exist
20
20
  def call(path, content, check_presence = false)
21
21
  fail "Expected #{path} to be present" if check_presence && !Aruba.platform.file?(path)
@@ -19,14 +19,14 @@ module Aruba
19
19
  # @param [Numeric] size
20
20
  # The size of the file
21
21
  #
22
- # @param [TrueClass, FalseClass] check_presence (false)
22
+ # @param [Boolean] check_presence (false)
23
23
  # Check if file exist
24
24
  def call(path, size, check_presence)
25
25
  fail "Expected #{path} to be present" if check_presence && !Aruba.platform.file?(path)
26
26
 
27
27
  Aruba.platform.mkdir(File.dirname(path))
28
28
 
29
- File.open(path, "wb"){ |f| f.seek(size - 1); f.write("\0") }
29
+ File.open(path, 'wb') { |f| f.seek(size - 1); f.write("\0") }
30
30
 
31
31
  self
32
32
  end
@@ -10,12 +10,32 @@ module Aruba
10
10
 
11
11
  # Create logger
12
12
  #
13
- # @param [Logger] logger (::Logger.new( $stderr ))
14
- # The logger with should be used to output data
13
+ # @param [Hash] opts
14
+ # Options
15
+ #
16
+ # @option opts [Symbol] :default_mode Log level
15
17
  def initialize(opts = {})
16
18
  @mode = opts.fetch(:default_mode, :info)
17
19
  end
18
20
 
21
+ # @!method fatal(msg)
22
+ # Log a fatal level log message
23
+
24
+ # @!method warn(msg)
25
+ # Log a warn level log message
26
+
27
+ # @!method debug(msg)
28
+ # Log a debug level log message
29
+
30
+ # @!method info(msg)
31
+ # Log an info level log message
32
+
33
+ # @!method error(msg)
34
+ # Log an error level log message
35
+
36
+ # @!method unknown(msg)
37
+ # Log an unknown level log message
38
+
19
39
  [:fatal, :warn, :debug, :info, :error, :unknown].each do |m|
20
40
  define_method m do |msg|
21
41
  logger.public_send m, msg
@@ -40,23 +40,11 @@ module Aruba
40
40
 
41
41
  @last_command_stopped = DefaultLastCommandStopped.new
42
42
  @last_command_started = DefaultLastCommandStarted.new
43
-
44
43
  rescue KeyError => e
45
44
  raise ArgumentError, e.message
46
45
  end
47
46
 
48
- if Aruba::VERSION < '1'
49
- # Return the last command stopped
50
- def last_command_stopped
51
- return @last_command_stopped unless @last_command_stopped.nil?
52
-
53
- registered_commands.each(&:stop)
54
-
55
- @last_command_stopped
56
- end
57
- else
58
- attr_reader :last_command_stopped
59
- end
47
+ attr_reader :last_command_stopped
60
48
 
61
49
  # Set last command started
62
50
  #
@@ -66,7 +54,7 @@ module Aruba
66
54
  @last_command_started = find(cmd)
67
55
  end
68
56
 
69
- # Set last command started
57
+ # Set last command stopped
70
58
  #
71
59
  # @param [String] cmd
72
60
  # The commandline of the command
@@ -95,117 +83,6 @@ module Aruba
95
83
  self
96
84
  end
97
85
 
98
- # @deprecated
99
- # Fetch output (stdout, stderr) from command
100
- #
101
- # @param [String] cmd
102
- # The command
103
- def output_from(cmd)
104
- cmd = Aruba.platform.detect_ruby(cmd)
105
- find(cmd).output
106
- end
107
-
108
- # @deprecated
109
- # Fetch stdout from command
110
- #
111
- # @param [String] cmd
112
- # The command
113
- def stdout_from(cmd)
114
- cmd = Aruba.platform.detect_ruby(cmd)
115
- find(cmd).stdout
116
- end
117
-
118
- # @deprecated
119
- # Fetch stderr from command
120
- #
121
- # @param [String] cmd
122
- # The command
123
- def stderr_from(cmd)
124
- cmd = Aruba.platform.detect_ruby(cmd)
125
- find(cmd).stderr
126
- end
127
-
128
- # @deprecated
129
- # Get stdout of all commands
130
- #
131
- # @return [String]
132
- # The stdout of all command which have run before
133
- def all_stdout
134
- registered_commands.each(&:stop)
135
-
136
- registered_commands.each_with_object("".dup) { |e, a| a << e.stdout }
137
- end
138
-
139
- # @deprecated
140
- # Get stderr of all commands
141
- #
142
- # @return [String]
143
- # The stderr of all command which have run before
144
- def all_stderr
145
- registered_commands.each(&:stop)
146
-
147
- registered_commands.each_with_object("".dup) { |e, a| a << e.stderr }
148
- end
149
-
150
- # @deprecated
151
- # Get stderr and stdout of all commands
152
- #
153
- # @return [String]
154
- # The stderr and stdout of all command which have run before
155
- def all_output
156
- all_stdout << all_stderr
157
- end
158
-
159
- # @deprecated
160
- def last_exit_status
161
- Aruba.platform.deprecated('The use of "#last_exit_status" is deprecated. Use "last_command_(started|stopped).exit_status" instead')
162
-
163
- return @last_exit_status if @last_exit_status
164
- registered_commands.each(&:stop)
165
- @last_exit_status
166
- end
167
-
168
- # @deprecated
169
- def stop_process(process)
170
- @last_command_stopped = process
171
- @last_exit_status = process.stop(announcer)
172
- end
173
-
174
- # @deprecated
175
- def terminate_process!(process)
176
- process.terminate
177
- end
178
-
179
- # @deprecated
180
- def stop_processes!
181
- Aruba.platform.deprecated('The use of "#stop_processes!" is deprecated.')
182
-
183
- registered_commands.each(&:stop)
184
- end
185
-
186
- # @deprecated
187
- # Terminate all running processes
188
- def terminate_processes
189
- Aruba.platform.deprecated('The use of "#terminate_processes" is deprecated.')
190
-
191
- registered_commands.each(&:terminate)
192
- end
193
-
194
- # @deprecated
195
- def only_processes
196
- Aruba.platform.deprecated('The use of "#only_processes" is deprecated.')
197
-
198
- registered_commands
199
- end
200
-
201
- # @deprecated
202
- def get_process(wanted)
203
- command = find(wanted)
204
- raise ArgumentError.new("No process named '#{wanted}' has been started") unless command
205
-
206
- command
207
- end
208
-
209
86
  # Register command to monitor
210
87
  def register_command(cmd)
211
88
  registered_commands << cmd
@@ -30,7 +30,7 @@ module Aruba
30
30
 
31
31
  # Return permissions
32
32
  def mode
33
- format("%o", status.mode)[-4,4].gsub(/^0*/, '')
33
+ format('%o', status.mode)[-4, 4].gsub(/^0*/, '')
34
34
  end
35
35
 
36
36
  # Return owner
@@ -49,14 +49,14 @@ module Aruba
49
49
  # A hash of values
50
50
  def to_h
51
51
  {
52
- :owner => owner,
53
- :group => group,
54
- :mode => mode,
55
- :executable => executable?,
56
- :ctime => ctime,
57
- :atime => atime,
58
- :mtime => mtime,
59
- :size => size
52
+ owner: owner,
53
+ group: group,
54
+ mode: mode,
55
+ executable: executable?,
56
+ ctime: ctime,
57
+ atime: atime,
58
+ mtime: mtime,
59
+ size: size
60
60
  }
61
61
  end
62
62
  end
@@ -13,8 +13,8 @@ module Aruba
13
13
  #
14
14
  # @yield
15
15
  # The block of code which should with local ENV
16
- def call(env, &block)
17
- old_env = ENV.to_hash.dup
16
+ def call(env)
17
+ old_env = Aruba.platform.environment_variables.hash_from_env
18
18
 
19
19
  ENV.clear
20
20
  ENV.update env
@@ -17,7 +17,7 @@ module Aruba
17
17
  def initialize(hash, opts)
18
18
  @hash = hash
19
19
  @opts = {
20
- :sort => true
20
+ sort: true
21
21
  }.merge opts
22
22
  end
23
23
 
@@ -34,11 +34,11 @@ module Aruba
34
34
  if RUBY_VERSION < '2'
35
35
  rows = []
36
36
 
37
- hash.each do |k,v|
37
+ hash.each do |k, v|
38
38
  rows << format("# %-#{name_size}s => %s", k, v)
39
39
  end
40
40
  else
41
- rows = hash.each_with_object([]) do |(k,v), a|
41
+ rows = hash.each_with_object([]) do |(k, v), a|
42
42
  a << format("# %-#{name_size}s => %s", k, v)
43
43
  end
44
44
  end
@@ -6,14 +6,17 @@ module Aruba
6
6
  # Platforms
7
7
  module Platforms
8
8
  # This is a command which should be run
9
- class UnixCommandString < SimpleDelegator
10
- def initialize(cmd)
11
- __setobj__ cmd
9
+ #
10
+ # @private
11
+ class UnixCommandString
12
+ def initialize(command, *arguments)
13
+ @command = command
14
+ @arguments = arguments
12
15
  end
13
16
 
14
17
  # Convert to array
15
18
  def to_a
16
- Shellwords.split __getobj__
19
+ [@command, *@arguments]
17
20
  end
18
21
  end
19
22
  end
@@ -73,7 +73,7 @@ module Aruba
73
73
  def update(other_env)
74
74
  actions << UpdateAction.new(other_env)
75
75
 
76
- UnixEnvironmentVariables.new(to_h)
76
+ self
77
77
  end
78
78
 
79
79
  # Fetch variable from environment
@@ -133,7 +133,7 @@ module Aruba
133
133
  name = name.to_s
134
134
  value = self[name].to_s + value.to_s
135
135
 
136
- actions << UpdateAction.new(name => value )
136
+ actions << UpdateAction.new(name => value)
137
137
 
138
138
  value
139
139
  end
@@ -184,11 +184,7 @@ module Aruba
184
184
  # @return [Hash]
185
185
  # A new hash from environment
186
186
  def to_h
187
- if RUBY_VERSION < '2.0'
188
- Marshal.load(Marshal.dump(prepared_environment.to_hash))
189
- else
190
- Marshal.load(Marshal.dump(prepared_environment.to_h))
191
- end
187
+ actions.inject(hash_from_env.merge(env)) { |a, e| e.call(a) }
192
188
  end
193
189
 
194
190
  # Reset environment
@@ -200,14 +196,14 @@ module Aruba
200
196
  value
201
197
  end
202
198
 
199
+ def self.hash_from_env
200
+ ENV.to_hash
201
+ end
202
+
203
203
  private
204
204
 
205
- def prepared_environment
206
- if RUBY_VERSION == '1.9.3'
207
- actions.inject(ENV.to_hash.merge(env)) { |a, e| e.call(a) }
208
- else
209
- actions.each_with_object(ENV.to_hash.merge(env)) { |e, a| a = e.call(a) }
210
- end
205
+ def hash_from_env
206
+ self.class.hash_from_env
211
207
  end
212
208
  end
213
209
  end
@@ -98,14 +98,6 @@ module Aruba
98
98
  ::File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
99
99
  end
100
100
 
101
- # @deprecated
102
- # Add newline at the end
103
- def ensure_newline(str)
104
- deprecated('The use of "#ensure_newline" is deprecated. It will be removed soon')
105
-
106
- str.chomp << "\n"
107
- end
108
-
109
101
  def require_matching_files(pattern, base)
110
102
  ::Dir.glob(::File.expand_path(pattern, base)).each { |f| require_relative f }
111
103
  end
@@ -195,7 +187,7 @@ module Aruba
195
187
 
196
188
  # Check if command is relative
197
189
  #
198
- # @return [TrueClass, FalseClass]
190
+ # @return [Boolean]
199
191
  # true
200
192
  # * bin/command.sh
201
193
  #
@@ -209,7 +201,7 @@ module Aruba
209
201
 
210
202
  # Check if command is relative
211
203
  #
212
- # @return [TrueClass, FalseClass]
204
+ # @return [Boolean]
213
205
  # true
214
206
  # * command.sh
215
207
  #
@@ -226,23 +218,6 @@ module Aruba
226
218
  File.write(path, content)
227
219
  end
228
220
 
229
- # Unescape string
230
- #
231
- # @param [String] string
232
- # The string which should be unescaped, e.g. the output of a command
233
- #
234
- # @return
235
- # The string stripped from escape sequences
236
- def unescape(string, keep_ansi = true)
237
- # rubocop:disable Metrics/LineLength
238
- deprecated('The use of "Aruba.platform.unescape" is deprecated. Please use "#unescape_text" and "#sanitize_text" instead. But be aware it uses a different implementation')
239
- # rubocop:enable Metrics/LineLength
240
-
241
- string = string.gsub('\n', "\n").gsub('\"', '"').gsub('\e', "\e")
242
- string = string.gsub(/\e\[\d+(?>(;\d+)*)m/, '') unless keep_ansi
243
- string
244
- end
245
-
246
221
  # Transform hash to a string table which can be output on stderr/stdout
247
222
  def simple_table(hash, opts = {})
248
223
  SimpleTable.new(hash, opts).to_s
@@ -23,7 +23,7 @@ module Aruba
23
23
  Aruba.platform.absolute_path?(program) || Aruba.platform.relative_command?(program)
24
24
  end
25
25
 
26
- def call(program, path)
26
+ def call(program, _path)
27
27
  return File.expand_path(program) if Aruba.platform.executable?(program)
28
28
 
29
29
  nil
@@ -72,6 +72,7 @@ module Aruba
72
72
  # ENV['PATH']
73
73
  def call(program, path = ENV['PATH'])
74
74
  raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty?
75
+
75
76
  program = program.to_s
76
77
 
77
78
  whiches.find { |w| w.match? program }.new.call(program, path)
@@ -1,5 +1,3 @@
1
- require 'delegate'
2
-
3
1
  # Aruba
4
2
  module Aruba
5
3
  # Platforms
@@ -9,15 +7,30 @@ module Aruba
9
7
  # This adds `cmd.exec` in front of commmand
10
8
  #
11
9
  # @private
12
- class WindowsCommandString < SimpleDelegator
13
- def initialize(cmd)
14
- __setobj__ format('%s /c "%s"', Aruba.platform.which('cmd.exe'), cmd)
10
+ class WindowsCommandString
11
+ def initialize(command, *arguments)
12
+ @command = command
13
+ @arguments = arguments
15
14
  end
16
15
 
17
16
  # Convert to array
18
17
  def to_a
19
- Shellwords.split( __getobj__.gsub('\\', 'ARUBA_TMP_PATHSEPARATOR') )
20
- .map { |w| w.gsub('ARUBA_TMP_PATHSEPARATOR', '\\') }
18
+ [cmd_path, '/c', [escaped_command, *escaped_arguments].join(' ')]
19
+ end
20
+
21
+ private
22
+
23
+ def escaped_arguments
24
+ @arguments.map { |arg| arg.gsub(/"/, '"""') }.
25
+ map { |arg| arg =~ / / ? "\"#{arg}\"" : arg }
26
+ end
27
+
28
+ def escaped_command
29
+ @command.gsub(/ /, '""" """')
30
+ end
31
+
32
+ def cmd_path
33
+ Aruba.platform.which('cmd.exe')
21
34
  end
22
35
  end
23
36
  end