aruba 1.0.0.pre.alpha.5 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +153 -28
  3. data/CONTRIBUTING.md +0 -9
  4. data/LICENSE +1 -1
  5. data/README.md +37 -30
  6. data/lib/aruba/api.rb +0 -1
  7. data/lib/aruba/api/bundler.rb +17 -2
  8. data/lib/aruba/api/commands.rb +15 -16
  9. data/lib/aruba/api/core.rb +64 -50
  10. data/lib/aruba/api/environment.rb +12 -4
  11. data/lib/aruba/api/filesystem.rb +32 -46
  12. data/lib/aruba/api/text.rb +15 -3
  13. data/lib/aruba/aruba_path.rb +23 -95
  14. data/lib/aruba/basic_configuration.rb +46 -65
  15. data/lib/aruba/basic_configuration/option.rb +2 -2
  16. data/lib/aruba/cli.rb +4 -1
  17. data/lib/aruba/config/jruby.rb +1 -1
  18. data/lib/aruba/config_wrapper.rb +17 -4
  19. data/lib/aruba/configuration.rb +29 -22
  20. data/lib/aruba/console.rb +0 -2
  21. data/lib/aruba/console/help.rb +8 -5
  22. data/lib/aruba/contracts/absolute_path.rb +3 -3
  23. data/lib/aruba/contracts/is_power_of_two.rb +2 -2
  24. data/lib/aruba/contracts/relative_path.rb +3 -3
  25. data/lib/aruba/cucumber/command.rb +93 -82
  26. data/lib/aruba/cucumber/file.rb +43 -23
  27. data/lib/aruba/cucumber/hooks.rb +4 -1
  28. data/lib/aruba/cucumber/testing_frameworks.rb +14 -12
  29. data/lib/aruba/event_bus.rb +4 -2
  30. data/lib/aruba/event_bus/name_resolver.rb +9 -8
  31. data/lib/aruba/events.rb +2 -1
  32. data/lib/aruba/hooks.rb +2 -4
  33. data/lib/aruba/in_config_wrapper.rb +8 -5
  34. data/lib/aruba/initializer.rb +9 -3
  35. data/lib/aruba/matchers/base/base_matcher.rb +2 -11
  36. data/lib/aruba/matchers/base/message_indenter.rb +1 -1
  37. data/lib/aruba/matchers/base/object_formatter.rb +0 -5
  38. data/lib/aruba/matchers/collection/include_an_object.rb +4 -4
  39. data/lib/aruba/matchers/command/be_successfully_executed.rb +3 -1
  40. data/lib/aruba/matchers/command/have_exit_status.rb +3 -1
  41. data/lib/aruba/matchers/command/have_finished_in_time.rb +3 -1
  42. data/lib/aruba/matchers/command/have_output.rb +3 -1
  43. data/lib/aruba/matchers/command/have_output_on_stderr.rb +3 -1
  44. data/lib/aruba/matchers/command/have_output_on_stdout.rb +3 -1
  45. data/lib/aruba/matchers/directory/have_sub_directory.rb +8 -3
  46. data/lib/aruba/matchers/file/have_file_size.rb +4 -2
  47. data/lib/aruba/matchers/path/have_permissions.rb +7 -4
  48. data/lib/aruba/platforms/announcer.rb +25 -11
  49. data/lib/aruba/platforms/aruba_file_creator.rb +3 -1
  50. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +7 -2
  51. data/lib/aruba/platforms/aruba_logger.rb +10 -9
  52. data/lib/aruba/platforms/command_monitor.rb +4 -6
  53. data/lib/aruba/platforms/determine_disk_usage.rb +55 -20
  54. data/lib/aruba/platforms/filesystem_status.rb +19 -13
  55. data/lib/aruba/platforms/simple_table.rb +2 -2
  56. data/lib/aruba/platforms/unix_environment_variables.rb +9 -4
  57. data/lib/aruba/platforms/unix_platform.rb +10 -10
  58. data/lib/aruba/platforms/unix_which.rb +1 -1
  59. data/lib/aruba/platforms/windows_command_string.rb +1 -1
  60. data/lib/aruba/platforms/windows_environment_variables.rb +2 -1
  61. data/lib/aruba/platforms/windows_platform.rb +3 -3
  62. data/lib/aruba/platforms/windows_which.rb +6 -2
  63. data/lib/aruba/processes/basic_process.rb +4 -6
  64. data/lib/aruba/processes/debug_process.rb +4 -2
  65. data/lib/aruba/processes/in_process.rb +5 -3
  66. data/lib/aruba/processes/spawn_process.rb +27 -16
  67. data/lib/aruba/rspec.rb +25 -15
  68. data/lib/aruba/runtime.rb +11 -4
  69. data/lib/aruba/setup.rb +23 -10
  70. data/lib/aruba/tasks/docker_helpers.rb +3 -1
  71. data/lib/aruba/version.rb +1 -1
  72. metadata +96 -109
  73. data/.cucumberproignore +0 -3
  74. data/.document +0 -5
  75. data/.github/ISSUE_TEMPLATE.md +0 -48
  76. data/.github/PULL_REQUEST_TEMPLATE.md +0 -41
  77. data/.gitignore +0 -38
  78. data/.rspec +0 -3
  79. data/.rubocop.yml +0 -31
  80. data/.rubocop_todo.yml +0 -258
  81. data/.simplecov +0 -34
  82. data/.travis.yml +0 -73
  83. data/.yardopts +0 -11
  84. data/Dockerfile +0 -67
  85. data/Gemfile +0 -15
  86. data/Rakefile +0 -92
  87. data/TODO.md +0 -13
  88. data/appveyor.yml +0 -30
  89. data/aruba.gemspec +0 -46
  90. data/bin/console +0 -7
  91. data/bin/test +0 -9
  92. data/config/.gitignore +0 -1
  93. data/cucumber.yml +0 -6
  94. data/docker-compose.yml +0 -26
  95. data/fixtures/cli-app/.gitignore +0 -9
  96. data/fixtures/cli-app/.rspec +0 -2
  97. data/fixtures/cli-app/README.md +0 -39
  98. data/fixtures/cli-app/Rakefile +0 -1
  99. data/fixtures/cli-app/bin/aruba-test-cli +0 -6
  100. data/fixtures/cli-app/cli-app.gemspec +0 -25
  101. data/fixtures/cli-app/features/support/aruba.rb +0 -1
  102. data/fixtures/cli-app/features/support/env.rb +0 -1
  103. data/fixtures/cli-app/lib/cli/app.rb +0 -9
  104. data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +0 -15
  105. data/fixtures/cli-app/lib/cli/app/version.rb +0 -5
  106. data/fixtures/cli-app/script/console +0 -14
  107. data/fixtures/cli-app/spec/spec_helper.rb +0 -7
  108. data/fixtures/cli-app/spec/support/aruba.rb +0 -1
  109. data/fixtures/copy/file.txt +0 -1
  110. data/fixtures/empty-app/.gitignore +0 -9
  111. data/fixtures/empty-app/.rspec +0 -2
  112. data/fixtures/empty-app/README.md +0 -24
  113. data/fixtures/empty-app/Rakefile +0 -1
  114. data/fixtures/empty-app/cli-app.gemspec +0 -25
  115. data/fixtures/empty-app/lib/cli/app.rb +0 -7
  116. data/fixtures/empty-app/lib/cli/app/version.rb +0 -5
  117. data/fixtures/getting-started-app/.gitignore +0 -4
  118. data/fixtures/getting-started-app/Gemfile +0 -4
  119. data/fixtures/getting-started-app/README.md +0 -3
  120. data/fixtures/getting-started-app/features/support/env.rb +0 -1
  121. data/lib/aruba/extensions/string/strip.rb +0 -25
  122. data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
