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.
- checksums.yaml +5 -5
- data/.github/PULL_REQUEST_TEMPLATE.md +2 -1
- data/.rspec +0 -1
- data/.rubocop.yml +46 -182
- data/.rubocop_todo.yml +216 -0
- data/.simplecov +7 -5
- data/.travis.yml +56 -40
- data/.yardopts +3 -0
- data/CHANGELOG.md +1312 -0
- data/CONTRIBUTING.md +175 -83
- data/Gemfile +5 -69
- data/LICENSE +1 -1
- data/README.md +58 -21
- data/Rakefile +27 -54
- data/appveyor.yml +7 -10
- data/aruba.gemspec +38 -19
- data/bin/console +3 -12
- data/cucumber.yml +4 -22
- data/exe/aruba +1 -1
- data/fixtures/cli-app/README.md +1 -1
- data/fixtures/cli-app/Rakefile +1 -1
- data/fixtures/cli-app/bin/aruba-test-cli +1 -1
- data/fixtures/cli-app/cli-app.gemspec +4 -4
- data/fixtures/cli-app/lib/cli/app.rb +1 -1
- data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +3 -3
- data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
- data/fixtures/cli-app/spec/spec_helper.rb +3 -2
- data/fixtures/empty-app/Rakefile +1 -1
- data/fixtures/empty-app/cli-app.gemspec +4 -4
- data/fixtures/empty-app/lib/cli/app.rb +0 -2
- data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
- data/fixtures/getting-started-app/Gemfile +1 -1
- data/lib/aruba/api.rb +8 -15
- data/lib/aruba/api/bundler.rb +16 -0
- data/lib/aruba/api/commands.rb +272 -0
- data/lib/aruba/api/core.rb +82 -43
- data/lib/aruba/api/environment.rb +24 -7
- data/lib/aruba/api/filesystem.rb +66 -64
- data/lib/aruba/api/text.rb +17 -11
- data/lib/aruba/aruba_path.rb +25 -111
- data/lib/aruba/basic_configuration.rb +8 -25
- data/lib/aruba/basic_configuration/option.rb +2 -2
- data/lib/aruba/cli.rb +4 -1
- data/lib/aruba/colorizer.rb +10 -99
- data/lib/aruba/command.rb +4 -0
- data/lib/aruba/config/jruby.rb +15 -5
- data/lib/aruba/config_wrapper.rb +17 -2
- data/lib/aruba/configuration.rb +107 -0
- data/lib/aruba/console.rb +5 -7
- data/lib/aruba/console/help.rb +5 -2
- data/lib/aruba/contracts/absolute_path.rb +3 -3
- data/lib/aruba/contracts/is_power_of_two.rb +2 -2
- data/lib/aruba/contracts/relative_path.rb +3 -3
- data/lib/aruba/cucumber.rb +0 -3
- data/lib/aruba/cucumber/command.rb +227 -190
- data/lib/aruba/cucumber/environment.rb +1 -1
- data/lib/aruba/cucumber/file.rb +56 -50
- data/lib/aruba/cucumber/hooks.rb +10 -63
- data/lib/aruba/cucumber/testing_frameworks.rb +76 -50
- data/lib/aruba/event_bus.rb +4 -2
- data/lib/aruba/event_bus/name_resolver.rb +10 -10
- data/lib/aruba/events.rb +2 -1
- data/lib/aruba/hooks.rb +3 -5
- data/lib/aruba/in_config_wrapper.rb +10 -3
- data/lib/aruba/initializer.rb +40 -34
- data/lib/aruba/matchers/base/base_matcher.rb +2 -11
- data/lib/aruba/matchers/base/message_indenter.rb +19 -0
- data/lib/aruba/matchers/base/object_formatter.rb +2 -7
- data/lib/aruba/matchers/collection/include_an_object.rb +11 -13
- data/lib/aruba/matchers/command/be_successfully_executed.rb +8 -4
- data/lib/aruba/matchers/command/have_exit_status.rb +16 -4
- data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -5
- data/lib/aruba/matchers/command/have_output.rb +12 -5
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +4 -2
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +4 -2
- data/lib/aruba/matchers/command/have_output_size.rb +2 -2
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
- data/lib/aruba/matchers/directory/have_sub_directory.rb +10 -7
- data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
- data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
- data/lib/aruba/matchers/file/have_file_content.rb +4 -4
- data/lib/aruba/matchers/file/have_file_size.rb +8 -8
- data/lib/aruba/matchers/file/have_same_file_content.rb +9 -12
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
- data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
- data/lib/aruba/matchers/path/have_permissions.rb +8 -8
- data/lib/aruba/matchers/string/include_output_string.rb +8 -10
- data/lib/aruba/matchers/string/match_output_string.rb +9 -11
- data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
- data/lib/aruba/platform.rb +0 -8
- data/lib/aruba/platforms/announcer.rb +60 -85
- data/lib/aruba/platforms/aruba_file_creator.rb +4 -2
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +8 -3
- data/lib/aruba/platforms/aruba_logger.rb +22 -2
- data/lib/aruba/platforms/command_monitor.rb +15 -102
- data/lib/aruba/platforms/determine_disk_usage.rb +56 -19
- data/lib/aruba/platforms/filesystem_status.rb +9 -9
- data/lib/aruba/platforms/local_environment.rb +2 -2
- data/lib/aruba/platforms/simple_table.rb +3 -11
- data/lib/aruba/platforms/unix_command_string.rb +7 -4
- data/lib/aruba/platforms/unix_environment_variables.rb +19 -26
- data/lib/aruba/platforms/unix_platform.rb +18 -39
- data/lib/aruba/platforms/unix_which.rb +3 -2
- data/lib/aruba/platforms/windows_command_string.rb +20 -7
- data/lib/aruba/platforms/windows_environment_variables.rb +42 -30
- data/lib/aruba/platforms/windows_platform.rb +4 -0
- data/lib/aruba/platforms/windows_which.rb +9 -4
- data/lib/aruba/processes/basic_process.rb +21 -27
- data/lib/aruba/processes/debug_process.rb +16 -5
- data/lib/aruba/processes/in_process.rb +20 -9
- data/lib/aruba/processes/spawn_process.rb +64 -36
- data/lib/aruba/rspec.rb +28 -31
- data/lib/aruba/runtime.rb +16 -7
- data/lib/aruba/setup.rb +32 -17
- data/lib/aruba/tasks/docker_helpers.rb +4 -2
- data/lib/aruba/version.rb +1 -1
- metadata +194 -64
- data/History.md +0 -612
- data/bin/bootstrap +0 -34
- data/bin/build +0 -3
- data/bin/release +0 -3
- data/fixtures/spawn_process/stderr.sh +0 -3
- data/lib/aruba/api/command.rb +0 -309
- data/lib/aruba/api/deprecated.rb +0 -895
- data/lib/aruba/api/rvm.rb +0 -44
- data/lib/aruba/config.rb +0 -101
- data/lib/aruba/cucumber/rvm.rb +0 -3
- data/lib/aruba/in_process.rb +0 -14
- data/lib/aruba/jruby.rb +0 -4
- data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
- data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
- data/lib/aruba/spawn_process.rb +0 -11
data/lib/aruba/event_bus.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
data/lib/aruba/events.rb
CHANGED
|
@@ -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
|
|
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
|
data/lib/aruba/hooks.rb
CHANGED
|
@@ -18,15 +18,13 @@ module Aruba
|
|
|
18
18
|
# @param [String, Symbol] label
|
|
19
19
|
# The name of the hook
|
|
20
20
|
#
|
|
21
|
-
# @
|
|
21
|
+
# @param [Proc] block
|
|
22
22
|
# The block which should be run for the hook
|
|
23
23
|
def append(label, block)
|
|
24
|
-
|
|
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
|
-
|
|
19
|
-
|
|
18
|
+
if config.key? name
|
|
19
|
+
raise ArgumentError, 'Options take no argument' if args.any?
|
|
20
20
|
|
|
21
|
-
|
|
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
|
data/lib/aruba/initializer.rb
CHANGED
|
@@ -23,7 +23,12 @@ module Aruba
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
content = if File.exist? file
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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',
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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,
|
|
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',
|
|
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
|
-
|
|
171
|
+
class FirstRun < Minitest::Test
|
|
172
|
+
include Aruba::Api
|
|
167
173
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
31
|
-
|
|
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.
|
|
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(
|
|
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 [
|
|
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
|
-
|
|
33
|
-
|
|
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
|