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

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -48,6 +48,8 @@ module Aruba
48
48
 
49
49
  # Stop command
50
50
  def stop(*)
51
+ return if __getobj__.stopped?
52
+
51
53
  __getobj__.stop
52
54
  event_bus.notify Events::CommandStopped.new(self)
53
55
 
@@ -56,6 +58,8 @@ module Aruba
56
58
 
57
59
  # Terminate command
58
60
  def terminate(*)
61
+ return if __getobj__.stopped?
62
+
59
63
  __getobj__.terminate
60
64
  event_bus.notify Events::CommandStopped.new(self)
61
65
 
@@ -30,7 +30,7 @@ module Aruba
30
30
  # If one method ends with "=", e.g. ":option1=", then notify the event
31
31
  # queue, that the user changes the value of "option1"
32
32
  def method_missing(name, *args, &block)
33
- event_bus.notify Events::ChangedConfiguration.new(:changed => { :name => name.to_s.gsub(/=$/, ''), :value => args.first }) if name.to_s.end_with? '='
33
+ event_bus.notify Events::ChangedConfiguration.new(changed: { name: name.to_s.gsub(/=$/, ''), value: args.first }) if name.to_s.end_with? '='
34
34
 
35
35
  config.send(name, *args, &block)
36
36
  end
@@ -0,0 +1,78 @@
1
+ require 'contracts'
2
+
3
+ require 'aruba/version'
4
+ require 'aruba/basic_configuration'
5
+ require 'aruba/in_config_wrapper'
6
+ require 'aruba/hooks'
7
+
8
+ require 'aruba/contracts/relative_path'
9
+ require 'aruba/contracts/absolute_path'
10
+ require 'aruba/contracts/enum'
11
+
12
+ require 'aruba/contracts/is_power_of_two'
13
+
14
+ # Aruba
15
+ module Aruba
16
+ # Aruba Configuration
17
+ #
18
+ # This defines the configuration options of aruba
19
+ class Configuration < BasicConfiguration
20
+ option_reader :root_directory, contract: { None => String }, default: Dir.getwd
21
+
22
+ option_accessor :working_directory, contract: { Aruba::Contracts::RelativePath => Aruba::Contracts::RelativePath }, default: 'tmp/aruba'
23
+
24
+ option_reader :fixtures_path_prefix, contract: { None => String }, default: '%'
25
+
26
+ option_accessor :exit_timeout, contract: { Num => Num }, default: 15
27
+ option_accessor :stop_signal, contract: { Maybe[String] => Maybe[String] }, default: nil
28
+ option_accessor :io_wait_timeout, contract: { Num => Num }, default: 0.1
29
+ option_accessor :startup_wait_time, contract: { Num => Num }, default: 0
30
+ option_accessor :fixtures_directories, contract: { Array => ArrayOf[String] }, default: %w(features/fixtures spec/fixtures test/fixtures fixtures)
31
+ option_accessor :command_runtime_environment, contract: { Hash => Hash }, default: {}
32
+ # rubocop:disable Metrics/LineLength
33
+ option_accessor(:command_search_paths, contract: { ArrayOf[String] => ArrayOf[String] }) { |config| [File.join(config.root_directory.value, 'bin'), File.join(config.root_directory.value, 'exe')] }
34
+ # rubocop:enable Metrics/LineLength
35
+ option_accessor :remove_ansi_escape_sequences, contract: { Bool => Bool }, default: true
36
+ # rubocop:disable Metrics/LineLength
37
+ option_accessor :command_launcher, contract: { Aruba::Contracts::Enum[:in_process, :spawn, :debug] => Aruba::Contracts::Enum[:in_process, :spawn, :debug] }, default: :spawn
38
+ option_accessor :main_class, contract: { Class => Maybe[Class] }, default: nil
39
+
40
+ option_accessor :home_directory, contract: { Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] => Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] } do |config|
41
+ File.join(config.root_directory.value, config.working_directory.value)
42
+ end
43
+
44
+ option_accessor :log_level, contract: { Aruba::Contracts::Enum[:fatal, :warn, :debug, :info, :error, :unknown, :silent] => Aruba::Contracts::Enum[:fatal, :warn, :debug, :info, :error, :unknown, :silent] }, default: :info
45
+
46
+ # TODO: deprecate this value and replace with "filesystem allocation unit"
47
+ # equal to 4096 by default. "filesystem allocation unit" would represent
48
+ # the actual MINIMUM space taken in bytes by a 1-byte file
49
+ option_accessor :physical_block_size, contract: { Aruba::Contracts::IsPowerOfTwo => Aruba::Contracts::IsPowerOfTwo }, default: 512
50
+ option_accessor :console_history_file, contract: { String => String }, default: '~/.aruba_history'
51
+
52
+ option_accessor :activate_announcer_on_command_failure, contract: { ArrayOf[Symbol] => ArrayOf[Symbol] }, default: []
53
+ option_accessor :allow_absolute_paths, contract: { Bool => Bool }, default: false
54
+ end
55
+ end
56
+
57
+ # Aruba
58
+ module Aruba
59
+ @config = Configuration.new
60
+
61
+ class << self
62
+ attr_reader :config
63
+
64
+ # Configure aruba
65
+ #
66
+ # @example How to configure aruba
67
+ #
68
+ # Aruba.configure do |config|
69
+ # config.<option> = <value>
70
+ # end
71
+ #
72
+ def configure(&block)
73
+ @config.configure(&block)
74
+
75
+ self
76
+ end
77
+ end
78
+ end
@@ -20,10 +20,10 @@ module Aruba
20
20
 
