aruba 1.0.0.pre.alpha.2 → 1.0.1

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 (135) hide show
  1. checksums.yaml +5 -5
  2. data/.github/PULL_REQUEST_TEMPLATE.md +2 -1
  3. data/.rspec +0 -1
  4. data/.rubocop.yml +46 -182
  5. data/.rubocop_todo.yml +216 -0
  6. data/.simplecov +7 -5
  7. data/.travis.yml +56 -40
  8. data/.yardopts +3 -0
  9. data/CHANGELOG.md +1312 -0
  10. data/CONTRIBUTING.md +175 -83
  11. data/Gemfile +5 -69
  12. data/LICENSE +1 -1
  13. data/README.md +58 -21
  14. data/Rakefile +27 -54
  15. data/appveyor.yml +7 -10
  16. data/aruba.gemspec +38 -19
  17. data/bin/console +3 -12
  18. data/cucumber.yml +4 -22
  19. data/exe/aruba +1 -1
  20. data/fixtures/cli-app/README.md +1 -1
  21. data/fixtures/cli-app/Rakefile +1 -1
  22. data/fixtures/cli-app/bin/aruba-test-cli +1 -1
  23. data/fixtures/cli-app/cli-app.gemspec +4 -4
  24. data/fixtures/cli-app/lib/cli/app.rb +1 -1
  25. data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +3 -3
  26. data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
  27. data/fixtures/cli-app/spec/spec_helper.rb +3 -2
  28. data/fixtures/empty-app/Rakefile +1 -1
  29. data/fixtures/empty-app/cli-app.gemspec +4 -4
  30. data/fixtures/empty-app/lib/cli/app.rb +0 -2
  31. data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
  32. data/fixtures/getting-started-app/Gemfile +1 -1
  33. data/lib/aruba/api.rb +8 -15
  34. data/lib/aruba/api/bundler.rb +16 -0
  35. data/lib/aruba/api/commands.rb +272 -0
  36. data/lib/aruba/api/core.rb +82 -43
  37. data/lib/aruba/api/environment.rb +24 -7
  38. data/lib/aruba/api/filesystem.rb +66 -64
  39. data/lib/aruba/api/text.rb +17 -11
  40. data/lib/aruba/aruba_path.rb +25 -111
  41. data/lib/aruba/basic_configuration.rb +8 -25
  42. data/lib/aruba/basic_configuration/option.rb +2 -2
  43. data/lib/aruba/cli.rb +4 -1
  44. data/lib/aruba/colorizer.rb +10 -99
  45. data/lib/aruba/command.rb +4 -0
  46. data/lib/aruba/config/jruby.rb +15 -5
  47. data/lib/aruba/config_wrapper.rb +17 -2
  48. data/lib/aruba/configuration.rb +107 -0
  49. data/lib/aruba/console.rb +5 -7
  50. data/lib/aruba/console/help.rb +5 -2
  51. data/lib/aruba/contracts/absolute_path.rb +3 -3
  52. data/lib/aruba/contracts/is_power_of_two.rb +2 -2
  53. data/lib/aruba/contracts/relative_path.rb +3 -3
  54. data/lib/aruba/cucumber.rb +0 -3
  55. data/lib/aruba/cucumber/command.rb +227 -190
  56. data/lib/aruba/cucumber/environment.rb +1 -1
  57. data/lib/aruba/cucumber/file.rb +56 -50
  58. data/lib/aruba/cucumber/hooks.rb +10 -63
  59. data/lib/aruba/cucumber/testing_frameworks.rb +76 -50
  60. data/lib/aruba/event_bus.rb +4 -2
  61. data/lib/aruba/event_bus/name_resolver.rb +10 -10
  62. data/lib/aruba/events.rb +2 -1
  63. data/lib/aruba/hooks.rb +3 -5
  64. data/lib/aruba/in_config_wrapper.rb +10 -3
  65. data/lib/aruba/initializer.rb +40 -34
  66. data/lib/aruba/matchers/base/base_matcher.rb +2 -11
  67. data/lib/aruba/matchers/base/message_indenter.rb +19 -0
  68. data/lib/aruba/matchers/base/object_formatter.rb +2 -7
  69. data/lib/aruba/matchers/collection/include_an_object.rb +11 -13
  70. data/lib/aruba/matchers/command/be_successfully_executed.rb +8 -4
  71. data/lib/aruba/matchers/command/have_exit_status.rb +16 -4
  72. data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -5
  73. data/lib/aruba/matchers/command/have_output.rb +12 -5
  74. data/lib/aruba/matchers/command/have_output_on_stderr.rb +4 -2
  75. data/lib/aruba/matchers/command/have_output_on_stdout.rb +4 -2
  76. data/lib/aruba/matchers/command/have_output_size.rb +2 -2
  77. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
  78. data/lib/aruba/matchers/directory/have_sub_directory.rb +10 -7
  79. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
  80. data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
  81. data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
  82. data/lib/aruba/matchers/file/have_file_content.rb +4 -4
  83. data/lib/aruba/matchers/file/have_file_size.rb +8 -8
  84. data/lib/aruba/matchers/file/have_same_file_content.rb +9 -12
  85. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
  86. data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
  87. data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
  88. data/lib/aruba/matchers/path/have_permissions.rb +8 -8
  89. data/lib/aruba/matchers/string/include_output_string.rb +8 -10
  90. data/lib/aruba/matchers/string/match_output_string.rb +9 -11
  91. data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
  92. data/lib/aruba/platform.rb +0 -8
  93. data/lib/aruba/platforms/announcer.rb +60 -85
  94. data/lib/aruba/platforms/aruba_file_creator.rb +4 -2
  95. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +8 -3
  96. data/lib/aruba/platforms/aruba_logger.rb +22 -2
  97. data/lib/aruba/platforms/command_monitor.rb +15 -102
  98. data/lib/aruba/platforms/determine_disk_usage.rb +56 -19
  99. data/lib/aruba/platforms/filesystem_status.rb +9 -9
  100. data/lib/aruba/platforms/local_environment.rb +2 -2
  101. data/lib/aruba/platforms/simple_table.rb +3 -11
  102. data/lib/aruba/platforms/unix_command_string.rb +7 -4
  103. data/lib/aruba/platforms/unix_environment_variables.rb +19 -26
  104. data/lib/aruba/platforms/unix_platform.rb +18 -39
  105. data/lib/aruba/platforms/unix_which.rb +3 -2
  106. data/lib/aruba/platforms/windows_command_string.rb +20 -7
  107. data/lib/aruba/platforms/windows_environment_variables.rb +42 -30
  108. data/lib/aruba/platforms/windows_platform.rb +4 -0
  109. data/lib/aruba/platforms/windows_which.rb +9 -4
  110. data/lib/aruba/processes/basic_process.rb +21 -27
  111. data/lib/aruba/processes/debug_process.rb +16 -5
  112. data/lib/aruba/processes/in_process.rb +20 -9
  113. data/lib/aruba/processes/spawn_process.rb +64 -36
  114. data/lib/aruba/rspec.rb +28 -31
  115. data/lib/aruba/runtime.rb +16 -7
  116. data/lib/aruba/setup.rb +32 -17
  117. data/lib/aruba/tasks/docker_helpers.rb +4 -2
  118. data/lib/aruba/version.rb +1 -1
  119. metadata +194 -64
  120. data/History.md +0 -612
  121. data/bin/bootstrap +0 -34
  122. data/bin/build +0 -3
  123. data/bin/release +0 -3
  124. data/fixtures/spawn_process/stderr.sh +0 -3
  125. data/lib/aruba/api/command.rb +0 -309
  126. data/lib/aruba/api/deprecated.rb +0 -895
  127. data/lib/aruba/api/rvm.rb +0 -44
  128. data/lib/aruba/config.rb +0 -101
  129. data/lib/aruba/cucumber/rvm.rb +0 -3
  130. data/lib/aruba/in_process.rb +0 -14
  131. data/lib/aruba/jruby.rb +0 -4
  132. data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
  133. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
  134. data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
  135. data/lib/aruba/spawn_process.rb +0 -11
