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
@@ -33,7 +33,9 @@ module Aruba
33
33
  def register(event_ids, handler_object = nil, &handler_proc)
34
34
  handler = handler_proc || handler_object
35
35
 
36
- fail ArgumentError, 'Please pass either an object#call or a handler block' if handler.nil? || !handler.respond_to?(:call)
36
+ if handler.nil? || !handler.respond_to?(:call)
37
+ raise ArgumentError, 'Please pass either an object#call or a handler block'
38
+ end
37
39
 
38
40
  Array(event_ids).flatten.each do |id|
39
41
  @handlers[
@@ -51,7 +53,7 @@ module Aruba
51
53
  # handler.
52
54
  #
53
55
  def notify(event)
54
- fail NoEventError, 'Please pass an event object, not a class' if event.is_a?(Class)
56
+ raise NoEventError, 'Please pass an event object, not a class' if event.is_a?(Class)
55
57
 
56
58
  @handlers[event.class.to_s].each { |handler| handler.call(event) }
57
59
  end
@@ -15,11 +15,11 @@ module Aruba
15
15
 
16
16
  # Thanks ActiveSupport
17
17
  # (Only needed to support Ruby 1.9.3 and JRuby)
18
- # rubocop:disable Metrics/CyclomaticComplexity
19
18
  def constantize(camel_cased_word)
20
19
  names = camel_cased_word.split('::')
21
20
 
22
- # Trigger a built-in NameError exception including the ill-formed constant in the message.
21
+ # Trigger a built-in NameError exception including the ill-formed
22
+ # constant in the message.
23
23
  Object.const_get(camel_cased_word) if names.empty?
24
24
 
25
25
  # Remove the first blank element in case of '::ClassName' notation.
@@ -37,20 +37,18 @@ module Aruba
37
37
 
38
38
  # Go down the ancestors to check if it is owned directly. The check
39
39
  # stops when we reach Object or the end of ancestors tree.
40
- # rubocop:disable Style/EachWithObject
41
40
  constant = constant.ancestors.inject do |const, ancestor|
42
41
  break const if ancestor == Object
43
42
  break ancestor if ancestor.const_defined?(name, false)
43
+
44
44
  const
45
45
  end
46
- # rubocop:enable Style/EachWithObject
47
46
 
48
47
  # owner is in Object, so raise
49
48
  constant.const_get(name, false)
50
49
  end
51
50
  end
52
51
  end
53
- # rubocop:enable Metrics/CyclomaticComplexity
54
52
  end
55
53
 
56
54
  # @private
@@ -121,7 +119,8 @@ module Aruba
121
119
  class FailingResolver
122
120
  class << self
123
121
  def match?(event_id)
124
- fail ArgumentError, %(Input type "#{event_id.class}" of event_id "#{event_id}" is invalid)
122
+ raise ArgumentError,
123
+ %(Input type "#{event_id.class}" of event_id "#{event_id}" is invalid)
125
124
  end
126
125
 
127
126
  def supports
@@ -148,10 +147,11 @@ module Aruba
148
147
 
149
148
  def transform(event_id)
150
149
  resolvers.find { |r| r.match? event_id }.new.transform(default_namespace, event_id)
151
- rescue => e
152
- # rubocop:disable Metrics/LineLength
153
- raise EventNameResolveError, %(Transforming "#{event_id}" into an event class failed. Supported types are: #{@resolvers.map(&:supports).flatten.join(', ')}. #{e.message}.\n\n#{e.backtrace.join("\n")})
154
- # rubocop:enable Metrics/LineLength
150
+ rescue StandardError => e
151
+ types = @resolvers.map(&:supports).flatten.join(', ')
152
+ message = "Transforming \"#{event_id}\" into an event class failed." \
153
+ " Supported types are: #{types}. #{e.message}."
154
+ raise EventNameResolveError, message, cause: e
155
155
  end
156
156
  end
157
157
  end
@@ -4,7 +4,8 @@ module Aruba
4
4
  module Events
5
5
  # Basic event
6
6
  #
7
- # This is not meant for direct use - BasicEvent.new - by users. It is inherited by normal events
7
+ # This is not meant for direct use - BasicEvent.new - by users. It is
8
+ # inherited by normal events
8
9
  #
9
10
  # @private
10
11
  class BasicEvent
@@ -18,15 +18,13 @@ module Aruba
18
18
  # @param [String, Symbol] label
19
19
  # The name of the hook
20
20
  #
21
- # @para [Proc] block
21
+ # @param [Proc] block
22
22
  # The block which should be run for the hook
23
23
  def append(label, block)
24
- if store.key?(label.to_sym) && store[label.to_sym].respond_to?(:<<)
25
- store[label.to_sym] << block
26
- else
24
+ unless store.key?(label.to_sym) && store[label.to_sym].respond_to?(:<<)
27
25
  store[label.to_sym] = []
28
- store[label.to_sym] << block
29
26
  end
27
+ store[label.to_sym] << block
30
28
  end
31
29
 
32
30
  # Run hook
@@ -15,10 +15,17 @@ 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
19
- fail UnknownOptionError, %(Option "#{name}" is unknown. Please use only earlier defined options) unless config.key? name
18
+ if config.key? name
19
+ raise ArgumentError, 'Options take no argument' if args.any?
20
20
 
21
- config[name]
21
+ config[name]
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+ def respond_to_missing?(name, _include_private)
28
+ config.key? name
22
29
  end
23
30
  end
24
31
  end
@@ -23,7 +23,12 @@ module Aruba
23
23
  end
24
24
 
25
25
  content = if File.exist? file
26
- %(gem 'aruba', '~> #{Aruba::VERSION}')
26
+ file_ends_with_carriage_return =
27
+ File.open(file, 'r').readlines.last.match(/.*\n$/)
28
+
29
+ prefix = file_ends_with_carriage_return ? '' : "\n"
30
+
31
+ %(#{prefix}gem 'aruba', '~> #{Aruba::VERSION}')
27
32
  else
28
33
  %(source 'https://rubygems.org'\ngem 'aruba', '~> #{Aruba::VERSION}'\n)
29
34
  end
@@ -49,7 +54,8 @@ module Aruba
49
54
  end
50
55
 
51
56
  def start(*)
52
- fail ArgumentError, %(Unknown test framework. Please use one of :rspec, :cucumber or :minitest)
57
+ raise ArgumentError,
58
+ %(Unknown test framework. Please use one of :rspec, :cucumber or :minitest)
53
59
  end
54
60
  end
55
61
  end
@@ -68,7 +74,7 @@ module Aruba
68
74
 
69
75
  no_commands do
70
76
  def self.match?(framework)
71
- :rspec == framework.downcase.to_sym
77
+ framework.downcase.to_sym == :rspec
72
78
  end
73
79
  end
74
80
 
@@ -80,18 +86,18 @@ module Aruba
80
86
  :create_file
81
87
  end
82
88
 
83
- send creator, file, <<-EOS
84
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
89
+ send creator, file, <<~EOS
90
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
85
91
 
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
92
+ ::Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
93
+ ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
94
+ EOS
89
95
  end
90
96
 
91
97
  def create_support_file
92
- create_file 'spec/support/aruba.rb', <<-EOS
93
- require 'aruba/rspec'
94
- EOS
98
+ create_file 'spec/support/aruba.rb', <<~EOS
99
+ require 'aruba/rspec'
100
+ EOS
95
101
  end
96
102
  end
97
103
  end
@@ -109,14 +115,14 @@ module Aruba
109
115
 
110
116
  no_commands do
111
117
  def self.match?(framework)
112
- :cucumber == framework.downcase.to_sym
118
+ framework.downcase.to_sym == :cucumber
113
119
  end
114
120
  end
115
121
 
116
122
  def create_support_file
117
- create_file 'features/support/aruba.rb', <<-EOS
118
- require 'aruba/cucumber'
119
- EOS
123
+ create_file 'features/support/aruba.rb', <<~EOS
124
+ require 'aruba/cucumber'
125
+ EOS
120
126
  end
121
127
  end
122
128
  end
@@ -134,7 +140,7 @@ module Aruba
134
140
 
135
141
  no_commands do
136
142
  def self.match?(framework)
137
- :minitest == framework.downcase.to_sym
143
+ framework.downcase.to_sym == :minitest
138
144
  end
139
145
  end
140
146
 
@@ -146,30 +152,30 @@ module Aruba
146
152
  :create_file
147
153
  end
148
154
 
149
- send creator, file, <<-EOS
150
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
155
+ send creator, file, <<~EOS
156
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
151
157
 
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
158
+ ::Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
159
+ ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
160
+ EOS
155
161
  end
156
162
 
157
163
  def create_example
158
- create_file 'test/use_aruba_with_minitest.rb', <<-EOS
159
- $LOAD_PATH.unshift File.expand_path('../test', __FILE__)
164
+ create_file 'test/use_aruba_with_minitest.rb', <<~EOS
165
+ $LOAD_PATH.unshift File.expand_path('../test', __FILE__)
160
166
 
161
- require 'test_helper'
162
- require 'minitest/autorun'
163
- require 'aruba/api'
167
+ require 'test_helper'
168
+ require 'minitest/autorun'
169
+ require 'aruba/api'
164
170
 
165
- class FirstRun < Minitest::Test
166
- include Aruba::Api
171
+ class FirstRun < Minitest::Test
172
+ include Aruba::Api
167
173
 
168
- def setup
169
- aruba_setup
170
- end
171
- end
172
- EOS
174
+ def setup
175
+ aruba_setup
176
+ end
177
+ end
178
+ EOS
173
179
  end
174
180
  end
175
181
  end
@@ -202,7 +208,7 @@ module Aruba
202
208
  begin
203
209
  initializers.find { |i| i.match? test_framework }.start [], {}
204
210
  rescue ArgumentError => e
205
- $stderr.puts e.message
211
+ warn e.message
206
212
  exit 0
207
213
  end
208
214
 
@@ -33,6 +33,8 @@ module Aruba
33
33
 
34
34
  # @private
35
35
  module HashFormatting
36
+ module_function
37
+
36
38
  # `{ :a => 5, :b => 2 }.inspect` produces:
37
39
  #
38
40
  # {:a=>5, :b=>2}
@@ -45,7 +47,6 @@ module Aruba
45
47
  def improve_hash_formatting(inspect_string)
46
48
  inspect_string.gsub(/(\S)=>(\S)/, '\1 => \2')
47
49
  end
48
- module_function :improve_hash_formatting
49
50
  end
50
51
 
51
52
  include HashFormatting
@@ -70,16 +71,6 @@ module Aruba
70
71
  def failure_message_when_negated
71
72
  "expected #{description_of @actual} not to #{description}"
72
73
  end
73
-
74
- # @private
75
- # rubocop:disable Style/PredicateName
76
- def self.has_default_failure_messages?(matcher)
77
- matcher.method(:failure_message).owner == self &&
78
- matcher.method(:failure_message_when_negated).owner == self
79
- rescue NameError
80
- false
81
- end
82
- # rubocop:enable Style/PredicateName
83
74
  end
84
75
 
85
76
  include DefaultFailureMessages
@@ -0,0 +1,19 @@
1
+ module Aruba
2
+ module Matchers
3
+ module Base
4
+ # Provide #indent_multiline_message helper method.
5
+ #
6
+ # @api private
7
+ module MessageIndenter
8
+ module_function
9
+
10
+ def indent_multiline_message(message)
11
+ message = message.sub(/\n+\z/, '')
12
+ message.lines.map do |line|
13
+ /\S/.match?(line) ? ' ' + line : line
14
+ end.join
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -12,9 +12,6 @@ module Aruba
12
12
  prepare_for_inspection(object).inspect
13
13
  end
14
14
 
15
- # rubocop:disable MethodLength
16
- # rubocop:disable Metrics/CyclomaticComplexity
17
-
18
15
  # @private
19
16
  # Prepares the provided object to be formatted by wrapping it as needed
20
17
  # in something that, when `inspect` is called on it, will produce the
@@ -47,8 +44,6 @@ module Aruba
47
44
 
48
45
  InspectableItem.new(inspection)
49
46
  end
50
- # rubocop:enable Metrics/CyclomaticComplexity
51
- # rubocop:enable MethodLength
52
47
 
53
48
  # @private
54
49
  def self.prepare_hash(input)
@@ -57,7 +52,7 @@ module Aruba
57
52
  end
58
53
  end
59
54
 
60
- TIME_FORMAT = "%Y-%m-%d %H:%M:%S".freeze
55
+ TIME_FORMAT = '%Y-%m-%d %H:%M:%S'.freeze
61
56
 
62
57
  if Time.method_defined?(:nsec)
63
58
  # @private
@@ -66,7 +61,7 @@ module Aruba
66
61
  end
67
62
  end
68
63
 
69
- DATE_TIME_FORMAT = "%a, %d %b %Y %H:%M:%S.%N %z".freeze
64
+ DATE_TIME_FORMAT = '%a, %d %b %Y %H:%M:%S.%N %z'.freeze
70
65
 
71
66
  # ActiveSupport sometimes overrides inspect. If `ActiveSupport` is
72
67
  # defined use a custom format string that includes more time precision.
@@ -1,4 +1,5 @@
1
1
  require 'aruba/matchers/base/base_matcher'
2
+ require 'aruba/matchers/base/message_indenter'
2
3
 
3
4
  # Aruba
4
5
  module Aruba
@@ -8,6 +9,8 @@ module Aruba
8
9
  # Provides the implementation for `include_an_object`.
9
10
  # Not intended to be instantiated directly.
10
11
  class IncludeAnObject < BaseMatcher
12
+ include Base::MessageIndenter
13
+
11
14
  protected
12
15
 
13
16
  # @private
@@ -19,19 +22,19 @@ module Aruba
19
22
 
20
23
  def initialize(matcher)
21
24
  @matcher = matcher
22
- @failed_objects = {}
25
+ @failed_objects = []
23
26
  @any_succeeded_object = false
24
27
  end
25
28
 
26
29
  # @api private
27
30
  # @return [String]
28
31
  def failure_message
29
- unless iterable?
30
- return "#{improve_hash_formatting(super)}, but was not iterable"
31
- end
32
+ return "#{improve_hash_formatting(super)}, but was not iterable" unless iterable?
33
+
34
+ return failed_objects.first if failed_objects.size == 1
32
35
 
33
36
  all_messages = [improve_hash_formatting(super)]
34
- failed_objects.each do |index, matcher_failure_message|
37
+ failed_objects.each_with_index do |matcher_failure_message, index|
35
38
  all_messages << failure_message_for_item(index, matcher_failure_message)
36
39
  end
37
40
  all_messages.join("\n\n")
@@ -86,19 +89,14 @@ module Aruba
86
89
 
87
90
  def failure_message_for_item(index, failure_message)
88
91
  failure_message = indent_multiline_message(add_new_line_if_needed(failure_message))
89
- indent_multiline_message("object at index #{index} failed to match:#{failure_message}")
92
+ indent_multiline_message(
93
+ "object at index #{index} failed to match:#{failure_message}"
94
+ )
90
95
  end
91
96
 
92
97
  def add_new_line_if_needed(message)
93
98
  message.start_with?("\n") ? message : "\n#{message}"
94
99
  end
95
-
96
- def indent_multiline_message(message)
97
- message = message.sub(/\n+\z/, '')
98
- message.lines.map do |line|
99
- line =~ /\S/ ? ' ' + line : line
100
- end.join
101
- end
102
100
  end
103
101
  end
104
102
  end
@@ -6,7 +6,7 @@ require 'aruba/matchers/command/have_finished_in_time'
6
6
  # @!method be_successfuly_executed
7
7
  # This matchers checks if execution of <command> was successful
8
8
  #
9
- # @return [TrueClass, FalseClass] The result
9
+ # @return [Boolean] The result
10
10
  #
11
11
  # false:
12
12
  # * if command was not successful
@@ -27,8 +27,12 @@ RSpec::Matchers.define :be_successfully_executed do
27
27
 
28
28
  expect(@old_actual).to have_exit_status(0)
29
29
  end
30
- end
31
30
 
32
- if RSpec::Expectations::Version::STRING >= '3.1'
33
- RSpec::Matchers.define_negated_matcher :have_failed_running, :be_successfully_executed
31
+ failure_message do |_actual|
32
+ "Expected `#{@actual}` to succeed" \
33
+ ' but got non-zero exit status and the following output:' \
34
+ "\n\n#{@old_actual.output}\n"
35
+ end
34
36
  end
37
+
38
+ RSpec::Matchers.define_negated_matcher :have_failed_running, :be_successfully_executed