@@ -17,52 +17,59 @@ module Aruba
17
17
  #
18
18
  # This defines the configuration options of aruba
19
19
  class Configuration < BasicConfiguration
20
- option_reader :root_directory, contract: { None => String }, default: Dir.getwd
20
+ option_reader :root_directory, type: String, default: Dir.getwd
21
21
 
22
22
  option_accessor :working_directory,
23
- contract: { Aruba::Contracts::RelativePath => Aruba::Contracts::RelativePath },
23
+ type: Aruba::Contracts::RelativePath,
24
24
  default: 'tmp/aruba'
25
25
 
26
- option_reader :fixtures_path_prefix, contract: { None => String }, default: '%'
26
+ option_reader :fixtures_path_prefix, type: String, default: '%'
27
27
 
28
- option_accessor :exit_timeout, contract: { Num => Num }, default: 15
29
- option_accessor :stop_signal, contract: { Maybe[String] => Maybe[String] }, default: nil
30
- option_accessor :io_wait_timeout, contract: { Num => Num }, default: 0.1
31
- option_accessor :startup_wait_time, contract: { Num => Num }, default: 0
28
+ option_accessor :exit_timeout, type: Num, default: 15
29
+ option_accessor :stop_signal, type: Maybe[String], default: nil
30
+ option_accessor :io_wait_timeout, type: Num, default: 0.1
31
+ option_accessor :startup_wait_time, type: Num, default: 0
32
32
  option_accessor :fixtures_directories,