@@ -10,7 +10,8 @@ module Aruba
10
10
  def aruba_help
11
11
  puts 'Aruba Version: ' + Aruba::VERSION
12
12
  puts 'Issue Tracker: ' + 'https://github.com/cucumber/aruba/issues'
13
- puts "Documentation:\n" + %w(http://www.rubydoc.info/gems/aruba).map { |d| format('* %s', d) }.join("\n")
13
+ puts 'Documentation:'
14
+ puts '* http://www.rubydoc.info/gems/aruba'
14
15
  puts
15
16
 
16
17
  nil
@@ -18,7 +19,9 @@ module Aruba
18
19
 
19
20
  # List available methods in aruba
20
21
  def aruba_methods
21
- ms = (Aruba::Api.instance_methods - Module.instance_methods).each_with_object([]) { |e, a| a << format("* %s", e) }.sort
22
+ ms = (Aruba::Api.instance_methods - Module.instance_methods)
23
+ .each_with_object([]) { |e, a| a << format('* %s', e) }
24
+ .sort
22
25
 
23
26
  puts "Available Methods:\n" + ms.join("\n")
24
27
 
@@ -1,4 +1,4 @@
1
- require 'aruba/aruba_path'
1
+ require 'aruba/platform'
2
2
 
3
3
  # Aruba
4
4
  module Aruba
@@ -11,8 +11,8 @@ module Aruba
11
11
  # @param [Object] value
12
12
  # The value to be checked
13
13
  def self.valid?(value)
14
- ArubaPath.new(value).absolute?
15
- rescue
14
+ Aruba.platform.absolute_path? value
15
+ rescue StandardError
16
16
  false
17
17
  end
18
18
  end
@@ -13,8 +13,8 @@ module Aruba
13
13
  def self.valid?(value)
14
14
  # explanation for algorithm can be found here:
15
15
  # http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/
16
- value != 0 && (value & (value - 1)) == 0 ? true : false
17
- rescue
16
+ value.positive? && (value & (value - 1)).zero?
17
+ rescue StandardError
18
18
  false
19
19
  end
20
20
  end
@@ -1,4 +1,4 @@
1
- require 'aruba/aruba_path'
1
+ require 'aruba/platform'
2
2
 
3
3
  # Aruba
4
4
  module Aruba
@@ -11,8 +11,8 @@ module Aruba
11
11
  # @param [String] value
12
12
  # The path to be checked
13
13
  def self.valid?(value)
14
- ArubaPath.new(value).relative?
15
- rescue
14
+ Aruba.platform.relative_path? value
15
+ rescue StandardError
16
16
  false
17
17
  end
18
18
  end
@@ -1,11 +1,8 @@
1
1
  require 'aruba/version'
2
2
 
3
3
  require 'aruba/api'
4
- World(Aruba::Api)
5
-
6
4
  require 'aruba/cucumber/hooks'
7
5
  require 'aruba/cucumber/command'
8
6
  require 'aruba/cucumber/environment'
9
7
  require 'aruba/cucumber/file'
10
8
  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
-
3
+ When(/^I run `([^`]*)`$/) do |cmd|
6
4
  cmd = sanitize_text(cmd)
7
- run_command_and_stop(cmd, false)
8
- end
9
-
10
- When(/^I run `([^`]*)`$/)do |cmd|
11
- 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
- When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) do |shell, commands|
30
- prepend_environment_variable('PATH', expand_path('bin') + File::PATH_SEPARATOR)
15
+ When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) \
16
+ do |shell, commands|
17
+ full_path = expand_path('bin/myscript')
31
18
 
