aruba 1.0.0.pre.alpha.4 → 1.0.0.pre.alpha.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +0 -1
  3. data/.rubocop.yml +19 -1
  4. data/.rubocop_todo.yml +10 -116
  5. data/.travis.yml +24 -26
  6. data/CHANGELOG.md +112 -19
  7. data/CONTRIBUTING.md +7 -7
  8. data/Gemfile +2 -50
  9. data/Rakefile +20 -37
  10. data/appveyor.yml +3 -5
  11. data/aruba.gemspec +16 -6
  12. data/bin/console +1 -1
  13. data/cucumber.yml +4 -15
  14. data/exe/aruba +1 -1
  15. data/fixtures/cli-app/bin/aruba-test-cli +1 -1
  16. data/fixtures/cli-app/cli-app.gemspec +1 -3
  17. data/fixtures/cli-app/lib/cli/app.rb +1 -1
  18. data/fixtures/cli-app/spec/spec_helper.rb +1 -1
  19. data/fixtures/empty-app/cli-app.gemspec +1 -3
  20. data/fixtures/empty-app/lib/cli/app.rb +0 -2
  21. data/fixtures/getting-started-app/Gemfile +1 -1
  22. data/lib/aruba/api.rb +6 -6
  23. data/lib/aruba/api/commands.rb +25 -1
  24. data/lib/aruba/api/core.rb +17 -4
  25. data/lib/aruba/api/environment.rb +8 -4
  26. data/lib/aruba/api/filesystem.rb +19 -6
  27. data/lib/aruba/colorizer.rb +10 -99
  28. data/lib/aruba/config/jruby.rb +15 -5
  29. data/lib/aruba/config_wrapper.rb +3 -1
  30. data/lib/aruba/configuration.rb +24 -12
  31. data/lib/aruba/cucumber.rb +0 -2
  32. data/lib/aruba/cucumber/command.rb +123 -45
  33. data/lib/aruba/cucumber/file.rb +13 -15
  34. data/lib/aruba/cucumber/testing_frameworks.rb +74 -50
  35. data/lib/aruba/in_config_wrapper.rb +5 -1
  36. data/lib/aruba/initializer.rb +28 -28
  37. data/lib/aruba/matchers/command/be_successfully_executed.rb +4 -0
  38. data/lib/aruba/matchers/command/have_exit_status.rb +13 -3
  39. data/lib/aruba/matchers/command/have_finished_in_time.rb +1 -1
  40. data/lib/aruba/matchers/command/have_output.rb +1 -1
  41. data/lib/aruba/matchers/command/have_output_on_stderr.rb +1 -1
  42. data/lib/aruba/matchers/command/have_output_on_stdout.rb +1 -1
  43. data/lib/aruba/matchers/command/have_output_size.rb +1 -1
  44. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +1 -1
  45. data/lib/aruba/matchers/file/be_an_existing_file.rb +1 -1
  46. data/lib/aruba/platform.rb +0 -7
  47. data/lib/aruba/platforms/announcer.rb +16 -11
  48. data/lib/aruba/platforms/command_monitor.rb +36 -0
  49. data/lib/aruba/platforms/simple_table.rb +2 -10
  50. data/lib/aruba/platforms/unix_environment_variables.rb +2 -10
  51. data/lib/aruba/platforms/unix_platform.rb +7 -3
  52. data/lib/aruba/platforms/windows_command_string.rb +2 -2
  53. data/lib/aruba/platforms/windows_environment_variables.rb +7 -1
  54. data/lib/aruba/platforms/windows_platform.rb +4 -0
  55. data/lib/aruba/processes/basic_process.rb +11 -11
  56. data/lib/aruba/processes/debug_process.rb +7 -3
  57. data/lib/aruba/processes/spawn_process.rb +13 -8
  58. data/lib/aruba/rspec.rb +1 -1
  59. data/lib/aruba/setup.rb +5 -5
  60. data/lib/aruba/version.rb +1 -1
  61. metadata +153 -20
  62. data/bin/build +0 -3
  63. data/bin/release +0 -3