21
21
  IRB.conf[:PROMPT] = {}
22
22
  IRB.conf[:PROMPT][:ARUBA] = {
23
- :PROMPT_I => '%N:%03n:%i> ',
24
- :PROMPT_S => '%N:%03n:%i%l ',
25
- :PROMPT_C => '%N:%03n:%i* ',
26
- :RETURN => "# => %s\n"
23
+ PROMPT_I: '%N:%03n:%i> ',
24
+ PROMPT_S: '%N:%03n:%i%l ',
25
+ PROMPT_C: '%N:%03n:%i* ',
26
+ RETURN: "# => %s\n"
27
27
  }
28
28
  IRB.conf[:PROMPT_MODE] = :ARUBA
29
29
 
@@ -51,7 +51,7 @@ module Aruba
51
51
  irb = IRB::Irb.new(IRB::WorkSpace.new(context.new))
52
52
  IRB.conf[:MAIN_CONTEXT] = irb.context
53
53
 
54
- trap("SIGINT") do
54
+ trap('SIGINT') do
55
55
  irb.signal_handle
56
56
  end
57
57
 
@@ -18,7 +18,7 @@ module Aruba
18
18
 
19
19
  # List available methods in aruba
20
20
  def aruba_methods
21
- ms = (Aruba::Api.instance_methods - Module.instance_methods).each_with_object([]) { |e, a| a << format("* %s", e) }.sort
21
+ ms = (Aruba::Api.instance_methods - Module.instance_methods).each_with_object([]) { |e, a| a << format('* %s', e) }.sort
22
22
 
23
23
  puts "Available Methods:\n" + ms.join("\n")
24
24
 
@@ -8,4 +8,3 @@ require 'aruba/cucumber/command'
8
8
  require 'aruba/cucumber/environment'
9
9
  require 'aruba/cucumber/file'
10
10
  require 'aruba/cucumber/testing_frameworks'
11
- require 'aruba/cucumber/rvm'
@@ -1,55 +1,34 @@
1
1
  require 'aruba/generators/script_file'
2
2
 