32
19
  Aruba.platform.mkdir(expand_path('bin'))
33
20
  shell ||= Aruba.platform.default_shell
34
21
 
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)
22
+ Aruba::ScriptFile.new(interpreter: shell, content: commands, path: full_path).call
23
+ run_command_and_stop(Shellwords.escape(full_path), fail_on_error: false)
44
24
  end
45
25
 
46
- When(/^I run `([^`]*)` interactively$/)do |cmd|
47
- cmd = sanitize_text(cmd)
48
- @interactive = run_command(cmd)
26
+ When(/^I run `([^`]*)` interactively$/) do |cmd|
27
+ run_command(sanitize_text(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,27 @@ 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
- 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
-
65
+ When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$/) \
66
+ do |channel, expected|
96
67
  begin
97
68
  Timeout.timeout(aruba.config.exit_timeout) do
98
69
  loop do
99
- output = last_command_started.public_send channel.to_sym, :wait_for_io => 0
70
+ output = last_command_started.public_send channel.to_sym, wait_for_io: 0
100
71
 
101
72
  output = sanitize_text(output)
102
73
  expected = sanitize_text(expected)
@@ -110,7 +81,7 @@ When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$
110
81
  sleep 0.1
111
82
  end
112
83
  end
113
- rescue ChildProcess::TimeoutError, TimeoutError
84
+ rescue ChildProcess::TimeoutError, Timeout::Error
114
85
  last_command_started.terminate
115
86
  end
116
87
  end
@@ -146,24 +117,13 @@ When(/^I wait for (?:output|stdout) to contain "([^"]*)"$/) do |expected|
146
117
  end
147
118
 
148
119
  Then(/^the output should be (\d+) bytes long$/) do |size|
149
- expect(all_output).to have_output_size size.to_i
120
+ expect(last_command_started.output).to have_output_size size.to_i
150
121
  end
151
122
 
152
- Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain( exactly)? "([^"]*)"$/) do |channel, cmd, negated, exactly, expected|
153
- matcher = case channel.to_sym
154
- when :output
155
- :have_output
156
- when :stderr
157
- :have_output_on_stderr
158
- when :stdout
159
- :have_output_on_stdout
160
- end
161
-
162
- commands = if cmd
163
- [aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))]
164
- else
165
- all_commands
166
- end
123
+ ## the stderr should contain "hello"
124
+ Then(/^(?:the )?(output|stderr|stdout) should( not)? contain( exactly)? "([^"]*)"$/) \
125
+ do |channel, negated, exactly, expected|
126
+ combined_output = send("all_#{channel}")
167
127
 