@@ -23,7 +23,8 @@ module Aruba
23
23
  aruba.environment[name] = value
24
24
  new_environment = aruba.environment.to_h
25
25
 
26
- aruba.event_bus.notify Events::AddedEnvironmentVariable.new(old: old_environment, new: new_environment, changed: { name: name, value: value })
26
+ environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: value } }
27
+ aruba.event_bus.notify Events::AddedEnvironmentVariable.new(environment_change)
27
28
 
28
29
  self
29
30
  end
@@ -45,7 +46,8 @@ module Aruba
45
46
  aruba.environment.append name, value
46
47
  new_environment = aruba.environment.to_h
47
48
 
48
- aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(old: old_environment, new: new_environment, changed: { name: name, value: value })
49
+ environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: value } }
50
+ aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(environment_change)
49
51
 
50
52
  self
51
53
  end
@@ -67,7 +69,8 @@ module Aruba
67
69
  aruba.environment.prepend name, value
68
70
  new_environment = aruba.environment.to_h
69
71
 
70
- aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(old: old_environment, new: new_environment, changed: { name: name, value: value })
72
+ environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: value } }
73
+ aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(environment_change)
71
74
 
72
75
  self
73
76
  end
@@ -85,7 +88,8 @@ module Aruba
85
88
  aruba.environment.delete name
86
89
  new_environment = aruba.environment.to_h
87
90
 
88
- aruba.event_bus.notify Events::DeletedEnvironmentVariable.new(old: old_environment, new: new_environment, changed: { name: name, value: '' })
91
+ environment_change = { old: old_environment, new: new_environment, changed: { name: name, value: '' } }
92
+ aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(environment_change)
89
93
 
90
94
  self
91
95
  end
@@ -104,7 +104,9 @@ module Aruba
104
104
  # The content of directory
105
105
  def list(name)
106
106
  fail ArgumentError, %(Path "#{name}" does not exist.) unless exist? name
107
- fail ArgumentError, %(Only directories are supported. Path "#{name}" is not a directory.) unless directory? name
107
+ unless directory? name
108
+ fail ArgumentError, %(Only directories are supported. Path "#{name}" is not a directory.)
109
+ end
108
110
 
109
111
  existing_files = Dir.glob(expand_path(File.join(name, '**', '*')))
110
112
  current_working_directory = ArubaPath.new(expand_path('.'))
@@ -181,8 +183,13 @@ module Aruba
181
183
  raise ArgumentError, %(The following source "#{s}" does not exist.) unless exist? s
182
184
  end
183
185
 
184
- raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported" if destination.start_with? aruba.config.fixtures_path_prefix
185
- raise ArgumentError, 'Multiples sources can only be copied to a directory' if source.count > 1 && exist?(destination) && !directory?(destination)
186
+ if destination.start_with? aruba.config.fixtures_path_prefix
187
+ raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported"
188
+ end
189
+
190
+ if source.count > 1 && exist?(destination) && !directory?(destination)
191
+ raise ArgumentError, 'Multiples sources can only be copied to a directory'
192
+ end
186
193
 
187
194
  source_paths = source.map { |f| expand_path(f) }
188
195
  destination_path = expand_path(destination)
@@ -219,16 +226,22 @@ module Aruba
219
226
  source = args
220
227
 
221
228
  source.each do |s|
222
- raise ArgumentError, "Using a fixture as source (#{source}) is not supported" if s.start_with? aruba.config.fixtures_path_prefix
229
+ if s.start_with? aruba.config.fixtures_path_prefix
230
+ raise ArgumentError, "Using a fixture as source (#{source}) is not supported"
231
+ end
223
232
  end
224
233
 
225
- raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported" if destination.start_with? aruba.config.fixtures_path_prefix
234
+ if destination.start_with? aruba.config.fixtures_path_prefix
235
+ raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported"
236
+ end
226
237
 
227
238
  source.each do |s|
228
239
  raise ArgumentError, %(The following source "#{s}" does not exist.) unless exist? s