33
- contract: { Array => ArrayOf[String] },
33
+ type: ArrayOf[String],
34
34
  default: %w(features/fixtures spec/fixtures test/fixtures fixtures)
35
35
 
36
- option_accessor :command_runtime_environment, contract: { Hash => Hash }, default: {}
36
+ option_accessor :command_runtime_environment, type: Hash, default: {}
37
37
  option_accessor :command_search_paths,
38
- contract: { ArrayOf[String] => ArrayOf[String] } do |config|
39
- [File.join(config.root_directory.value, 'bin'), File.join(config.root_directory.value, 'exe')]
38
+ type: ArrayOf[String] do |config|
39
+ [File.join(config.root_directory.value, 'bin'),
40
+ File.join(config.root_directory.value, 'exe')]
40
41
  end
41
- option_accessor :remove_ansi_escape_sequences, contract: { Bool => Bool }, default: true
42
+ option_accessor :remove_ansi_escape_sequences, type: Bool, default: true
42
43
  option_accessor :command_launcher,
43
- contract: { Aruba::Contracts::Enum[:in_process, :spawn, :debug] => Aruba::Contracts::Enum[:in_process, :spawn, :debug] },
44
+ type: Aruba::Contracts::Enum[:in_process, :spawn, :debug],
44
45
  default: :spawn
45
- option_accessor :main_class, contract: { Class => Maybe[Class] }, default: nil
46
+ option_accessor :main_class, type: Maybe[Class], default: nil
46
47
 
47
48
  option_accessor :home_directory,
48
- contract: { Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] => Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] } do |config|
49
- File.join(config.root_directory.value, config.working_directory.value)
50
- end
49
+ type: Or[Aruba::Contracts::AbsolutePath,
50
+ Aruba::Contracts::RelativePath] do |config|
51
+ File.join(config.root_directory.value, config.working_directory.value)
52
+ end
51
53
 
52
54
  option_accessor :log_level,
53
- contract: { Aruba::Contracts::Enum[:fatal, :warn, :debug, :info, :error, :unknown, :silent] => Aruba::Contracts::Enum[:fatal, :warn, :debug, :info, :error, :unknown, :silent] },
55
+ type:
56
+ Aruba::Contracts::Enum[:fatal, :warn, :debug, :info,
57
+ :error, :unknown, :silent],
54
58
  default: :info
55
59
 
56
60
  # TODO: deprecate this value and replace with "filesystem allocation unit"
57
61
  # equal to 4096 by default. "filesystem allocation unit" would represent
58
62
  # the actual MINIMUM space taken in bytes by a 1-byte file
59
63
  option_accessor :physical_block_size,
60
- contract: { Aruba::Contracts::IsPowerOfTwo => Aruba::Contracts::IsPowerOfTwo },
64
+ type: Aruba::Contracts::IsPowerOfTwo,
61
65
  default: 512
62
- option_accessor :console_history_file, contract: { String => String }, default: '~/.aruba_history'
66
+ option_accessor :console_history_file, type: String,
67
+ default: '~/.aruba_history'
63
68
 
64
- option_accessor :activate_announcer_on_command_failure, contract: { ArrayOf[Symbol] => ArrayOf[Symbol] }, default: []
65
- option_accessor :allow_absolute_paths, contract: { Bool => Bool }, default: false
69
+ option_accessor :activate_announcer_on_command_failure,
70
+ type: ArrayOf[Symbol],
71
+ default: []
72
+ option_accessor :allow_absolute_paths, type: Bool, default: false
66
73
  end
67
74
  end
68
75
 
@@ -9,7 +9,6 @@ module Aruba
9
9
  class Console
10
10
  # Start the aruba console
11
11
  #
12
- # rubocop:disable Metrics/MethodLength
13
12
  def start
14
13
  # Start IRB with current context:
15
14
  # http://stackoverflow.com/questions/4189818/how-to-run-irb-start-in-context-of-current-class
@@ -63,6 +62,5 @@ module Aruba
63
62
  IRB.irb_at_exit
64
63
  end
65
64
  end
