aruba 2.0.0 → 2.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -1
  3. data/CONTRIBUTING.md +0 -1
  4. data/README.md +10 -3
  5. data/lib/aruba/api/commands.rb +0 -2
  6. data/lib/aruba/api/filesystem.rb +1 -1
  7. data/lib/aruba/api/text.rb +0 -12
  8. data/lib/aruba/console.rb +1 -1
  9. data/lib/aruba/contracts/enum.rb +1 -0
  10. data/lib/aruba/cucumber/command.rb +31 -19
  11. data/lib/aruba/cucumber/file.rb +2 -2
  12. data/lib/aruba/matchers/command/be_successfully_executed.rb +0 -2
  13. data/lib/aruba/matchers/command/have_exit_status.rb +7 -13
  14. data/lib/aruba/matchers/command/have_finished_in_time.rb +0 -2
  15. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +0 -2
  16. data/lib/aruba/matchers/directory/have_sub_directory.rb +0 -2
  17. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +0 -2
  18. data/lib/aruba/matchers/file/be_an_existing_executable.rb +0 -1
  19. data/lib/aruba/matchers/file/be_an_existing_file.rb +0 -2
  20. data/lib/aruba/matchers/file/have_file_content.rb +0 -2
  21. data/lib/aruba/matchers/file/have_file_size.rb +0 -2
  22. data/lib/aruba/matchers/file/have_same_file_content.rb +0 -1
  23. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +0 -2
  24. data/lib/aruba/matchers/path/be_an_absolute_path.rb +0 -2
  25. data/lib/aruba/matchers/path/be_an_existing_path.rb +0 -2
  26. data/lib/aruba/matchers/path/have_permissions.rb +0 -2
  27. data/lib/aruba/platform.rb +2 -2
  28. data/lib/aruba/platforms/announcer.rb +0 -2
  29. data/lib/aruba/platforms/command_monitor.rb +2 -2
  30. data/lib/aruba/platforms/unix_environment_variables.rb +0 -2
  31. data/lib/aruba/platforms/unix_platform.rb +1 -0
  32. data/lib/aruba/processes/basic_process.rb +4 -0
  33. data/lib/aruba/version.rb +1 -1
  34. metadata +32 -17
  35. data/lib/aruba/matchers/base/base_matcher.rb +0 -87
  36. data/lib/aruba/matchers/base/object_formatter.rb +0 -104
  37. data/lib/aruba/matchers/collection/all.rb +0 -11
  38. data/lib/aruba/matchers/collection/include_an_object.rb +0 -120
  39. data/lib/aruba/matchers/collection.rb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 274e6609a41e03eb74e7fa94a41c6165f5db84e5cff6787c8793afdde8c56cef
4
- data.tar.gz: 1252caf02a2a758f334ce58e8da97c21015e7477cfb8266695ae7b54b2db6e57
3
+ metadata.gz: bc48eb26abb5d1e638537ed9eaf53f5758c541ca48e9f979da107bb8a7bdcf6c
4
+ data.tar.gz: 75d8cc6d3c52b62538f688949ee212abd5c3dad8aca20fd3007860757eaf830e
5
5
  SHA512:
6
- metadata.gz: afa76ddef7027ba2e46f5db09114a9430b520f970ef03a8fb4989ffd383abece8629f20e3ea0ca657037b9a68b1a7cb8fff383342fced0ea4841a204c6b4389d
7
- data.tar.gz: c3c7ef6f78b7a67e8a8cb44edd7ca7c72ee5fda00601ceee4eceba5663fb782a575933949b89389242454cef176e6ca89579380943c98a363e76db54fde5ba2c
6
+ metadata.gz: bece1031dfa68f1fa9a80854758558596cc48d073996fb5d3f6440226d18e68c7408d478ffa6a9f7881aa52e3d172c1acaa1bf3bae5948b07af363e6a456c75d
7
+ data.tar.gz: 7f68b65140bbe200235a6e23aac68a5f4da28ca9cf47171cd28d758a2b70aaa5645b7a45f739a1fa803d5c5770864196224d4797685c0de40328a71db7697d90
data/CHANGELOG.md CHANGED
@@ -6,6 +6,16 @@ This project adheres to [Semantic Versioning][1].
6
6
 
7
7
  This document is formatted according to the principles of [Keep A CHANGELOG][2].
8
8
 