3
- When(/^I run "(.*)"$/)do |cmd|
4
- warn(%{\e[35m The /^I run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
5
-
6
- cmd = sanitize_text(cmd)
7
- run_command_and_stop(cmd, false)
8
- end
9
-
10
- When(/^I run `([^`]*)`$/)do |cmd|
3
+ When(/^I run `([^`]*)`$/) do |cmd|
11
4
  cmd = sanitize_text(cmd)
12
- run_command_and_stop(cmd, :fail_on_error => false)
13
- end
14
-
15
- When(/^I successfully run "(.*)"$/)do |cmd|
16
- warn(%{\e[35m The /^I successfully run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
17
-
18
- cmd = sanitize_text(cmd)
19
- run_command_and_stop(cmd)
5
+ run_command_and_stop(cmd, fail_on_error: false)
20
6
  end
21
7
 
22
8
  ## I successfully run `echo -n "Hello"`
23
9
  ## I successfully run `sleep 29` for up to 30 seconds
24
- When(/^I successfully run `(.*?)`(?: for up to (\d+) seconds)?$/)do |cmd, secs|
10
+ When(/^I successfully run `(.*?)`(?: for up to ([\d.]+) seconds)?$/) do |cmd, secs|
25
11
  cmd = sanitize_text(cmd)
26
- run_command_and_stop(cmd, :fail_on_error => true, :exit_timeout => secs && secs.to_i)
12
+ run_command_and_stop(cmd, fail_on_error: true, exit_timeout: secs && secs.to_f)
27
13
  end
28
14
 
29
15
  When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) do |shell, commands|
30
- prepend_environment_variable('PATH', expand_path('bin') + File::PATH_SEPARATOR)
16
+ full_path = expand_path('bin/myscript')
31
17
 
32
18
  Aruba.platform.mkdir(expand_path('bin'))
33
19
  shell ||= Aruba.platform.default_shell
34
20
 
35
- Aruba::ScriptFile.new(:interpreter => shell, :content => commands,
36
- :path => expand_path('bin/myscript')).call
37
- step 'I run `myscript`'
38
- end
39
-
40
- When(/^I run "([^"]*)" interactively$/) do |cmd|
41
- Aruba.platform.deprecated(%{\e[35m The /^I run "([^"]*)" interactively$/ step definition is deprecated. Please use the `backticks` version\e[0m})
42
-
43
- step %(I run `#{cmd}` interactively)
21
+ Aruba::ScriptFile.new(interpreter: shell, content: commands, path: full_path).call
22
+ run_command_and_stop(Shellwords.escape(full_path), fail_on_error: false)
44
23
  end
45
24
 
46
- When(/^I run `([^`]*)` interactively$/)do |cmd|
25
+ When(/^I run `([^`]*)` interactively$/) do |cmd|
47
26
  cmd = sanitize_text(cmd)
48
27
  @interactive = run_command(cmd)
49
28
  end
50
29
 
51
30
  # Merge interactive and background after refactoring with event queue
52
- When(/^I run `([^`]*)` in background$/)do |cmd|
31
+ When(/^I run `([^`]*)` in background$/) do |cmd|
53
32
  run_command(sanitize_text(cmd))
54
33
  end
55
34
 
@@ -68,35 +47,26 @@ When(/^I pipe in (?:a|the) file(?: named)? "([^"]*)"$/) do |file|
68
47
  end
69
48
 
70
49
  When(/^I (terminate|stop) the command (?:"([^"]*)"|(?:started last))$/) do |signal, command|
71
- if command
72
- cmd = all_commands.find { |c| c.commandline == command }
73
- fail ArgumentError, %(No command "#{command}" found) if cmd.nil?
50
+ monitor = aruba.command_monitor
74
51
 
75
- if signal == 'terminate'
76
- # last_command_started.terminate
77
- process_monitor.terminate_process!(process_monitor.get_process(command))
78
- else
79
- # last_command_started.stop
80
- process_monitor.stop_process(process_monitor.get_process(command))
81
- end
52
+ cmd = if command
53
+ monitor.find(command)
54
+ else
55
+ last_command_started
56
+ end
57
+
58
+ if signal == 'terminate'
59
+ cmd.terminate
82
60
  else
83
- if signal == 'terminate'
84
- # last_command_started.terminate
85
- process_monitor.terminate_process!(last_command_started)
86
- else
87
- # last_command_started.stop
88
- process_monitor.stop_process(last_command_started)
89
- end
61
+ cmd.stop
90
62
  end
91
63
  end
92
64
 
93
65
  When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$/) do |channel, expected|
94
- fail %(Invalid output channel "#{channel}" chosen. Please choose one of "output, stdout or stderr") unless %w(output stdout stderr).include? channel
95
-
96
66
  begin
97
67
  Timeout.timeout(aruba.config.exit_timeout) do
98
68
  loop do
99
- output = last_command_started.public_send channel.to_sym, :wait_for_io => 0
69
+ output = last_command_started.public_send channel.to_sym, wait_for_io: 0
100
70
 
101
71
  output = sanitize_text(output)
102
72
  expected = sanitize_text(expected)
@@ -146,7 +116,7 @@ When(/^I wait for (?:output|stdout) to contain "([^"]*)"$/) do |expected|
146
116
  end
147
117
 
148
118
  Then(/^the output should be (\d+) bytes long$/) do |size|
149
- expect(all_output).to have_output_size size.to_i
119
+ expect(last_command_started.output).to have_output_size size.to_i
150
120
  end
151
121
 
152
122
  Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain( exactly)? "([^"]*)"$/) do |channel, cmd, negated, exactly, expected|