168
128
  output_string_matcher = if exactly
169
129
  :an_output_string_being_eq
@@ -171,47 +131,93 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
171
131
  :an_output_string_including
172
132
  end
173
133
 
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
134
+ if negated
135
+ expect(combined_output).not_to send(output_string_matcher, expected)
185
136
  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
137
+ expect(combined_output).to send(output_string_matcher, expected)
191
138
  end
192
139
  end
193
140
 
194
- ## the stderr should contain "hello"
195
141
  ## the stderr from "echo -n 'Hello'" should contain "hello"
142
+ Then(
143
+ /^(?:the )?(output|stderr|stdout) from "([^"]*)" should contain( exactly)? "([^"]*)"$/
144
+ ) do |channel, cmd, exactly, expected|
145
+ matcher = case channel
146
+ when 'output'; then :have_output
147
+ when 'stderr'; then :have_output_on_stderr
148
+ when 'stdout'; then :have_output_on_stdout
149
+ end
150
+
151
+ command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
152
+
153
+ output_string_matcher = if exactly
154
+ :an_output_string_being_eq
155
+ else
156
+ :an_output_string_including
157
+ end
158
+
159
+ expect(command).to send(matcher, send(output_string_matcher, expected))
160
+ end
161
+
162
+ ## the stderr from "echo -n 'Hello'" should not contain "hello"
163
+ Then(
164
+ /^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactly)? "([^"]*)"$/
165
+ ) do |channel, cmd, exactly, expected|
166
+ matcher = case channel
167
+ when 'output'; then :have_output
168
+ when 'stderr'; then :have_output_on_stderr
169
+ when 'stdout'; then :have_output_on_stdout
170
+ end
171
+
172
+ command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
173
+
174
+ output_string_matcher = if exactly
175
+ :an_output_string_being_eq
176
+ else
177
+ :an_output_string_including
178
+ end
179
+
180
+ expect(command).not_to send(matcher, send(output_string_matcher, expected))
181
+ end
182
+
183
+ ## the stderr should not contain exactly:
184
+ Then(/^(?:the )?(output|stderr|stdout) should not contain( exactly)?:$/) \
185
+ do |channel, exactly, expected|
186
+ combined_output = send("all_#{channel}")
187
+
188
+ output_string_matcher = if exactly
189
+ :an_output_string_being_eq
190
+ else
191
+ :an_output_string_including
192
+ end
193
+
194
+ expect(combined_output).not_to send(output_string_matcher, expected)
195
+ end
196
+
196
197
  ## the stderr should contain exactly:
197
- ## the stderr from "echo -n 'Hello'" should contain exactly:
198
- Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain( exactly)?:$/) do |channel, cmd, negated, exactly, expected|
199
- matcher = case channel.to_sym
200
- when :output
201
- :have_output
202
- when :stderr
203
- :have_output_on_stderr
204
- when :stdout
205
- :have_output_on_stdout
206
- else
207
- fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stderr" or "stdout" are allowed.)
198
+ Then(/^(?:the )?(output|stderr|stdout) should contain( exactly)?:$/) \
199
+ do |channel, exactly, expected|
200
+ combined_output = send("all_#{channel}")
201
+
202
+ output_string_matcher = if exactly
203
+ :an_output_string_being_eq
204
+ else
205
+ :an_output_string_including
206
+ end
207
+
208
+ expect(combined_output).to send(output_string_matcher, expected)
209
+ end
210
+
211
+ ## the stderr from "echo -n 'Hello'" should not contain exactly:
212
+ Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactly)?:$/) \
213
+ do |channel, cmd, exactly, expected|
214
+ matcher = case channel
215
+ when 'output'; then :have_output
216
+ when 'stderr'; then :have_output_on_stderr
217
+ when 'stdout'; then :have_output_on_stdout
208
218
  end
209
219
 
210
- commands = if cmd
211
- [aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))]
212
- else
213
- all_commands
214
- end
220
+ command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
215
221
 
216
222
  output_string_matcher = if exactly
217
223
  :an_output_string_being_eq
@@ -219,55 +225,66 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
219
225
  :an_output_string_including
220
226
  end
221
227
 
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")
228
+ expect(command).not_to send(matcher, send(output_string_matcher, expected))
229
+ end
227
230
 
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
233
- 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
239
- end
231
+ ## the stderr from "echo -n 'Hello'" should contain exactly:
232
+ Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should contain( exactly)?:$/) \
233
+ do |channel, cmd, exactly, expected|
234
+ matcher = case channel
235
+ when 'output'; then :have_output
236
+ when 'stderr'; then :have_output_on_stderr
237
+ when 'stdout'; then :have_output_on_stdout
238
+ end
239
+
240
+ command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
241
+
242
+ output_string_matcher = if exactly
243
+ :an_output_string_being_eq
244
+ else
245
+ :an_output_string_including
246
+ end
247
+
248
+ expect(command).to send(matcher, send(output_string_matcher, expected))
240
249
  end
241
250
 
242
251
  # "the output should match" allows regex in the partial_output, if
243
252
  # you don't need regex, use "the output should contain" instead since
244
253
  # that way, you don't have to escape regex characters that
245
254
  # appear naturally in the output
246
- Then(/^the output should( not)? match \/([^\/]*)\/$/) do |negated, expected|
255
+ Then(%r{^the output should( not)? match /([^/]*)/$}) do |negated, expected|
247
256
  if negated
248
- expect(all_commands).not_to include_an_object have_output an_output_string_matching(expected)
257
+ expect(all_commands)
258
+ .not_to include_an_object have_output an_output_string_matching(expected)
249
259
  else
250
- expect(all_commands).to include_an_object have_output an_output_string_matching(expected)
260
+ expect(all_commands)
261
+ .to include_an_object have_output an_output_string_matching(expected)
251
262
  end
252
263
  end
253
264
 
254
265
  Then(/^the output should( not)? match %r<([^>]*)>$/) do |negated, expected|
255
266
  if negated
256
- expect(all_commands).not_to include_an_object have_output an_output_string_matching(expected)
267
+ expect(all_commands)
268
+ .not_to include_an_object have_output an_output_string_matching(expected)
257
269
  else
258
- expect(all_commands).to include_an_object have_output an_output_string_matching(expected)
270
+ expect(all_commands)
271
+ .to include_an_object have_output an_output_string_matching(expected)
259
272
  end
260
273
  end
261
274
 
262
275
  Then(/^the output should( not)? match:$/) do |negated, expected|
263
276
  if negated
264
- expect(all_commands).not_to include_an_object have_output an_output_string_matching(expected)
277
+ expect(all_commands)
278
+ .not_to include_an_object have_output an_output_string_matching(expected)
265
279
  else