229
240
  end
230
241
 
231
- raise ArgumentError, 'Multiple sources can only be copied to a directory' if source.count > 1 && exist?(destination) && !directory?(destination)
242
+ if source.count > 1 && exist?(destination) && !directory?(destination)
243
+ raise ArgumentError, 'Multiple sources can only be copied to a directory'
244
+ end
232
245
 
233
246
  source_paths = source.map { |f| expand_path(f) }
234
247
  destination_path = expand_path(destination)
@@ -1,108 +1,19 @@
1
+ # Aruba
1
2
  module Aruba
2
- # The ANSIColor module can be used for namespacing and mixed into your own
3
- # classes.
4
- module AnsiColor
5
- # :stopdoc:
6
- ATTRIBUTES = [
7
- [:clear, 0],
8
- [:reset, 0], # synonym for :clear
9
- [:bold, 1],
10
- [:dark, 2],
11
- [:italic, 3], # not widely implemented
12
- [:underline, 4],
13
- [:underscore, 4], # synonym for :underline
14
- [:blink, 5],
15
- [:rapid_blink, 6], # not widely implemented
16
- [:negative, 7], # no reverse because of String#reverse
17
- [:concealed, 8],
18
- [:strikethrough, 9], # not widely implemented
19
- [:black, 30],
20
- [:red, 31],
21
- [:green, 32],
22
- [:yellow, 33],
23
- [:blue, 34],
24
- [:magenta, 35],
25
- [:cyan, 36],
26
- [:white, 37],
27
- [:on_black, 40],
28
- [:on_red, 41],
29
- [:on_green, 42],
30
- [:on_yellow, 43],
31
- [:on_blue, 44],
32
- [:on_magenta, 45],
33
- [:on_cyan, 46],
34
- [:on_white, 47]
35
- ].freeze
36
-
37
- ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
38
- # :startdoc:
39
-
40
- # Returns true, if the coloring function of this module
41
- # is switched on, false otherwise.
42
- def self.coloring?
43
- @coloring
44
- end
45
-
46
- # Turns the coloring on or off globally, so you can easily do
47
- # this for example:
48
- # Cucumber::Term::ANSIColor::coloring = STDOUT.isatty
49
- def self.coloring=(val)
50
- @coloring = val
51
- end
52
- self.coloring = true
53
-
54
- ATTRIBUTES.each do |c, v|
55
- define_method(c) do |string|
56
- result = ''
57
- result << "\e[#{v}m" if Aruba::AnsiColor.coloring?
58
- if block_given?
59
- result << yield
60
- elsif string
61
- result << string
62
- elsif respond_to?(:to_str)
63
- result << to_str
64
- else
65
- return result # only switch on
66
- end
67
- result << "\e[0m" if Aruba::AnsiColor.coloring?
68
- result
69
- end
70
- end
71
-
72
- # Regular expression that is used to scan for ANSI-sequences while
73
- # uncoloring strings.
74
- COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/
75
-
76
- def self.included(klass)
77
- return unless klass == String
3
+ # Simple colorizer class. Only supports the color cyan
4
+ class Colorizer
5
+ class << self
6
+ attr_accessor :coloring
78
7
 
79
- ATTRIBUTES.delete(:clear)
80
- ATTRIBUTE_NAMES.delete(:clear)
8
+ alias coloring? coloring
81
9
  end
82
10
 
83
- # Returns an uncolored version of the string, that is all
84
- # ANSI-sequences are stripped from the string.
85
- def uncolored(string = nil) # :yields:
86
- if block_given?
87
- yield.gsub(COLORED_REGEXP, '')
88
- elsif string
89
- string.gsub(COLORED_REGEXP, '')
90
- elsif respond_to?(:to_str)
91
- to_str.gsub(COLORED_REGEXP, '')
11
+ def cyan(string)
12
+ if self.class.coloring?
13
+ "\e[36m#{string}\e[0m"
92
14
  else
93
- ''
15
+ string
94
16
  end
95
17
  end