66
- # rubocop:enable Metrics/MethodLength
67
65
  end
68
66
  end
@@ -8,9 +8,10 @@ module Aruba
8
8
  module Help
9
9
  # Output help information
10
10
  def aruba_help
11
- puts 'Aruba Version: ' + Aruba::VERSION
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")
11
+ puts "Aruba Version: #{Aruba::VERSION}"
12
+ puts 'Issue Tracker: https://github.com/cucumber/aruba/issues'
13
+ puts 'Documentation:'
14
+ puts '* http://www.rubydoc.info/gems/aruba'
14
15
  puts
15
16
 
16
17
  nil
@@ -18,9 +19,11 @@ 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
- puts "Available Methods:\n" + ms.join("\n")
26
+ puts "Available Methods:\n#{ms.join("\n")}"
24
27
 
25
28
  nil
26
29
  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 [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
@@ -12,7 +12,8 @@ When(/^I successfully run `(.*?)`(?: for up to ([\d.]+) seconds)?$/) do |cmd, se
12
12
  run_command_and_stop(cmd, fail_on_error: true, exit_timeout: secs && secs.to_f)
13
13
  end
14
14
 
15
- When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) do |shell, commands|
15
+ When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) \
16
+ do |shell, commands|
16
17
  full_path = expand_path('bin/myscript')
17
18
 
18
19
  Aruba.platform.mkdir(expand_path('bin'))
@@ -61,7 +62,8 @@ When(/^I (terminate|stop) the command (?:"([^"]*)"|(?:started last))$/) do |sign
61
62
  end
62
63
  end
63
64
 
64
- When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$/) do |channel, expected|
65
+ When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$/) \
66
+ do |channel, expected|
65
67
  begin
66
68
  Timeout.timeout(aruba.config.exit_timeout) do
67
69
  loop do
@@ -86,30 +88,22 @@ end
86
88
 
87
89
  When(/^I wait for (?:output|stdout) to contain:$/) do |expected|
88
90
  Timeout.timeout(aruba.config.exit_timeout) do
89
- loop do
90
- begin
91
- expect(last_command_started).to have_output an_output_string_including(expected)
92
- rescue ExpectationError
93
- sleep 0.1
94
- retry
95
- end
96
-
97
- break
91
+ begin
92
+ expect(last_command_started).to have_output an_output_string_including(expected)
93
+ rescue ExpectationError
94
+ sleep 0.1
95
+ retry
98
96
  end
99
97
  end
100
98
  end
101
99
 
102
100
  When(/^I wait for (?:output|stdout) to contain "([^"]*)"$/) do |expected|
103
101
  Timeout.timeout(aruba.config.exit_timeout) do
104
- loop do
105
- begin
106
- expect(last_command_started).to have_output an_output_string_including(expected)
107
- rescue ExpectationError
108
- sleep 0.1
109
- retry
110
- end
111
-
112
- break
102
+ begin
103
+ expect(last_command_started).to have_output an_output_string_including(expected)
104
+ rescue ExpectationError
105
+ sleep 0.1
106
+ retry
113
107
  end
114
108
  end
115
109
  end
@@ -119,7 +113,8 @@ Then(/^the output should be (\d+) bytes long$/) do |size|
119
113
  end
120
114
 
121
115
  ## the stderr should contain "hello"
122
- Then(/^(?:the )?(output|stderr|stdout) should( not)? contain( exactly)? "([^"]*)"$/) do |channel, negated, exactly, expected|
116
+ Then(/^(?:the )?(output|stderr|stdout) should( not)? contain( exactly)? "([^"]*)"$/) \
117
+ do |channel, negated, exactly, expected|
123
118
  combined_output = send("all_#{channel}")
124
119
 
125
120
  output_string_matcher = if exactly
@@ -136,14 +131,13 @@ Then(/^(?:the )?(output|stderr|stdout) should( not)? contain( exactly)? "([^"]*)
136
131
  end
137
132
 
138
133
  ## the stderr from "echo -n 'Hello'" should contain "hello"