266
- expect(all_commands).to include_an_object have_output an_output_string_matching(expected)
280
+ expect(all_commands)
281
+ .to include_an_object have_output an_output_string_matching(expected)
267
282
  end
268
283
  end
269
284
 
270
285
  Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
286
+ last_command_started.stop if last_command_stopped.nil?
287
+
271
288
  if negated
272
289
  expect(last_command_stopped).not_to have_exit_status exit_status.to_i
273
290
  else
@@ -275,134 +292,154 @@ Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
275
292
  end
276
293
  end
277
294
 
278
- Then(/^it should( not)? (pass|fail) with "(.*?)"$/) do |negated, pass_fail, expected|
295
+ Then(/^it should not (pass|fail) with "(.*?)"$/) do |pass_fail, expected|
296
+ last_command_started.stop
297
+
279
298
  if pass_fail == 'pass'
280
299
  expect(last_command_stopped).to be_successfully_executed
281
300
  else
282
301
  expect(last_command_stopped).not_to be_successfully_executed
283
302
  end
284
303
 
285
- if negated
286
- expect(last_command_stopped).not_to have_output an_output_string_including(expected)
304
+ expect(last_command_stopped).not_to have_output an_output_string_including(expected)
305
+ end
306
+
307
+ Then(/^it should (pass|fail) with "(.*?)"$/) do |pass_fail, expected|
308
+ last_command_started.stop
309
+
310
+ if pass_fail == 'pass'
311
+ expect(last_command_stopped).to be_successfully_executed
287
312
  else
288
- expect(last_command_stopped).to have_output an_output_string_including(expected)
313
+ expect(last_command_stopped).not_to be_successfully_executed
289
314
  end
315
+
316
+ expect(last_command_stopped).to have_output an_output_string_including(expected)
290
317
  end
291
318
 
292
- Then(/^it should( not)? (pass|fail) with:$/) do |negated, pass_fail, expected|
319
+ Then(/^it should not (pass|fail) with:$/) do |pass_fail, expected|
320
+ last_command_started.stop
321
+
293
322
  if pass_fail == 'pass'
294
323
  expect(last_command_stopped).to be_successfully_executed
295
324
  else
296
325
  expect(last_command_stopped).not_to be_successfully_executed
297
326
  end
298
327
 
299
- if negated
300
- expect(last_command_stopped).not_to have_output an_output_string_including(expected)
328
+ expect(last_command_stopped).not_to have_output an_output_string_including(expected)
329
+ end
330
+
331
+ Then(/^it should (pass|fail) with:$/) do |pass_fail, expected|
332
+ last_command_started.stop
333
+
334
+ if pass_fail == 'pass'
335
+ expect(last_command_stopped).to be_successfully_executed
301
336
  else
302
- expect(last_command_stopped).to have_output an_output_string_including(expected)
337
+ expect(last_command_stopped).not_to be_successfully_executed
303
338
  end
339
+
340
+ expect(last_command_stopped).to have_output an_output_string_including(expected)
304
341
  end
305
342
 
306
- Then(/^it should( not)? (pass|fail) with exactly:$/) do |negated, pass_fail, expected|
343
+ Then(/^it should not (pass|fail) with exactly:$/) do |pass_fail, expected|
344
+ last_command_started.stop
345
+
307
346
  if pass_fail == 'pass'
308
347
  expect(last_command_stopped).to be_successfully_executed
309
348
  else
310
349
  expect(last_command_stopped).not_to be_successfully_executed
311
350
  end
312
351
 
313
- if negated
314
- expect(last_command_stopped).not_to have_output an_output_string_eq(expected)
352
+ expect(last_command_stopped).not_to have_output an_output_string_eq(expected)
353
+ end
354
+
355
+ Then(/^it should (pass|fail) with exactly:$/) do |pass_fail, expected|
356
+ last_command_started.stop
357
+
358
+ if pass_fail == 'pass'
359
+ expect(last_command_stopped).to be_successfully_executed
315
360
  else
316
- expect(last_command_stopped).to have_output an_output_string_being_eq(expected)
361
+ expect(last_command_stopped).not_to be_successfully_executed
317
362
  end
363
+
364
+ expect(last_command_stopped).to have_output an_output_string_being_eq(expected)
318
365
  end
319
366
 