9
+ ## [2.0.1] / 2022-04-22
10
+
11
+ * Various cleanups of internal APIs ([#838] by [mvz])
12
+ * Make objects not pretend to be nil ([#843] by [mvz])
13
+ * Remove experimental variables replacement feature ([#846] by [mvz])
14
+ * Support Ruby 3.1 ([#850] by [mvz])
15
+ * Fix steps that wait for output from commands ([#856] by [mvz])
16
+ * Ensure `Gem.win_platform?` is available ([#858] by [mvz])
17
+ * Support JRuby 9.3 ([#867] by [mvz])
18
+
9
19
  ## [2.0.0] / 2021-07-26
10
20
 
11
21
  Potentially breaking changes:
@@ -994,6 +1004,13 @@ Note: These are changes w.r.t. Aruba version 0.14.1.
994
1004
 
995
1005
  <!-- issues & pull requests -->
996
1006
 
1007
+ [#867]: https://github.com/cucumber/aruba/pull/867
1008
+ [#858]: https://github.com/cucumber/aruba/pull/858
1009
+ [#856]: https://github.com/cucumber/aruba/pull/856
1010
+ [#850]: https://github.com/cucumber/aruba/pull/850
1011
+ [#846]: https://github.com/cucumber/aruba/pull/846
1012
+ [#843]: https://github.com/cucumber/aruba/pull/843
1013
+ [#838]: https://github.com/cucumber/aruba/pull/838
997
1014
  [#829]: https://github.com/cucumber/aruba/pull/829
998
1015
  [#828]: https://github.com/cucumber/aruba/pull/828
999
1016
  [#822]: https://github.com/cucumber/aruba/pull/822
@@ -1295,7 +1312,8 @@ Note: These are changes w.r.t. Aruba version 0.14.1.
1295
1312
 
1296
1313
  <!-- Releases -->
1297
1314
 
1298
- [Unreleased]: https://github.com/cucumber/aruba/compare/v2.0.0...main
1315
+ [Unreleased]: https://github.com/cucumber/aruba/compare/v2.0.1...main
1316
+ [2.0.1]: https://github.com/cucumber/aruba/compare/v2.0.0...v2.0.1
1299
1317
  [2.0.0]: https://github.com/cucumber/aruba/compare/v1.1.2...v2.0.0
1300
1318
  [1.1.2]: https://github.com/cucumber/aruba/compare/v1.1.1...v1.1.2
1301
1319
  [1.1.1]: https://github.com/cucumber/aruba/compare/v1.1.0...v1.1.1
data/CONTRIBUTING.md CHANGED
@@ -161,7 +161,6 @@ your normal development workflow.
161
161
  Example `Gemfile.local`:
162
162
 
163
163
  ```ruby
164
- gem 'pry'
165
164
  gem 'pry-byebug'
166
165
  gem 'byebug'
167
166
  ```
data/README.md CHANGED
@@ -69,12 +69,19 @@ Currently, this gem is mainly maintained by this group of people:
69
69
 
70
70
  ## Release Policy
71
71
 
72
- We try to comply with [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html).
72
+ We use [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html). We
73
+ depend on rubygems to ensure correct dependency versions, so dropping support
74
+ for older dependencies and Ruby versions will not result in a major version
75
+ bump.
73
76
 
74
77
  ## Supported Ruby versions
75
78
 
76
- Aruba is supported on Ruby 2.5 and up, and tested against CRuby 2.5, 2.6 and
77
- 2.7, and JRuby 9.2.
79
+ Aruba is supported on Ruby 2.5 and up, and tested against CRuby 2.5, 2.6, 2.7, 3.0 and
80
+ 3.1, and JRuby 9.2 and 9.2.
81
+
82
+ ## Supported Cucumber versions
83
+
84
+ Aruba is supported on and tested with Cucumber versions 4 through 7.
78
85
 
79
86
  ## Supported operating systems
80
87
 
@@ -226,8 +226,6 @@ module Aruba
226
226
  stop_signal = opts[:stop_signal] || aruba.config.stop_signal
227
227
  startup_wait_time = opts[:startup_wait_time] || aruba.config.startup_wait_time
228
228
 
229
- cmd = replace_variables(cmd)
230
-
231
229
  @commands ||= []
232
230
  @commands << cmd
233
231
 
@@ -406,7 +406,7 @@ module Aruba
406
406
  # Bytes on disk
407
407
  def disk_usage(*paths)
408
408
  paths = paths.flatten
409
- expect(paths).to Aruba::Matchers.all be_an_existing_path
409
+ expect(paths).to all be_an_existing_path
410
410
  expanded = paths.map { |path| expand_path(path) }
411
411
 
412
412
  Aruba.platform.determine_disk_usage(expanded)
@@ -45,18 +45,6 @@ module Aruba
45
45
 
46
46
  text.chomp
47
47
  end
48
-
49
- # Replace variables in command string (experimental)
50
- #
51
- # @param [#to_s] text
52
- # The text to parse
53
- def replace_variables(text)
54
- if text.include? "<pid-last-command-started>"
55
- text = text.gsub(/<pid-last-command-started>/, last_command_started.pid.to_s)
56
- end
57
-
58
- text
59
- end
60
48
  end
61
49
  end
62
50
  end
data/lib/aruba/console.rb CHANGED
@@ -43,7 +43,7 @@ module Aruba
43
43
  end
44
44
 
45
45
  def inspect
46
- "nil"
46
+ "aruba console"
47
47
  end
48
48
  end
49
49
 
@@ -14,6 +14,7 @@ module Aruba
14
14
 
15
15
  # Create contract
16
16
  def initialize(*vals)
17
+ super()
17
18
  @vals = vals
18
19
  end
19
20
 
@@ -85,21 +85,33 @@ rescue ChildProcess::TimeoutError, Timeout::Error
85
85
  last_command_started.terminate
86
86
  end
87
87
 
88
- When "I wait for output/stdout to contain" do |expected|
88
+ When "I wait for output/stdout to contain:" do |expected|
89
89
  Timeout.timeout(aruba.config.exit_timeout) do
90
- expect(last_command_started).to have_output an_output_string_including(expected)
91
- rescue ExpectationError
92
- sleep 0.1
93
- retry
90
+ loop do
91
+ output = last_command_started.public_send :stdout, wait_for_io: 0
92
+
93
+ output = sanitize_text(output)
94
+ expected = sanitize_text(expected)
95
+
96
+ break if output.include? expected
97
+
98
+ sleep 0.1
99
+ end
94
100
  end
95
101
  end
96
102
 
97
103
  When "I wait for output/stdout to contain {string}" do |expected|
98
104
  Timeout.timeout(aruba.config.exit_timeout) do
99
- expect(last_command_started).to have_output an_output_string_including(expected)
100
- rescue ExpectationError
101
- sleep 0.1
102
- retry
105
+ loop do
106
+ output = last_command_started.public_send :stdout, wait_for_io: 0
107
+
108
+ output = sanitize_text(output)
109
+ expected = sanitize_text(expected)
110
+
111
+ break if output.include? expected
112
+
113
+ sleep 0.1
114
+ end
103
115
  end
104
116
  end
105
117
 
@@ -292,35 +304,35 @@ end
292
304
  Then(%r{^the output should( not)? match /([^/]*)/$}) do |negated, expected|
293
305
  if negated
294
306
  expect(all_commands)
295
- .not_to include_an_object have_output an_output_string_matching(expected)
307
+ .not_to include have_output an_output_string_matching(expected)
296
308
  else
297
309
  expect(all_commands)
298
- .to include_an_object have_output an_output_string_matching(expected)
310
+ .to include have_output an_output_string_matching(expected)
299
311
  end
300
312
  end
301
313
 
302
314
  Then(/^the output should( not)? match %r<([^>]*)>$/) do |negated, expected|
303
315
  if negated
304
316
  expect(all_commands)
305
- .not_to include_an_object have_output an_output_string_matching(expected)
317
+ .not_to include have_output an_output_string_matching(expected)
306
318
  else
307
319
  expect(all_commands)
308
- .to include_an_object have_output an_output_string_matching(expected)
320
+ .to include have_output an_output_string_matching(expected)
309
321
  end
310
322
  end
311
323
 
312
324
  Then(/^the output should( not)? match:$/) do |negated, expected|
313
325
  if negated
314
326
  expect(all_commands)
315
- .not_to include_an_object have_output an_output_string_matching(expected)
327
+ .not_to include have_output an_output_string_matching(expected)
316
328
  else
317
329
  expect(all_commands)
318
- .to include_an_object have_output an_output_string_matching(expected)
330
+ .to include have_output an_output_string_matching(expected)
319
331
  end
320
332
  end
321
333
 
322
334
  Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
323
- last_command_started.stop if last_command_stopped.nil?
335
+ last_command_started.stop if last_command_stopped.empty?
324
336
 
325
337
  if negated
326
338
  expect(last_command_stopped).not_to have_exit_status exit_status.to_i
@@ -432,7 +444,7 @@ Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channe
432
444
  when "stdout"; then :have_output_on_stdout
433
445
  end
434
446
 
435
- expect(all_commands).to include_an_object send(matcher, be_nil.or(be_empty))
447
+ expect(all_commands).to include send(matcher, be_nil.or(be_empty))
436
448
  end
437
449
 
438
450
  Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) \
@@ -448,10 +460,10 @@ Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:
448
460
 
449
461
  if negated
450
462
  expect(all_commands)
451
- .not_to include_an_object have_output an_output_string_including(expected)
463
+ .not_to include have_output an_output_string_including(expected)
452
464
  else
453
465
  expect(all_commands)
454
- .to include_an_object have_output an_output_string_including(expected)
466
+ .to include have_output an_output_string_including(expected)
455
467
  end
456
468
  end
457
469
  end
@@ -95,7 +95,7 @@ Then(/^the following files should (not )?exist:$/) do |negated, files|
95
95
  if negated
96
96
  expect(files).not_to include an_existing_file
97
97
  else
98
- expect(files).to Aruba::Matchers.all be_an_existing_file
98
+ expect(files).to all be_an_existing_file
99
99
  end
100
100
  end
101
101
 
@@ -140,7 +140,7 @@ Then(/^the following directories should (not )?exist:$/) do |negated, directorie
140
140
  if negated
141
141
  expect(directories).not_to include an_existing_directory
142
142
  else
143
- expect(directories).to Aruba::Matchers.all be_an_existing_directory
143
+ expect(directories).to all be_an_existing_directory
144
144
  end
145
145
  end
146
146
 
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  require "aruba/matchers/command/have_exit_status"
4
2
  require "aruba/matchers/command/have_finished_in_time"
5
3
 
@@ -18,33 +18,27 @@
18
18
  # end
19
19
  RSpec::Matchers.define :have_exit_status do |expected|
20
20
  match do |actual|
21
- @old_actual = actual
21
+ actual.stop
22
+ @actual_exit_status = actual.exit_status
22
23
 
23
- @old_actual.stop
24
- @actual = actual.exit_status
25
-
26
- unless @old_actual.respond_to? :exit_status
27
- raise "Expected #{@old_actual} to respond to #exit_status"
28
- end
29
-
30
- values_match? expected, @actual
24
+ values_match? expected, @actual_exit_status
31
25
  end
32
26
 
33
27
  failure_message do |actual|
34
28
  format(
35
29
  %(expected that command "%s" has exit status of "%s", but has "%s".),
36
- @old_actual.commandline,
30
+ actual.commandline,
37
31
  expected.to_s,
38
- actual.to_s
32
+ @actual_exit_status.to_s
39
33
  )
40
34
  end
41
35
 
42
36
  failure_message_when_negated do |actual|
43
37
  format(
44
38
  %(expected that command "%s" does not have exit status of "%s", but has "%s".),
45
- @old_actual.commandline,
39
+ actual.commandline,
46
40
  expected.to_s,
47
- actual.to_s
41
+ @actual_exit_status.to_s
48
42
  )
49
43
  end
50
44
  end
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  # @!method run_too_long
4
2
  # This matchers checks if <command> run too long. Say the timeout is 10
5
3
  # seconds and it takes <command> to finish in 15. This matchers will succeed.
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  # @!method be_an_existing_directory
4
2
  # This matchers checks if <directory> exists in filesystem
5
3
  #
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  # @!method have_sub_directory(sub_directory)
4
2
  # This matchers checks if <directory> has given sub-directory
5
3
  #
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  # @!method be_a_command_found_in_path
4
2
  # This matchers checks if <command> can be found in path
5
3
  #
@@ -1,4 +1,3 @@
1
- require "rspec/expectations/version"
2
1
  require "shellwords"
3
2
 
4
3
  # @!method be_an_existing_executable
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  # @!method be_an_existing_file
4
2
  # This matchers checks if <file> exists in filesystem
5
3
  #
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  # @!method have_file_content(content)
4
2
  # This matchers checks if <file> has content. `content` can be a string,
5
3
  # regexp or an RSpec matcher.
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  # @!method have_file_size(size)
4
2
  # This matchers checks if path has file size
5
3
  #
@@ -1,4 +1,3 @@
1
- require "rspec/expectations/version"
2
1
  require "fileutils"
3
2
 
4
3
  # @!method have_same_file_content_as(file_name)
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  # @!method a_path_matching_pattern(/pattern/)
4
2
  # This matchers checks if <path> matches pattern. `pattern` can be a string,
5
3
  # regexp or an RSpec matcher.
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  # @!method be_an_absolute_path
4
2
  # This matchers checks if <path> exists in filesystem
5
3
  #
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  # @!method be_an_existing_path
4
2
  # This matchers checks if <path> exists in filesystem
5
3
  #
@@ -1,5 +1,3 @@
1
- require "rspec/expectations/version"
2
-
3
1
  # @!method have_permissions(permissions)
4
2
  # This matchers checks if <file> or <directory> has <perm> permissions
5
3
  #
@@ -5,10 +5,10 @@ require "aruba/platforms/windows_platform"
5
5
  module Aruba
6
6
  PLATFORM_MUTEX = Mutex.new
7
7
 
8
- Platform = [Platforms::WindowsPlatform, Platforms::UnixPlatform].find(&:match?)
8
+ PLATFORM = [Platforms::WindowsPlatform, Platforms::UnixPlatform].find(&:match?)
9
9
 
10
10
  PLATFORM_MUTEX.synchronize do
11
- @platform = Platform.new
11
+ @platform = PLATFORM.new
12
12
  end
13
13
 
14
14
  class << self
@@ -134,8 +134,6 @@ module Aruba
134
134
  # The mode to set
135
135
  def mode=(m)
136
136
  @announcer = @announcers.find { |a| a.mode? m.to_sym }
137
-
138
- self
139
137
  end
140
138
 
141
139
  # Fecth mode of announcer
@@ -15,7 +15,7 @@ module Aruba
15
15
  attr_reader :registered_commands, :last_command_started, :last_command_stopped
16
16
 
17
17
  class DefaultLastCommandStopped
18
- def nil?
18
+ def empty?
19
19
  true
20
20
  end
21
21
 
@@ -29,7 +29,7 @@ module Aruba
29
29
  end
30
30
 
31
31
  class DefaultLastCommandStarted
32
- def nil?
32
+ def empty?
33
33
  true
34
34
  end
35
35
 
@@ -108,8 +108,6 @@ module Aruba
108
108
  value = value.to_s
109
109
 
110
110
  actions << UpdateAction.new(name.to_s => value)
111
-
112
- value
113
111
  end
114
112
 
115
113
  # Append value to variable
@@ -1,4 +1,5 @@
1
1
  require "rbconfig"
2
+ require "rubygems"
2
3
  require "pathname"
3
4
 
4
5
  require "aruba/aruba_path"
@@ -130,6 +130,10 @@ module Aruba
130
130
  []
131
131
  end
132
132
 
133
+ def empty?
134
+ false
135
+ end
136
+
133
137
  private
134
138
 
135
139
  def truncate(string, max_length)
data/lib/aruba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Aruba
2
- VERSION = "2.0.0".freeze
2
+ VERSION = "2.0.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aruba
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy, Matt Wynne and other Aruba Contributors
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-26 00:00:00.000000000 Z
11
+ date: 2022-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -174,6 +174,26 @@ dependencies:
174
174
  - - "~>"
175
175
  - !ruby/object:Gem::Version
176
176
  version: '5.10'
177
+ - !ruby/object:Gem::Dependency
178
+ name: pry
179
+ requirement: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: 0.13.0
184
+ - - "<"
185
+ - !ruby/object:Gem::Version
186
+ version: 0.15.0
187
+ type: :development
188
+ prerelease: false
189
+ version_requirements: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: 0.13.0
194
+ - - "<"
195
+ - !ruby/object:Gem::Version
196
+ version: 0.15.0
177
197
  - !ruby/object:Gem::Dependency
178
198
  name: pry-doc
179
199
  requirement: !ruby/object:Gem::Requirement
@@ -228,28 +248,28 @@ dependencies:
228
248
  requirements:
229
249
  - - "~>"
230
250
  - !ruby/object:Gem::Version
231
- version: 3.10.0
251
+ version: '3.11'
232
252
  type: :development
233
253
  prerelease: false
234
254
  version_requirements: !ruby/object:Gem::Requirement
235
255
  requirements:
236
256
  - - "~>"
237
257
  - !ruby/object:Gem::Version
238
- version: 3.10.0
258
+ version: '3.11'
239
259
  - !ruby/object:Gem::Dependency
240
260
  name: rubocop
241
261
  requirement: !ruby/object:Gem::Requirement
242
262
  requirements:
243
263
  - - "~>"
244
264
  - !ruby/object:Gem::Version
245
- version: 1.18.0
265
+ version: '1.28'
246
266
  type: :development
247
267
  prerelease: false
248
268
  version_requirements: !ruby/object:Gem::Requirement
249
269
  requirements:
250
270
  - - "~>"
251
271
  - !ruby/object:Gem::Version
252
- version: 1.18.0
272
+ version: '1.28'
253
273
  - !ruby/object:Gem::Dependency
254
274
  name: rubocop-packaging
255
275
  requirement: !ruby/object:Gem::Requirement
@@ -270,28 +290,28 @@ dependencies:
270
290
  requirements:
271
291
  - - "~>"
272
292
  - !ruby/object:Gem::Version
273
- version: 1.11.3
293
+ version: '1.13'
274
294
  type: :development
275
295
  prerelease: false
276
296
  version_requirements: !ruby/object:Gem::Requirement
277
297
  requirements:
278
298
  - - "~>"
279
299
  - !ruby/object:Gem::Version
280
- version: 1.11.3
300
+ version: '1.13'
281
301
  - !ruby/object:Gem::Dependency
282
302
  name: rubocop-rspec
283
303
  requirement: !ruby/object:Gem::Requirement
284
304
  requirements:
285
305
  - - "~>"
286
306
  - !ruby/object:Gem::Version
287
- version: 2.4.0
307
+ version: '2.8'
288
308
  type: :development
289
309
  prerelease: false
290
310
  version_requirements: !ruby/object:Gem::Requirement
291
311
  requirements:
292
312
  - - "~>"
293
313
  - !ruby/object:Gem::Version
294
- version: 2.4.0
314
+ version: '2.8'
295
315
  - !ruby/object:Gem::Dependency
296
316
  name: simplecov
297
317
  requirement: !ruby/object:Gem::Requirement
@@ -383,12 +403,7 @@ files:
383
403
  - lib/aruba/hooks.rb
384
404
  - lib/aruba/in_config_wrapper.rb
385
405
  - lib/aruba/initializer.rb
386
- - lib/aruba/matchers/base/base_matcher.rb
387
406
  - lib/aruba/matchers/base/message_indenter.rb
388
- - lib/aruba/matchers/base/object_formatter.rb
389
- - lib/aruba/matchers/collection.rb
390
- - lib/aruba/matchers/collection/all.rb
391
- - lib/aruba/matchers/collection/include_an_object.rb
392
407
  - lib/aruba/matchers/command.rb
393
408
  - lib/aruba/matchers/command/be_successfully_executed.rb
394
409
  - lib/aruba/matchers/command/have_exit_status.rb
@@ -472,8 +487,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
472
487
  - !ruby/object:Gem::Version
473
488
  version: '0'
474
489
  requirements: []
475
- rubygems_version: 3.2.22
490
+ rubygems_version: 3.3.7
476
491
  signing_key:
477
492
  specification_version: 4
478
- summary: aruba-2.0.0
493
+ summary: aruba-2.0.1
479
494
  test_files: []
@@ -1,87 +0,0 @@
1
- require "aruba/matchers/base/object_formatter"
2
-
3
- # Aruba
4
- module Aruba
5
- # Matchers
6
- module Matchers
7
- # Base Matcher
8
- class BaseMatcher
9
- # @api private
10
- # Used to detect when no arg is passed to `initialize`.
11
- # `nil` cannot be used because it's a valid value to pass.
12
- UNDEFINED = Object.new.freeze
13
-
14
- # @private
15
- attr_reader :actual, :expected, :rescued_exception
16
-
17
- def initialize(expected = UNDEFINED)
18
- @expected = expected unless UNDEFINED.equal?(expected)
19
- end
20
-
21
- # @api private
22
- # Indicates if the match is successful. Delegates to `match`, which
23
- # should be defined on a subclass. Takes care of consistently
24
- # initializing the `actual` attribute.
25
- def matches?(actual)
26
- @actual = actual
27
- match(expected, actual)
28
- end
29
-
30
- def iterable?
31
- @actual.respond_to?(:each_with_index)
32
- end
33
-
34
- # @private
35
- module HashFormatting
36
- module_function
37
-
38
- # `{ :a => 5, :b => 2 }.inspect` produces:
39
- #
40
- # {:a=>5, :b=>2}
41
- #
42
- # ...but it looks much better as:
43
- #
44
- # {:a => 5, :b => 2}
45
- #
46
- # This is idempotent and safe to run on a string multiple times.
47
- def improve_hash_formatting(inspect_string)
48
- inspect_string.gsub(/(\S)=>(\S)/, '\1 => \2')
49
- end
50
- end
51
-
52
- include HashFormatting
53
-
54
- # @api private
55
- # Provides default implementations of failure messages, based on the `description`.
56
- module DefaultFailureMessages
57
- # @api private
58
- # Provides a good generic failure message. Based on `description`.
59
- # When subclassing, if you are not satisfied with this failure message
60
- # you often only need to override `description`.
61
- # @return [String]
62
- def failure_message
63
- "expected #{description_of @actual} to #{description}"
64
- end
65
-
66
- # @api private
67
- # Provides a good generic negative failure message. Based on `description`.
68
- # When subclassing, if you are not satisfied with this failure message
69
- # you often only need to override `description`.
70
- # @return [String]
71
- def failure_message_when_negated
72
- "expected #{description_of @actual} not to #{description}"
73
- end
74
- end
75
-
76
- include DefaultFailureMessages
77
-
78
- # Returns the description of the given object in a way that is
79
- # aware of composed matchers. If the object is a matcher with
80
- # a `description` method, returns the description; otherwise
81
- # returns `object.inspect`.
82
- def description_of(object)
83
- Aruba::Matchers::ObjectFormatter.format(object)
84
- end
85
- end
86
- end
87
- end
@@ -1,104 +0,0 @@
1
- # Aruba
2
- module Aruba
3
- # Matchers
4
- module Matchers
5
- # Provide additional output details beyond what `inspect` provides when
6
- # printing Time, DateTime, or BigDecimal
7
- #
8
- # @private
9
- module ObjectFormatter
10
- # @api private
11
- def self.format(object)
12
- prepare_for_inspection(object).inspect
13
- end
14
-
15
- # @private
16
- # Prepares the provided object to be formatted by wrapping it as needed
17
- # in something that, when `inspect` is called on it, will produce the
18
- # desired output.
19
- #
20
- # This allows us to apply the desired formatting to hash/array data structures
21
- # at any level of nesting, simply by walking that structure and replacing items
22
- # with custom items that have `inspect` defined to return the desired output
23
- # for that item. Then we can just use `Array#inspect` or `Hash#inspect` to
24
- # format the entire thing.
25
- def self.prepare_for_inspection(object)
26
- case object
27
- when Array
28
- return object.map { |o| prepare_for_inspection(o) }
29
- when Hash
30
- return prepare_hash(object)
31
- when Time
32
- inspection = format_time(object)
33
- else
34
- if defined?(DateTime) && DateTime === object
35
- inspection = format_date_time(object)
36
- elsif defined?(BigDecimal) && BigDecimal === object
37
- inspection = "#{object.to_s 'F'} (#{object.inspect})"
38
- elsif RSpec::Support.is_a_matcher?(object) && object.respond_to?(:description)
39
- inspection = object.description
40
- else
41
- return DelegatingInspector.new(object)
42
- end
43
- end
44
-
45
- InspectableItem.new(inspection)
46
- end
47
-
48
- # @private
49
- def self.prepare_hash(input)
50
- input.each_with_object({}) do |(k, v), hash|
51
- hash[prepare_for_inspection(k)] = prepare_for_inspection(v)
52
- end
53
- end
54
-
55
- TIME_FORMAT = "%Y-%m-%d %H:%M:%S".freeze
56
-
57
- if Time.method_defined?(:nsec)
58
- # @private
59
- def self.format_time(time)
60
- time.strftime("#{TIME_FORMAT}.#{format('%09d', time.nsec)} %z")
61
- end
62
- end
63
-
64
- DATE_TIME_FORMAT = "%a, %d %b %Y %H:%M:%S.%N %z".freeze
65
-
66
- # ActiveSupport sometimes overrides inspect. If `ActiveSupport` is
67
- # defined use a custom format string that includes more time precision.
68
- # @private
69
- def self.format_date_time(date_time)
70
- if defined?(ActiveSupport)
71
- date_time.strftime(DATE_TIME_FORMAT)
72
- else
73
- date_time.inspect
74
- end
75
- end
76
-
77
- # @private
78
- InspectableItem = Struct.new(:inspection) do
79
- def inspect
80
- inspection
81
- end
82
-
83
- def pretty_print(pp)
84
- pp.text inspection
85
- end
86
- end
87
-
88
- # @private
89
- DelegatingInspector = Struct.new(:object) do
90
- def inspect
91
- if defined?(::Delegator) && ::Delegator === object
92
- "#<#{object.class}(#{ObjectFormatter.format(object.__getobj__)})>"
93
- else
94
- object.inspect
95
- end
96
- end
97
-
98
- def pretty_print(pp)
99
- pp.text inspect
100
- end
101
- end
102
- end
103
- end
104
- end
@@ -1,11 +0,0 @@
1
- require "rspec/expectations"
2
-
3
- # Aruba
4
- module Aruba
5
- # Matchers
6
- module Matchers
7
- include ::RSpec::Matchers
8
-
9
- module_function :all
10
- end
11
- end
@@ -1,120 +0,0 @@
1
- require "aruba/matchers/base/base_matcher"
2
- require "aruba/matchers/base/message_indenter"
3
-
4
- # Aruba
5
- module Aruba
6
- # Matchers
7
- module Matchers
8
- # @api private
9
- # Provides the implementation for `include_an_object`.
10
- # Not intended to be instantiated directly.
11
- class IncludeAnObject < BaseMatcher
12
- include Base::MessageIndenter
13
-
14
- protected
15
-
16
- # @private
17
- attr_reader :matcher, :failed_objects
18
- # @private
19
- attr_accessor :any_succeeded_object
20
-
21
- public
22
-
23
- def initialize(matcher)
24
- @matcher = matcher
25
- @failed_objects = []
26
- @any_succeeded_object = false
27
- end
28
-
29
- # @api private
30
- # @return [String]
31
- def failure_message
32
- return "#{improve_hash_formatting(super)}, but was not iterable" unless iterable?
33
-
34
- return failed_objects.first if failed_objects.size == 1
35
-
36
- all_messages = [improve_hash_formatting(super)]
37
- failed_objects.each_with_index do |matcher_failure_message, index|
38
- all_messages << failure_message_for_item(index, matcher_failure_message)
39
- end
40
- all_messages.join("\n\n")
41
- end
42
-
43
- # @api private
44
- # @return [String]
45
- def description
46
- improve_hash_formatting "include an object #{description_of matcher}"
47
- end
48
-
49
- def does_not_match?(actual)
50
- @actual = actual
51
-
52
- return false unless iterable?
53
-
54
- index_objects
55
-
56
- any_succeeded_object == false
57
- end
58
-
59
- private
60
-
61
- def match(expected, actual)
62
- @actual = actual
63
- @expected = expected
64
-
65
- return false unless iterable?
66
-
67
- index_objects
68
-
69
- any_succeeded_object == true
70
- end
71
-
72
- def index_objects
73
- actual.each_with_index do |actual_item, index|
74
- cloned_matcher = matcher.clone
75
- begin
76
- matches = cloned_matcher.matches?(actual_item)
77
- rescue StandardError
78
- matches = nil
79
- end
80
-
81
- if matches
82
- self.any_succeeded_object = true
83
- break
84
- else
85
- failed_objects[index] = cloned_matcher.failure_message
86
- end
87
- end
88
- end
89
-
90
- def failure_message_for_item(index, failure_message)
91
- failure_message = indent_multiline_message(add_new_line_if_needed(failure_message))
92
- indent_multiline_message(
93
- "object at index #{index} failed to match:#{failure_message}"
94
- )
95
- end
96
-
97
- def add_new_line_if_needed(message)
98
- message.start_with?("\n") ? message : "\n#{message}"
99
- end
100
- end
101
- end
102
- end
103
-
104
- module RSpec
105
- module Matchers
106
- # Passes if the provided matcher passes when checked against any
107
- # element of the collection.
108
- #
109
- # @example
110
- # expect([1, 4, 5]).to include_an_object be_odd
111
- #
112
- # @note You can also use this with compound matchers as well.
113
- #
114
- # @example
115
- # expect([1, 4, 'a']).to include_an_object( be_odd.and be_an(Integer) )
116
- def include_an_object(expected)
117
- ::Aruba::Matchers::IncludeAnObject.new(expected)
118
- end
119
- end
120
- end
@@ -1 +0,0 @@
1
- Aruba.platform.require_matching_files("../collection/**/*.rb", __FILE__)