96
-
97
- # Returns an array of all Aruba::Platforms::AnsiColor attributes as symbols.
98
- def attributes
99
- ATTRIBUTE_NAMES
100
- end
101
- end
102
- end
103
-
104
- module Aruba
105
- class Colorizer
106
- include Aruba::AnsiColor
107
18
  end
108
19
  end
@@ -2,16 +2,26 @@ require 'rbconfig'
2
2
 
3
3
  # ideas taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html
4
4
  Aruba.configure do |config|
5
- config.before :command do
5
+ config.before :command do |command|
6
6
  next unless RUBY_PLATFORM == 'java'
7
7
 
8
+ env = command.environment
9
+
10
+ jruby_opts = env['JRUBY_OPTS'] || ''
11
+
8
12
  # disable JIT since these processes are so short lived
9
- ENV['JRUBY_OPTS'] = "-X-C #{ENV['JRUBY_OPTS']}" unless (ENV['JRUBY_OPTS'] || '') .include? '-X-C'
13
+ jruby_opts = "-X-C #{jruby_opts}" unless jruby_opts.include? '-X-C'
10
14
 
11
15
  # Faster startup for jruby
12
- ENV['JRUBY_OPTS'] = "--dev #{ENV['JRUBY_OPTS']}" unless (ENV['JRUBY_OPTS'] || '').include? '--dev'
16
+ jruby_opts = "--dev #{jruby_opts}" unless jruby_opts.include? '--dev'
17
+
18
+ env['JRUBY_OPTS'] = jruby_opts
19
+
20
+ if RbConfig::CONFIG['host_os'] =~ /solaris|sunos/i
21
+ java_opts = env['JAVA_OPTS'] || ''
13
22
 
14
- # force jRuby to use client JVM for faster startup times
15
- ENV['JAVA_OPTS'] = "-d32 #{ENV['JAVA_OPTS']}" if RbConfig::CONFIG['host_os'] =~ /solaris|sunos/i && !(ENV['JAVA_OPTS'] || '').include?('-d32')
23
+ # force jRuby to use client JVM for faster startup times
24
+ env['JAVA_OPTS'] = "-d32 #{java_opts}" unless java_opts.include?('-d32')
25
+ end
16
26
  end
17
27
  end
@@ -30,7 +30,9 @@ 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
+ if name.to_s.end_with? '='
34
+ event_bus.notify Events::ChangedConfiguration.new(changed: { name: name.to_s.gsub(/=$/, ''), value: args.first })
35
+ end
34
36
 
35
37
  config.send(name, *args, &block)
36
38
  end
@@ -19,7 +19,9 @@ module Aruba
19
19
  class Configuration < BasicConfiguration
20
20
  option_reader :root_directory, contract: { None => String }, default: Dir.getwd
21
21
 
22
- option_accessor :working_directory, contract: { Aruba::Contracts::RelativePath => Aruba::Contracts::RelativePath }, default: 'tmp/aruba'
22
+ option_accessor :working_directory,
23
+ contract: { Aruba::Contracts::RelativePath => Aruba::Contracts::RelativePath },
24
+ default: 'tmp/aruba'
23
25
 
24
26
  option_reader :fixtures_path_prefix, contract: { None => String }, default: '%'
25
27
 
@@ -27,26 +29,36 @@ module Aruba
27
29
  option_accessor :stop_signal, contract: { Maybe[String] => Maybe[String] }, default: nil
28
30
  option_accessor :io_wait_timeout, contract: { Num => Num }, default: 0.1
29
31
  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)
32
+ option_accessor :fixtures_directories,
33
+ contract: { Array => ArrayOf[String] },
34
+ default: %w(features/fixtures spec/fixtures test/fixtures fixtures)
35
+
31
36
  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
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')]
40
+ end
35
41
  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
42
+ option_accessor :command_launcher,
43
+ contract: { Aruba::Contracts::Enum[:in_process, :spawn, :debug] => Aruba::Contracts::Enum[:in_process, :spawn, :debug] },
44
+ default: :spawn
38
45
  option_accessor :main_class, contract: { Class => Maybe[Class] }, default: nil