320
- Then(/^it should( not)? (pass|fail) (?:with regexp?|matching):$/) do |negated, pass_fail, expected|
367
+ Then(/^it should not (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected|
368
+ last_command_started.stop
369
+
321
370
  if pass_fail == 'pass'
322
371
  expect(last_command_stopped).to be_successfully_executed
323
372
  else
324
373
  expect(last_command_stopped).not_to be_successfully_executed
325
374
  end
326
375
 
327
- if negated
328
- expect(last_command_stopped).not_to have_output an_output_string_matching(expected)
376
+ expect(last_command_stopped).not_to have_output an_output_string_matching(expected)
377
+ end
378
+
379
+ Then(/^it should (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected|
380
+ last_command_started.stop
381
+
382
+ if pass_fail == 'pass'
383
+ expect(last_command_stopped).to be_successfully_executed
329
384
  else
330
- expect(last_command_stopped).to have_output an_output_string_matching(expected)
385
+ expect(last_command_stopped).not_to be_successfully_executed
331
386
  end
387
+
388
+ expect(last_command_stopped).to have_output an_output_string_matching(expected)
332
389
  end
333
390
 
334
391
  Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channel|
335
- matcher = case channel.to_sym
336
- when :output
337
- :have_output
338
- when :stderr
339
- :have_output_on_stderr
340
- when :stdout
341
- :have_output_on_stdout
342
- else
343
- fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stdout" and "stderr" are supported.)
392
+ matcher = case channel
393
+ when 'output'; then :have_output
394
+ when 'stderr'; then :have_output_on_stderr
395
+ when 'stdout'; then :have_output_on_stdout
344
396
  end
345
397
 
346
398
  expect(all_commands).to include_an_object send(matcher, be_nil.or(be_empty))
347
399
  end
348
400
 
349
- Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) do |channel, negated, table|
401
+ Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) \
402
+ do |channel, negated, table|
350
403
  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
404
+ _matcher = case channel
405
+ when 'output'; then :have_output
406
+ when 'stderr'; then :have_output_on_stderr
407
+ when 'stdout'; then :have_output_on_stdout
408
+ end
409
+
410
+ # TODO: This isn't actually using the above. It's hardcoded to use have_output only
361
411
 
362
412
  if negated
363
- expect(all_commands).not_to include_an_object have_output an_output_string_including(expected)
413
+ expect(all_commands)
414
+ .not_to include_an_object have_output an_output_string_including(expected)
364
415
  else
365
- expect(all_commands).to include_an_object have_output an_output_string_including(expected)
416
+ expect(all_commands)
417
+ .to include_an_object have_output an_output_string_including(expected)
366
418
  end
367
419
  end
368
420
  end
369
421
 
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
422
+ Given(/^the (?:default )?aruba io wait timeout is ([\d.]+) seconds?$/) do |seconds|
423
+ aruba.config.io_wait_timeout = seconds.to_f
388
424
  end
389
425
 
390
- Given(/^the (?:default )?aruba exit timeout is (\d+) seconds?$/) do |seconds|
391
- aruba.config.exit_timeout = seconds.to_i
426
+ Given(/^the (?:default )?aruba exit timeout is ([\d.]+) seconds?$/) do |seconds|
427
+ aruba.config.exit_timeout = seconds.to_f
392
428
  end
393
429
 
394
430
  Given(/^the (?:default )?aruba stop signal is "([^"]*)"$/) do |signal|
395
431
  aruba.config.stop_signal = signal
396
432
  end
397
433
 
398
- Given(/^I wait (\d+) seconds? for (?:a|the) command to start up$/) do |seconds|
399
- aruba.config.startup_wait_time = seconds.to_i
434
+ Given(/^I wait ([\d.]+) seconds? for (?:a|the) command to start up$/) do |seconds|
435
+ aruba.config.startup_wait_time = seconds.to_f
400
436
  end
401
437
 
402
- When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))$/) do |signal, command|
438
+ When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))$/) \
439
+ do |signal, command|
403
440
  if command
404
441
  cmd = all_commands.find { |c| c.commandline == command }
405
- fail ArgumentError, %(No command "#{command}" found) if cmd.nil?
442
+ raise ArgumentError, %(No command "#{command}" found) if cmd.nil?
406
443
 
407
444
  cmd.send_signal signal
408
445
  else