139
- Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should( not)? contain( exactly)? "([^"]*)"$/) do |channel, cmd, negated, exactly, expected|
140
- matcher = case channel.to_sym
141
- when :output
142
- :have_output
143
- when :stderr
144
- :have_output_on_stderr
145
- when :stdout
146
- :have_output_on_stdout
134
+ Then(
135
+ /^(?:the )?(output|stderr|stdout) from "([^"]*)" should contain( exactly)? "([^"]*)"$/
136
+ ) do |channel, cmd, exactly, expected|
137
+ matcher = case channel
138
+ when 'output'; then :have_output
139
+ when 'stderr'; then :have_output_on_stderr
140
+ when 'stdout'; then :have_output_on_stdout
147
141
  end
148
142
 
149
143
  command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
@@ -154,15 +148,33 @@ Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should( not)? contain( exa
154
148
  :an_output_string_including
155
149
  end
156
150
 
157
- if negated
158
- expect(command).not_to send(matcher, send(output_string_matcher, expected))
159
- else
160
- expect(command).to send(matcher, send(output_string_matcher, expected))
161
- end
151
+ expect(command).to send(matcher, send(output_string_matcher, expected))
152
+ end
153
+
154
+ ## the stderr from "echo -n 'Hello'" should not contain "hello"
155
+ Then(
156
+ /^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactly)? "([^"]*)"$/
157
+ ) do |channel, cmd, exactly, expected|
158
+ matcher = case channel
159
+ when 'output'; then :have_output
160
+ when 'stderr'; then :have_output_on_stderr
161
+ when 'stdout'; then :have_output_on_stdout
162
+ end
163
+
164
+ command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
165
+
166
+ output_string_matcher = if exactly
167
+ :an_output_string_being_eq
168
+ else
169
+ :an_output_string_including
170
+ end
171
+
172
+ expect(command).not_to send(matcher, send(output_string_matcher, expected))
162
173
  end
163
174
 
164
175
  ## the stderr should not contain exactly:
165
- Then(/^(?:the )?(output|stderr|stdout) should not contain( exactly)?:$/) do |channel, exactly, expected|
176
+ Then(/^(?:the )?(output|stderr|stdout) should not contain( exactly)?:$/) \
177
+ do |channel, exactly, expected|
166
178
  combined_output = send("all_#{channel}")
167
179
 
168
180
  output_string_matcher = if exactly
@@ -175,7 +187,8 @@ Then(/^(?:the )?(output|stderr|stdout) should not contain( exactly)?:$/) do |cha
175
187
  end
176
188
 
177
189
  ## the stderr should contain exactly:
178
- Then(/^(?:the )?(output|stderr|stdout) should contain( exactly)?:$/) do |channel, exactly, expected|
190
+ Then(/^(?:the )?(output|stderr|stdout) should contain( exactly)?:$/) \
191
+ do |channel, exactly, expected|
179
192
  combined_output = send("all_#{channel}")
180
193
 
181
194
  output_string_matcher = if exactly
@@ -188,14 +201,12 @@ Then(/^(?:the )?(output|stderr|stdout) should contain( exactly)?:$/) do |channel
188
201
  end
189
202
 
190
203
  ## the stderr from "echo -n 'Hello'" should not contain exactly:
191
- Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactly)?:$/) do |channel, cmd, exactly, expected|
192
- matcher = case channel.to_sym
193
- when :output
194
- :have_output
195
- when :stderr
196
- :have_output_on_stderr
197
- when :stdout
198
- :have_output_on_stdout
204
+ Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactly)?:$/) \
205
+ do |channel, cmd, exactly, expected|
206
+ matcher = case channel
207
+ when 'output'; then :have_output
208
+ when 'stderr'; then :have_output_on_stderr
209
+ when 'stdout'; then :have_output_on_stdout
199
210
  end
200
211
 
201
212
  command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
@@ -210,14 +221,12 @@ Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactl
210
221
  end
211
222
 
212
223
  ## the stderr from "echo -n 'Hello'" should contain exactly:
213
- Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should contain( exactly)?:$/) do |channel, cmd, exactly, expected|
214
- matcher = case channel.to_sym
215
- when :output
216
- :have_output
217
- when :stderr
218
- :have_output_on_stderr
219
- when :stdout
220
- :have_output_on_stdout
224
+ Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should contain( exactly)?:$/) \
225
+ do |channel, cmd, exactly, expected|
226
+ matcher = case channel
227
+ when 'output'; then :have_output
228
+ when 'stderr'; then :have_output_on_stderr
229
+ when 'stdout'; then :have_output_on_stdout
221
230
  end
222
231
 
223
232
  command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
@@ -235,34 +244,38 @@ end
235
244
  # you don't need regex, use "the output should contain" instead since
236
245
  # that way, you don't have to escape regex characters that
237
246
  # appear naturally in the output
