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
@@ -88,21 +88,19 @@ Then(/^the following files should (not )?exist:$/) do |negated, files|
88
88
  end
89
89
  end
90
90
 
91
- Then(/^(?:a|the) (file|directory)(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) do |directory_or_file, path, expect_match|
92
- if directory_or_file == 'file'
93
- if expect_match
94
- expect(path).not_to be_an_existing_file
95
- else
96
- expect(path).to be_an_existing_file
97
- end
98
- elsif directory_or_file == 'directory'
99
- if expect_match
100
- expect(path).not_to be_an_existing_directory
101
- else
102
- expect(path).to be_an_existing_directory
103
- end
91
+ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) do |path, expect_match|
92
+ if expect_match
93
+ expect(path).not_to be_an_existing_file
94
+ else
95
+ expect(path).to be_an_existing_file
96
+ end
97
+ end
98
+
99
+ Then(/^(?:a|the) directory(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) do |path, expect_match|
100
+ if expect_match
101
+ expect(path).not_to be_an_existing_directory
104
102
  else
105
- fail ArgumentError, %("#{directory_or_file}" can only be "directory" or "file".)
103
+ expect(path).to be_an_existing_directory
106
104
  end
107
105
  end
108
106
 
@@ -180,7 +178,7 @@ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?be equal to file "([^"]
180
178
  end
181
179
  end
182
180
 