39
46
 
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
47
+ 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
43
51
 
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
52
+ 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] },
54
+ default: :info
45
55
 
46
56
  # TODO: deprecate this value and replace with "filesystem allocation unit"
47
57
  # equal to 4096 by default. "filesystem allocation unit" would represent
48
58
  # 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
59
+ option_accessor :physical_block_size,
60
+ contract: { Aruba::Contracts::IsPowerOfTwo => Aruba::Contracts::IsPowerOfTwo },
61
+ default: 512
50
62
  option_accessor :console_history_file, contract: { String => String }, default: '~/.aruba_history'
51
63
 
52
64
  option_accessor :activate_announcer_on_command_failure, contract: { ArrayOf[Symbol] => ArrayOf[Symbol] }, default: []
@@ -1,8 +1,6 @@
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'
@@ -23,8 +23,7 @@ When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) do
23
23
  end
24
24
 
25
25
  When(/^I run `([^`]*)` interactively$/) do |cmd|
26
- cmd = sanitize_text(cmd)
27
- @interactive = run_command(cmd)
26
+ run_command(sanitize_text(cmd))
28
27
  end
29
28
 
30
29
  # Merge interactive and background after refactoring with event queue
@@ -119,7 +118,25 @@ Then(/^the output should be (\d+) bytes long$/) do |size|
119
118
  expect(last_command_started.output).to have_output_size size.to_i
120
119
  end
121
120
 
122
- Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain( exactly)? "([^"]*)"$/) do |channel, cmd, negated, exactly, expected|
121
+ ## the stderr should contain "hello"
122
+ Then(/^(?:the )?(output|stderr|stdout) should( not)? contain( exactly)? "([^"]*)"$/) do |channel, negated, exactly, expected|
123
+ combined_output = send("all_#{channel}")
124
+
125
+ output_string_matcher = if exactly
126
+ :an_output_string_being_eq
127
+ else
128
+ :an_output_string_including
129
+ end
130
+
131
+ if negated
132
+ expect(combined_output).not_to send(output_string_matcher, expected)
133
+ else
134
+ expect(combined_output).to send(output_string_matcher, expected)
135
+ end
136
+ end
137
+
138
+ ## 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|
123
140
  matcher = case channel.to_sym
124
141
  when :output
125
142
  :have_output
@@ -129,11 +146,7 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
129
146
  :have_output_on_stdout
130
147
  end
131
148
 
132
- commands = if cmd
133
- [aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))]
134
- else
135
- all_commands
136
- end
149
+ command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
137
150
 
138
151
  output_string_matcher = if exactly
139
152
  :an_output_string_being_eq
@@ -142,17 +155,62 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
142
155
  end
143
156
 
144
157
  if negated
145
- expect(commands).not_to include_an_object send(matcher, send(output_string_matcher, expected))
158
+ expect(command).not_to send(matcher, send(output_string_matcher, expected))
146
159
  else
147
- expect(commands).to include_an_object send(matcher, send(output_string_matcher, expected))
160
+ expect(command).to send(matcher, send(output_string_matcher, expected))
148
161
  end
149
162
  end
150
163
 
151
- ## the stderr should contain "hello"
152
- ## the stderr from "echo -n 'Hello'" should contain "hello"
164
+ ## the stderr should not contain exactly:
165
+ Then(/^(?:the )?(output|stderr|stdout) should not contain( exactly)?:$/) do |channel, exactly, expected|
166
+ combined_output = send("all_#{channel}")
167
+
168
+ output_string_matcher = if exactly
169
+ :an_output_string_being_eq
170
+ else
171
+ :an_output_string_including
172
+ end
173
+
174
+ expect(combined_output).not_to send(output_string_matcher, expected)
175
+ end
176
+
153
177
  ## the stderr should contain exactly:
178
+ Then(/^(?:the )?(output|stderr|stdout) should contain( exactly)?:$/) do |channel, exactly, expected|
179
+ combined_output = send("all_#{channel}")
180
+
181
+ output_string_matcher = if exactly
182
+ :an_output_string_being_eq
183
+ else
184
+ :an_output_string_including
185
+ end
186
+
187
+ expect(combined_output).to send(output_string_matcher, expected)
188
+ end
189
+
190
+ ## 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
199
+ end
200
+
201
+ command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
202
+
203
+ output_string_matcher = if exactly
204
+ :an_output_string_being_eq
205
+ else
206
+ :an_output_string_including
207
+ end
208
+
209
+ expect(command).not_to send(matcher, send(output_string_matcher, expected))
210
+ end
211
+
154
212
  ## the stderr from "echo -n 'Hello'" should contain exactly:
155
- Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain( exactly)?:$/) do |channel, cmd, negated, exactly, expected|
213
+ Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should contain( exactly)?:$/) do |channel, cmd, exactly, expected|
156
214
  matcher = case channel.to_sym
157
215
  when :output
158
216
  :have_output
@@ -160,15 +218,9 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
160
218
  :have_output_on_stderr
161
219
  when :stdout
162
220
  :have_output_on_stdout
163
- else
164
- fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stderr" or "stdout" are allowed.)
165
221
  end
166
222
 
167
- commands = if cmd
168
- [aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))]
169
- else
170
- all_commands
171
- end
223
+ command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
172
224
 
173
225
  output_string_matcher = if exactly
174
226
  :an_output_string_being_eq
@@ -176,11 +228,7 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
176
228
  :an_output_string_including
177
229
  end
178
230
 
179
- if negated
180
- expect(commands).not_to include_an_object send(matcher, send(output_string_matcher, expected))
181
- else
182
- expect(commands).to include_an_object send(matcher, send(output_string_matcher, expected))
183
- end
231
+ expect(command).to send(matcher, send(output_string_matcher, expected))
184
232
  end
185
233
 
186
234
  # "the output should match" allows regex in the partial_output, if
@@ -223,7 +271,7 @@ Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
223
271
  end
224
272
  end
225
273
 
226
- Then(/^it should( not)? (pass|fail) with "(.*?)"$/) do |negated, pass_fail, expected|
274
+ Then(/^it should not (pass|fail) with "(.*?)"$/) do |pass_fail, expected|
227
275
  last_command_started.stop
228
276
 
229
277
  if pass_fail == 'pass'
@@ -232,14 +280,22 @@ Then(/^it should( not)? (pass|fail) with "(.*?)"$/) do |negated, pass_fail, expe
232
280
  expect(last_command_stopped).not_to be_successfully_executed
233
281
  end
234
282
 
235
- if negated
236
- expect(last_command_stopped).not_to have_output an_output_string_including(expected)
283
+ expect(last_command_stopped).not_to have_output an_output_string_including(expected)
284
+ end
285
+
286
+ Then(/^it should (pass|fail) with "(.*?)"$/) do |pass_fail, expected|
287
+ last_command_started.stop
288
+
289
+ if pass_fail == 'pass'
290
+ expect(last_command_stopped).to be_successfully_executed
237
291
  else
238
- expect(last_command_stopped).to have_output an_output_string_including(expected)
292
+ expect(last_command_stopped).not_to be_successfully_executed
239
293
  end
294
+
295
+ expect(last_command_stopped).to have_output an_output_string_including(expected)
240
296
  end
241
297
 
242
- Then(/^it should( not)? (pass|fail) with:$/) do |negated, pass_fail, expected|
298
+ Then(/^it should not (pass|fail) with:$/) do |pass_fail, expected|
243
299
  last_command_started.stop
244
300
 
245
301
  if pass_fail == 'pass'
@@ -248,14 +304,22 @@ Then(/^it should( not)? (pass|fail) with:$/) do |negated, pass_fail, expected|
248
304
  expect(last_command_stopped).not_to be_successfully_executed
249
305
  end
250
306
 
251
- if negated
252
- expect(last_command_stopped).not_to have_output an_output_string_including(expected)
307
+ expect(last_command_stopped).not_to have_output an_output_string_including(expected)
308
+ end
309
+
310
+ Then(/^it should (pass|fail) with:$/) do |pass_fail, expected|
311
+ last_command_started.stop
312
+
313
+ if pass_fail == 'pass'
314
+ expect(last_command_stopped).to be_successfully_executed
253
315
  else
254
- expect(last_command_stopped).to have_output an_output_string_including(expected)
316
+ expect(last_command_stopped).not_to be_successfully_executed
255
317
  end
318
+
319
+ expect(last_command_stopped).to have_output an_output_string_including(expected)
256
320
  end
257
321
 
258
- Then(/^it should( not)? (pass|fail) with exactly:$/) do |negated, pass_fail, expected|
322
+ Then(/^it should not (pass|fail) with exactly:$/) do |pass_fail, expected|
259
323
  last_command_started.stop
260
324
 
261
325
  if pass_fail == 'pass'
@@ -264,14 +328,22 @@ Then(/^it should( not)? (pass|fail) with exactly:$/) do |negated, pass_fail, exp
264
328
  expect(last_command_stopped).not_to be_successfully_executed
265
329
  end
266
330
 
267
- if negated
268
- expect(last_command_stopped).not_to have_output an_output_string_eq(expected)
331
+ expect(last_command_stopped).not_to have_output an_output_string_eq(expected)
332
+ end
333
+
334
+ Then(/^it should (pass|fail) with exactly:$/) do |pass_fail, expected|
335
+ last_command_started.stop
336
+
337
+ if pass_fail == 'pass'
338
+ expect(last_command_stopped).to be_successfully_executed
269
339
  else
270
- expect(last_command_stopped).to have_output an_output_string_being_eq(expected)
340
+ expect(last_command_stopped).not_to be_successfully_executed
271
341
  end
342
+
343
+ expect(last_command_stopped).to have_output an_output_string_being_eq(expected)
272
344
  end
273
345
 
274
- Then(/^it should( not)? (pass|fail) (?:with regexp?|matching):$/) do |negated, pass_fail, expected|
346
+ Then(/^it should not (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected|
275
347
  last_command_started.stop
276
348
 
277
349
  if pass_fail == 'pass'
@@ -280,11 +352,19 @@ Then(/^it should( not)? (pass|fail) (?:with regexp?|matching):$/) do |negated, p
280
352
  expect(last_command_stopped).not_to be_successfully_executed
281
353
  end
282
354
 
283
- if negated
284
- expect(last_command_stopped).not_to have_output an_output_string_matching(expected)
355
+ expect(last_command_stopped).not_to have_output an_output_string_matching(expected)
356
+ end
357
+
358
+ Then(/^it should (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected|
359
+ last_command_started.stop
360
+
361
+ if pass_fail == 'pass'
362
+ expect(last_command_stopped).to be_successfully_executed
285
363
  else
286
- expect(last_command_stopped).to have_output an_output_string_matching(expected)
364
+ expect(last_command_stopped).not_to be_successfully_executed
287
365
  end
366
+
367
+ expect(last_command_stopped).to have_output an_output_string_matching(expected)
288
368
  end
289
369
 
290
370
  Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channel|
@@ -295,8 +375,6 @@ Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channe
295
375
  :have_output_on_stderr
296
376
  when :stdout
297
377
  :have_output_on_stdout
298
- else
299
- fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stdout" and "stderr" are supported.)
300
378
  end
301
379
 
302
380
  expect(all_commands).to include_an_object send(matcher, be_nil.or(be_empty))
@@ -311,10 +389,10 @@ Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:
311
389
  :have_output_on_stderr
312
390
  when :stdout
313
391
  :have_output_on_stdout
314
- else
315
- fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stdout" and "stderr" are supported.)
316
392
  end
317
393
 
394
+ # TODO: This isn't actually using the above. It's hardcoded to use have_output only
395
+
318
396
  if negated
319
397
  expect(all_commands).not_to include_an_object have_output an_output_string_including(expected)
320
398
  else