238
- Then(/^the output should( not)? match \/([^\/]*)\/$/) do |negated, expected|
247
+ Then(%r{^the output should( not)? match /([^/]*)/$}) do |negated, expected|
239
248
  if negated
240
- expect(all_commands).not_to include_an_object have_output an_output_string_matching(expected)
249
+ expect(all_commands)
250
+ .not_to include_an_object have_output an_output_string_matching(expected)
241
251
  else
242
- expect(all_commands).to include_an_object have_output an_output_string_matching(expected)
252
+ expect(all_commands)
253
+ .to include_an_object have_output an_output_string_matching(expected)
243
254
  end
244
255
  end
245
256
 
246
257
  Then(/^the output should( not)? match %r<([^>]*)>$/) do |negated, expected|
247
258
  if negated
248
- expect(all_commands).not_to include_an_object have_output an_output_string_matching(expected)
259
+ expect(all_commands)
260
+ .not_to include_an_object have_output an_output_string_matching(expected)
249
261
  else
250
- expect(all_commands).to include_an_object have_output an_output_string_matching(expected)
262
+ expect(all_commands)
263
+ .to include_an_object have_output an_output_string_matching(expected)
251
264
  end
252
265
  end
253
266
 
254
267
  Then(/^the output should( not)? match:$/) do |negated, expected|
255
268
  if negated
256
- expect(all_commands).not_to include_an_object have_output an_output_string_matching(expected)
269
+ expect(all_commands)
270
+ .not_to include_an_object have_output an_output_string_matching(expected)
257
271
  else
258
- expect(all_commands).to include_an_object have_output an_output_string_matching(expected)
272
+ expect(all_commands)
273
+ .to include_an_object have_output an_output_string_matching(expected)
259
274
  end
260
275
  end
261
276
 
262
277
  Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
263
- if last_command_stopped.nil?
264
- last_command_started.stop
265
- end
278
+ last_command_started.stop if last_command_stopped.nil?
266
279
 
267
280
  if negated
268
281
  expect(last_command_stopped).not_to have_exit_status exit_status.to_i
@@ -368,35 +381,32 @@ Then(/^it should (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expect
368
381
  end
369
382
 
370
383
  Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channel|
371
- matcher = case channel.to_sym
372
- when :output
373
- :have_output
374
- when :stderr
375
- :have_output_on_stderr
376
- when :stdout
377
- :have_output_on_stdout
384
+ matcher = case channel
385
+ when 'output'; then :have_output
386
+ when 'stderr'; then :have_output_on_stderr
387
+ when 'stdout'; then :have_output_on_stdout
378
388
  end
379
389
 
380
390
  expect(all_commands).to include_an_object send(matcher, be_nil.or(be_empty))
381
391
  end
382
392
 
383
- Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) do |channel, negated, table|
393
+ Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) \
394
+ do |channel, negated, table|
384
395
  table.raw.flatten.each do |expected|
385
- case channel.to_sym
386
- when :output
387
- :have_output
388
- when :stderr
389
- :have_output_on_stderr
390
- when :stdout
391
- :have_output_on_stdout
392
- end
396
+ _matcher = case channel
397
+ when 'output'; then :have_output
398
+ when 'stderr'; then :have_output_on_stderr
399
+ when 'stdout'; then :have_output_on_stdout
400
+ end
393
401
 
394
402
  # TODO: This isn't actually using the above. It's hardcoded to use have_output only
395
403
 
396
404
  if negated
397
- expect(all_commands).not_to include_an_object have_output an_output_string_including(expected)
405
+ expect(all_commands)
406
+ .not_to include_an_object have_output an_output_string_including(expected)
398
407
  else
399
- expect(all_commands).to include_an_object have_output an_output_string_including(expected)
408
+ expect(all_commands)
409
+ .to include_an_object have_output an_output_string_including(expected)
400
410
  end
401
411
  end
402
412
  end
@@ -417,10 +427,11 @@ Given(/^I wait ([\d.]+) seconds? for (?:a|the) command to start up$/) do |second
417
427
  aruba.config.startup_wait_time = seconds.to_f
418
428
  end
419
429
 
420
- When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))$/) do |signal, command|
430
+ When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))$/) \
431
+ do |signal, command|
421
432
  if command
422
433
  cmd = all_commands.find { |c| c.commandline == command }
423
- fail ArgumentError, %(No command "#{command}" found) if cmd.nil?
434
+ raise ArgumentError, %(No command "#{command}" found) if cmd.nil?
424
435
 
425
436
  cmd.send_signal signal
426
437
  else