@@ -171,23 +141,10 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
171
141
  :an_output_string_including
172
142
  end
173
143
 
174
- if Aruba::VERSION < '1.0'
175
- combined_output = commands.map do |c|
176
- c.stop
177
- c.send(channel.to_sym).chomp
178
- end.join("\n")
179
-
180
- if negated
181
- expect(combined_output).not_to send(output_string_matcher, expected)
182
- else
183
- expect(combined_output).to send(output_string_matcher, expected)
184
- end
144
+ if negated
145
+ expect(commands).not_to include_an_object send(matcher, send(output_string_matcher, expected))
185
146
  else
186
- if negated
187
- expect(commands).not_to include_an_object send(matcher, send(output_string_matcher, expected))
188
- else
189
- expect(commands).to include_an_object send(matcher, send(output_string_matcher, expected))
190
- end
147
+ expect(commands).to include_an_object send(matcher, send(output_string_matcher, expected))
191
148
  end
192
149
  end
193
150
 
@@ -219,23 +176,10 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
219
176
  :an_output_string_including
220
177
  end
221
178
 
222
- if Aruba::VERSION < '1.0'
223
- combined_output = commands.map do |c|
224
- c.stop
225
- c.send(channel.to_sym).chomp
226
- end.join("\n")
227
-
228
- if negated
229
- expect(combined_output).not_to send(output_string_matcher, expected)
230
- else
231
- expect(combined_output).to send(output_string_matcher, expected)
232
- end
179
+ if negated
180
+ expect(commands).not_to include_an_object send(matcher, send(output_string_matcher, expected))
233
181
  else
234
- if negated
235
- expect(commands).not_to include_an_object send(matcher, send(output_string_matcher, expected))
236
- else
237
- expect(commands).to include_an_object send(matcher, send(output_string_matcher, expected))
238
- end
182
+ expect(commands).to include_an_object send(matcher, send(output_string_matcher, expected))
239
183
  end
240
184
  end
241
185
 
@@ -268,6 +212,10 @@ Then(/^the output should( not)? match:$/) do |negated, expected|
268
212
  end
269
213
 
270
214
  Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
215
+ if last_command_stopped.nil?
216
+ last_command_started.stop
217
+ end
218
+
271
219
  if negated
272
220
  expect(last_command_stopped).not_to have_exit_status exit_status.to_i
273
221
  else
@@ -276,6 +224,8 @@ Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
276
224
  end
277
225
 
278
226
  Then(/^it should( not)? (pass|fail) with "(.*?)"$/) do |negated, pass_fail, expected|
227
+ last_command_started.stop
228
+
279
229
  if pass_fail == 'pass'
280
230
  expect(last_command_stopped).to be_successfully_executed
281
231
  else
@@ -290,6 +240,8 @@ Then(/^it should( not)? (pass|fail) with "(.*?)"$/) do |negated, pass_fail, expe
290
240
  end
291
241
 
292
242
  Then(/^it should( not)? (pass|fail) with:$/) do |negated, pass_fail, expected|