183
- Then(/^the (?:file|directory)(?: named)? "([^"]*)" should( not)? have permissions "([^"]*)"$/) do |path, negated, permissions|
181
+ Then(/^(?:a|the) (?:file|directory)(?: named)? "([^"]*)" should( not)? have permissions "([^"]*)"$/) do |path, negated, permissions|
184
182
  if negated
185
183
  expect(path).not_to have_permissions(permissions)
186
184
  else
@@ -1,25 +1,33 @@
1
1
  # Cucumber
2
- Then /^the feature(?:s)? should( not)?(?: all)? pass$/ do |negated|
3
- if negated
4
- step 'the output should contain " failed)"'
5
- step 'the exit status should be 1'
6
- else
7
- step 'the output should not contain " failed)"'
8
- step 'the output should not contain " undefined)"'
9
- step 'the exit status should be 0'
10
- end
2
+ Then /^the feature(?:s)? should not(?: all)? pass$/ do
3
+ step 'the output should contain " failed)"'
4
+ step 'the exit status should be 1'
5
+ end
6
+
7
+ # Cucumber
8
+ Then /^the feature(?:s)? should(?: all)? pass$/ do
9
+ step 'the output should not contain " failed)"'
10
+ step 'the output should not contain " undefined)"'
11
+ step 'the exit status should be 0'
11
12
  end
12
13
 
13
14
  # Cucumber
14
- Then /^the feature(?:s)? should( not)?(?: all)? pass with( regex)?:$/ do |negated, regex, string|
15
- if negated
16
- step 'the output should contain " failed)"'
17
- step 'the exit status should be 1'
15
+ Then /^the feature(?:s)? should not(?: all)? pass with( regex)?:$/ do |regex, string|
16
+ step 'the output should contain " failed)"'
17
+ step 'the exit status should be 1'
18
+
19
+ if regex
20
+ step "the output should match %r<#{string}>"
18
21
  else
19
- step 'the output should not contain " failed)"'
20
- step 'the output should not contain " undefined)"'
21
- step 'the exit status should be 0'
22
+ step 'the output should contain:', string
22
23
  end
24
+ end
25
+
26
+ # Cucumber
27
+ Then /^the feature(?:s)? should(?: all)? pass with( regex)?:$/ do |regex, string|
28
+ step 'the output should not contain " failed)"'
29
+ step 'the output should not contain " undefined)"'
30
+ step 'the exit status should be 0'
23
31
 
24
32
  if regex
25
33
  step "the output should match %r<#{string}>"
@@ -29,30 +37,38 @@ Then /^the feature(?:s)? should( not)?(?: all)? pass with( regex)?:$/ do |negate
29
37
  end
30
38
 
31
39
  # RSpec
32
- Then /^the spec(?:s)? should( not)?(?: all)? pass(?: with (\d+) failures?)?$/ do |negated, count_failures|
33
- if negated
34
- if count_failures.nil?
35
- step 'the output should not contain "0 failures"'
36
- else
37
- step %(the output should contain "#{count_failures} failures")
38
- end
39
-
40
- step 'the exit status should be 1'
40
+ Then /^the spec(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/ do |count_failures|
41
+ if count_failures.nil?
42
+ step 'the output should not contain "0 failures"'
41
43
  else
42
- step 'the output should contain "0 failures"'
43
- step 'the exit status should be 0'
44
+ step %(the output should contain "#{count_failures} failures")
44
45
  end
46
+
47
+ step 'the exit status should be 1'
45
48
  end
46
49
 
47
50
  # RSpec
48
- Then /^the spec(?:s)? should( not)?(?: all)? pass with( regex)?:$/ do |negated, regex, string|
49
- if negated
50
- step 'the output should not contain "0 failures"'
51
- step 'the exit status should be 1'
51
+ Then /^the spec(?:s)? should all pass$/ do
52
+ step 'the output should contain "0 failures"'
53
+ step 'the exit status should be 0'
54
+ end
55
+
56
+ # RSpec
57
+ Then /^the spec(?:s)? should not(?: all)? pass with( regex)?:$/ do |regex, string|
58
+ step 'the output should not contain "0 failures"'
59
+ step 'the exit status should be 1'
60
+
61
+ if regex
62
+ step "the output should match %r<#{string}>"
52
63
  else
53
- step 'the output should contain "0 failures"'
54
- step 'the exit status should be 0'
64
+ step 'the output should contain:', string
55
65
  end
66
+ end
67
+
68
+ # RSpec
69
+ Then /^the spec(?:s)? should(?: all)? pass with( regex)?:$/ do |regex, string|
70
+ step 'the output should contain "0 failures"'
71
+ step 'the exit status should be 0'
56
72
 
57
73
  if regex
58
74
  step "the output should match %r<#{string}>"
@@ -62,30 +78,38 @@ Then /^the spec(?:s)? should( not)?(?: all)? pass with( regex)?:$/ do |negated,
62
78
  end
63
79
 
64
80
  # Minitest
65
- Then /^the tests(?:s)? should( not)?(?: all)? pass(?: with (\d+) failures?)?$/ do |negated, count_failures|
66
- if negated
67
- if count_failures.nil?
68
- step 'the output should not contain "0 errors"'
69
- else
70
- step %(the output should contain "#{count_failures} errors")
71
- end
72
-
73
- step 'the exit status should be 1'
81
+ Then /^the tests(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/ do |count_failures|
82
+ if count_failures.nil?
83
+ step 'the output should not contain "0 errors"'
74
84
  else
75
- step 'the output should contain "0 errors"'
76
- step 'the exit status should be 0'
85
+ step %(the output should contain "#{count_failures} errors")
77
86
  end
87
+
88
+ step 'the exit status should be 1'
78
89
  end
79
90
 
80
91
  # Minitest
81
- Then /^the test(?:s)? should( not)?(?: all)? pass with( regex)?:$/ do |negated, regex, string|
82
- if negated
83
- step 'the output should contain "0 errors"'
84
- step 'the exit status should be 1'
92
+ Then /^the tests(?:s)? should all pass$/ do
93
+ step 'the output should contain "0 errors"'
94
+ step 'the exit status should be 0'
95
+ end
96
+
97
+ # Minitest
98
+ Then /^the test(?:s)? should not(?: all)? pass with( regex)?:$/ do |regex, string|
99
+ step 'the output should contain "0 errors"'
100
+ step 'the exit status should be 1'
101
+
102
+ if regex
103
+ step "the output should match %r<#{string}>"
85
104
  else
86
- step 'the output should not contain "0 errors"'
87
- step 'the exit status should be 0'
105
+ step 'the output should contain:', string
88
106
  end
107
+ end
108
+
109
+ # Minitest
110
+ Then /^the test(?:s)? should(?: all)? pass with( regex)?:$/ do |regex, string|
111
+ step 'the output should not contain "0 errors"'
112
+ step 'the exit status should be 0'
89
113
 
90
114
  if regex
91
115
  step "the output should match %r<#{string}>"
@@ -15,10 +15,14 @@ module Aruba
15
15
  end
16
16
 
17
17
  def method_missing(name, *args)
18
- fail ArgumentError, 'Options take no argument' if args.count > 0
18
+ fail ArgumentError, 'Options take no argument' if args.any?
19
19
  fail UnknownOptionError, %(Option "#{name}" is unknown. Please use only earlier defined options) unless config.key? name
20
20
 
21
21
  config[name]
22
22
  end
23
+
24
+ def respond_to_missing?(*)
25
+ true
26
+ end
23
27
  end
24
28
  end
@@ -80,18 +80,18 @@ module Aruba
80
80
  :create_file
81
81
  end
82
82
 
83
- send creator, file, <<-EOS
84
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
83
+ send creator, file, <<~EOS
84
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
85
85
 
86
- ::Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
87
- ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
88
- EOS
86
+ ::Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
87
+ ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
88
+ EOS
89
89
  end
90
90
 
91
91
  def create_support_file
92
- create_file 'spec/support/aruba.rb', <<-EOS
93
- require 'aruba/rspec'
94
- EOS
92
+ create_file 'spec/support/aruba.rb', <<~EOS
93
+ require 'aruba/rspec'
94
+ EOS
95
95
  end
96
96
  end
97
97
  end
@@ -114,9 +114,9 @@ module Aruba
114
114
  end
115
115
 
116
116
  def create_support_file
117
- create_file 'features/support/aruba.rb', <<-EOS
118
- require 'aruba/cucumber'
119
- EOS
117
+ create_file 'features/support/aruba.rb', <<~EOS
118
+ require 'aruba/cucumber'
119
+ EOS
120
120
  end
121
121
  end
122
122
  end
@@ -146,30 +146,30 @@ module Aruba
146
146
  :create_file
147
147
  end
148
148
 
149
- send creator, file, <<-EOS
150
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
149
+ send creator, file, <<~EOS
150
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
151
151
 
152
- ::Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
153
- ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
154
- EOS
152
+ ::Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
153
+ ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
154
+ EOS
155
155
  end
156
156
 
157
157
  def create_example
158
- create_file 'test/use_aruba_with_minitest.rb', <<-EOS
159
- $LOAD_PATH.unshift File.expand_path('../test', __FILE__)
158
+ create_file 'test/use_aruba_with_minitest.rb', <<~EOS
159
+ $LOAD_PATH.unshift File.expand_path('../test', __FILE__)
160
160
 
161
- require 'test_helper'
162
- require 'minitest/autorun'
163
- require 'aruba/api'
161
+ require 'test_helper'
162
+ require 'minitest/autorun'
163
+ require 'aruba/api'
164
164
 
165
- class FirstRun < Minitest::Test
166
- include Aruba::Api
165
+ class FirstRun < Minitest::Test
166
+ include Aruba::Api
167
167
 
168
- def setup
169
- aruba_setup
170
- end
171
- end
172
- EOS
168
+ def setup
169
+ aruba_setup
170
+ end
171
+ end
172
+ EOS
173
173
  end
174
174
  end
175
175
  end
@@ -27,6 +27,10 @@ RSpec::Matchers.define :be_successfully_executed do
27
27
 
28
28
  expect(@old_actual).to have_exit_status(0)
29
29
  end
30
+
31
+ failure_message do |_actual|
32
+ "Expected `#{@actual}` to succeed but got non-zero exit status and the following output:\n\n#{@old_actual.output}\n"
33
+ end
30
34
  end
31
35
 
32
36
  RSpec::Matchers.define_negated_matcher :have_failed_running, :be_successfully_executed
@@ -23,16 +23,26 @@ RSpec::Matchers.define :have_exit_status do |expected|
23
23
  @old_actual.stop
24
24
  @actual = actual.exit_status
25
25
 
26
- next false unless @old_actual.respond_to? :exit_status
26
+ raise "Expected #{@old_actual} to respond to #exit_status" unless @old_actual.respond_to? :exit_status
27
27
 
28
28
  values_match? expected, @actual
29
29
  end
30
30
 
31
31
  failure_message do |actual|
32
- format(%(expected that command "%s" has exit status of "%s", but has "%s".), @old_actual.commandline, expected.to_s, actual.to_s)
32
+ format(
33
+ %(expected that command "%s" has exit status of "%s", but has "%s".),
34
+ @old_actual.commandline,
35
+ expected.to_s,
36
+ actual.to_s
37
+ )
33
38
  end
34
39
 
35
40
  failure_message_when_negated do |actual|
36
- format(%(expected that command "%s" does not have exit status of "%s", but has "%s".), @old_actual.commandline, expected.to_s, actual.to_s)
41
+ format(
42
+ %(expected that command "%s" does not have exit status of "%s", but has "%s".),
43
+ @old_actual.commandline,
44
+ expected.to_s,
45
+ actual.to_s
46
+ )
37
47
  end
38
48
  end
@@ -24,7 +24,7 @@ RSpec::Matchers.define :have_finished_in_time do
24
24
  @old_actual = actual
25
25
  @actual = @old_actual.commandline
26
26
 
27
- next false unless @old_actual.respond_to? :timed_out?
27
+ raise "Expected #{@old_actual} to respond to #timed_out?" unless @old_actual.respond_to? :timed_out?
28
28
 
29
29
  @old_actual.stop
30
30
 
@@ -19,7 +19,7 @@ RSpec::Matchers.define :have_output do |expected|
19
19
  match do |actual|
20
20
  @old_actual = actual
21
21
 
22
- next false unless @old_actual.respond_to? :output
22
+ raise "Expected #{@old_actual} to respond to #output" unless @old_actual.respond_to? :output
23
23
 
24
24
  @old_actual.stop
25
25
 
@@ -17,7 +17,7 @@ RSpec::Matchers.define :have_output_on_stderr do |expected|
17
17
  match do |actual|
18
18
  @old_actual = actual
19
19
 
20
- next false unless @old_actual.respond_to? :stderr
20
+ raise "Expected #{@old_actual} to respond to #stderr" unless @old_actual.respond_to? :stderr
21
21
 
22
22
  @old_actual.stop
23
23
 
@@ -17,7 +17,7 @@ RSpec::Matchers.define :have_output_on_stdout do |expected|
17
17
  match do |actual|
18
18
  @old_actual = actual
19
19
 
20
- next false unless @old_actual.respond_to? :stdout
20
+ raise "Expected #{@old_actual} to respond to #stdout" unless @old_actual.respond_to? :stdout
21
21
 
22
22
  @old_actual.stop
23
23
 
@@ -18,7 +18,7 @@
18
18
  # end
19
19
  RSpec::Matchers.define :have_output_size do |expected|
20
20
  match do |actual|
21
- next false unless actual.respond_to? :size
21
+ raise "Expected #{actual} to respond to #size" unless actual.respond_to? :size
22
22
 
23
23
  @actual = actual.size
24
24
  values_match? expected, @actual
@@ -19,7 +19,7 @@ RSpec::Matchers.define :be_an_existing_directory do |_|
19
19
  match do |actual|
20
20
  stop_all_commands
21
21
 
22
- next false unless actual.is_a? String
22
+ raise 'String expected' unless actual.is_a? String
23
23
 
24
24
  directory?(actual)
25
25
  end
@@ -19,7 +19,7 @@ RSpec::Matchers.define :be_an_existing_file do |_|
19
19
  match do |actual|
20
20
  stop_all_commands
21
21
 
22
- next false unless actual.is_a? String
22
+ raise 'String expected' unless actual.is_a? String
23
23
 
24
24
  file?(actual)
25
25
  end
@@ -4,16 +4,9 @@ require 'aruba/platforms/windows_platform'
4
4
  # Aruba
5
5
  module Aruba
6
6
  PLATFORM_MUTEX = Mutex.new
7
- end
8
7
 
9
- # Aruba
10
- module Aruba
11
- # Platform
12
8
  Platform = [Platforms::WindowsPlatform, Platforms::UnixPlatform].find(&:match?)
13
- end
14
9
 
15
- # Aruba
16
- module Aruba
17
10
  PLATFORM_MUTEX.synchronize do
18
11
  @platform = Platform.new
19
12
  end
@@ -1,7 +1,7 @@
1
1
  require 'shellwords'
2
2
  require 'aruba/colorizer'
3
3
 
4
- Aruba::AnsiColor.coloring = false if !STDOUT.tty? && !ENV.key?('AUTOTEST')
4
+ Aruba::Colorizer.coloring = false if !STDOUT.tty? && !ENV.key?('AUTOTEST')
5
5
 
6
6
  # Aruba
7
7
  module Aruba
@@ -92,9 +92,9 @@ module Aruba
92
92
  output_format :stop_signal, proc { |p, s| format('Command will be stopped with `kill -%s %s`', s, p) }
93
93
  output_format :timeout, '# %s-timeout: %s seconds'
94
94
  output_format :wait_time, '# %s: %s seconds'
95
- # rubocop:disable Metrics/LineLength
96
- output_format :command_filesystem_status, proc { |status| format("<<-COMMAND FILESYSTEM STATUS\n%s\nCOMMAND FILESYSTEM STATUS", Aruba.platform.simple_table(status.to_h, sort: false)) }
97
- # rubocop:enable Metrics/LineLength
95
+ output_format :command_filesystem_status, proc { |status|
96
+ format("<<-COMMAND FILESYSTEM STATUS\n%s\nCOMMAND FILESYSTEM STATUS",
97
+ Aruba.platform.simple_table(status.to_h, sort: false)) }
98
98
  end
99
99
 
100
100
  def output_format(channel, string = '%s', &block)
@@ -171,13 +171,18 @@ module Aruba
171
171
 
172
172
  return unless activated?(channel)
173
173
 
174
- message = if block_given?
175
- the_output_format.call(yield)
176
- else
177
- the_output_format.call(*args)
178
- end
179
- message += "\n"
180
- message = colorizer.cyan(message)
174
+ begin
175
+ if block_given?
176
+ value = yield
177
+ args << value
178
+ end
179
+
180
+ message = the_output_format.call(*args)
181
+ message += "\n"
182
+ message = colorizer.cyan(message)
183
+ rescue NotImplementedError => e
184
+ message = "Error fetching announced value for #{channel}: #{e.message}"
185
+ end
181
186
 
182
187
  announcer.announce(message)
183
188