243
+ last_command_started.stop
244
+
293
245
  if pass_fail == 'pass'
294
246
  expect(last_command_stopped).to be_successfully_executed
295
247
  else
@@ -304,6 +256,8 @@ Then(/^it should( not)? (pass|fail) with:$/) do |negated, pass_fail, expected|
304
256
  end
305
257
 
306
258
  Then(/^it should( not)? (pass|fail) with exactly:$/) do |negated, pass_fail, expected|
259
+ last_command_started.stop
260
+
307
261
  if pass_fail == 'pass'
308
262
  expect(last_command_stopped).to be_successfully_executed
309
263
  else
@@ -318,6 +272,8 @@ Then(/^it should( not)? (pass|fail) with exactly:$/) do |negated, pass_fail, exp
318
272
  end
319
273
 
320
274
  Then(/^it should( not)? (pass|fail) (?:with regexp?|matching):$/) do |negated, pass_fail, expected|
275
+ last_command_started.stop
276
+
321
277
  if pass_fail == 'pass'
322
278
  expect(last_command_stopped).to be_successfully_executed
323
279
  else
@@ -348,16 +304,16 @@ end
348
304
 
349
305
  Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) do |channel, negated, table|
350
306
  table.raw.flatten.each do |expected|
351
- matcher = case channel.to_sym
352
- when :output
353
- :have_output
354
- when :stderr
355
- :have_output_on_stderr
356
- when :stdout
357
- :have_output_on_stdout
358
- else
359
- fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stdout" and "stderr" are supported.)
360
- end
307
+ case channel.to_sym
308
+ when :output
309
+ :have_output
310
+ when :stderr
311
+ :have_output_on_stderr
312
+ when :stdout
313
+ :have_output_on_stdout
314
+ else
315
+ fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stdout" and "stderr" are supported.)
316
+ end
361
317
 
362
318
  if negated
363
319
  expect(all_commands).not_to include_an_object have_output an_output_string_including(expected)
@@ -367,36 +323,20 @@ Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:
367
323
  end
368
324
  end
369
325
 
370
- Given(/the default aruba timeout is (\d+) seconds/) do |seconds|
371
- # rubocop:disable Metrics/LineLength
372
- Aruba.platform.deprecated(%{The /^the default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
373
- # rubocop:enable Metrics/LineLength
374
-
375
- aruba.config.exit_timeout = seconds.to_i
376
- end
377
-
378
- Given(/The default aruba timeout is (\d+) seconds/) do |seconds|
379
- # rubocop:disable Metrics/LineLength
380
- Aruba.platform.deprecated(%{The /^The default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
381
- # rubocop:enable Metrics/LineLength
382
-
383
- aruba.config.exit_timeout = seconds.to_i
384
- end
385
-
386
- Given(/^the (?:default )?aruba io wait timeout is (\d+) seconds?$/) do |seconds|
387
- aruba.config.io_wait_timeout = seconds.to_i
326
+ Given(/^the (?:default )?aruba io wait timeout is ([\d.]+) seconds?$/) do |seconds|
327
+ aruba.config.io_wait_timeout = seconds.to_f
388
328
  end
389
329
 
390
- Given(/^the (?:default )?aruba exit timeout is (\d+) seconds?$/) do |seconds|
391
- aruba.config.exit_timeout = seconds.to_i
330
+ Given(/^the (?:default )?aruba exit timeout is ([\d.]+) seconds?$/) do |seconds|
331
+ aruba.config.exit_timeout = seconds.to_f
392
332
  end
393
333
 
394
334
  Given(/^the (?:default )?aruba stop signal is "([^"]*)"$/) do |signal|
395
335
  aruba.config.stop_signal = signal
396
336
  end
397
337
 
398
- Given(/^I wait (\d+) seconds? for (?:a|the) command to start up$/) do |seconds|
399
- aruba.config.startup_wait_time = seconds.to_i
338
+ Given(/^I wait ([\d.]+) seconds? for (?:a|the) command to start up$/) do |seconds|
339
+ aruba.config.startup_wait_time = seconds.to_f
400
340
  end
401
341
 
402
342
  When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))$/) do |signal, command|
@@ -1,4 +1,4 @@
1
- Given(/^a mocked home directory$/)do
1
+ Given(/^a mocked home directory$/) do
2
2
  set_environment_variable 'HOME', expand_path('.')
3
3
  end
4
4
 
@@ -3,11 +3,11 @@ Given(/^I use (?:a|the) fixture(?: named)? "([^"]*)"$/) do |name|
3
3
  cd name
4
4
  end
5
5
 
6
- Given(/^I copy (?:a|the) (file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/) do |file_or_directory, source, destination|
6
+ Given(/^I copy (?:a|the) (?:file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/) do |source, destination|
7
7
  copy source, destination
8
8
  end
9
9
 
10
- Given(/^I move (?:a|the) (file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/) do |file_or_directory, source, destination|
10
+ Given(/^I move (?:a|the) (?:file|directory)(?: (?:named|from))? "([^"]*)" to "([^"]*)"$/) do |source, destination|
11
11
  move source, destination
12
12
  end
13
13
 
@@ -42,11 +42,11 @@ Given(/^(?:a|the) (\d+) byte file(?: named)? "([^"]*)"$/) do |file_size, file_na
42
42
  end
43
43
 
44
44
  Given(/^(?:an|the) empty file(?: named)? "([^"]*)"$/) do |file_name|
45
- write_file(file_name, "")
45
+ write_file(file_name, '')
46
46
  end
47
47
 
48
48
  Given(/^(?:an|the) empty file(?: named)? "([^"]*)" with mode "([^"]*)"$/) do |file_name, file_mode|
49
- write_file(file_name, "")
49
+ write_file(file_name, '')
50
50
  chmod(file_mode, file_name)
51
51
  end
52
52
 
@@ -67,11 +67,11 @@ When(/^I append to "([^"]*)" with "([^"]*)"$/) do |file_name, file_content|
67
67
  end
68
68
 
69
69
  When(/^I remove (?:a|the) (?:file|directory)(?: named)? "([^"]*)"( with full force)?$/) do |name, force_remove|
70
- remove(name, :force => force_remove.nil? ? false : true)
70
+ remove(name, force: force_remove.nil? ? false : true)
71
71
  end
72
72
 
73
73
  Given(/^(?:a|the) (?:file|directory)(?: named)? "([^"]*)" does not exist$/) do |name|
74
- remove(name, :force => true)
74
+ remove(name, force: true)
75
75
  end
76
76
 
77
77
  When(/^I cd to "([^"]*)"$/) do |dir|
@@ -156,7 +156,7 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?contain exactly:$/) do
156
156
  end
157
157
  end
158
158
 
159
- Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match %r<([^\/]*)>$/) do |file, negated, content|
159
+ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?match %r<([^>]*)>$/) do |file, negated, content|
160
160
  if negated
161
161
  expect(file).not_to have_file_content file_content_matching(content)
162
162
  else
@@ -174,21 +174,9 @@ end
174
174
 
175
175
  Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?be equal to file "([^"]*)"/) do |file, negated, reference_file|
176
176
  if negated
177
- expect(file).not_to have_same_file_content_like(reference_file)
177
+ expect(file).not_to have_same_file_content_as(reference_file)
178
178
  else
179
- expect(file).to have_same_file_content_like(reference_file)
180
- end
181
- end
182
-
183
- Then(/^the mode of filesystem object "([^"]*)" should (not )?match "([^"]*)"$/) do |file, negated, permissions|
184
- # rubocop:disable Metrics/LineLength
185
- Aruba.platform.deprecated('The use of step "the mode of filesystem object "([^"]*)" should (not )?match "([^"]*)" is deprecated. Use "^the (?:file|directory)(?: named)? "([^"]*)" should have permissions "([^"]*)"$" instead')
186
- # rubocop:enable Metrics/LineLength
187
-
188
- if negated
189
- expect(file).not_to have_permissions(permissions)
190
- else
191
- expect(file).to have_permissions(permissions)
179
+ expect(file).to have_same_file_content_as(reference_file)
192
180
  end
193
181
  end
194
182