rspec-expectations 3.11.0 → 3.12.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e651e80dd869915779a72a9ea43b38d20327f3dbfaf94a4851eff7974d1f3d0a
4
- data.tar.gz: e1788055c911b97cbad1b3747fe9b9be005a999e2e97e6c361df4c91fa4fda25
3
+ metadata.gz: d167a03fcf6e4519b628fefcf03b644e6436e1f6769058d84431fab3181e5119
4
+ data.tar.gz: dccb3d8b5ed822e523989e59e897085584173d65a503be30166b9d14bba675ef
5
5
  SHA512:
6
- metadata.gz: ec1b6b68b80fddae764dbf88312817c35c1e76228c29748e2b89d8d9a69d95384aa4fe9daf7b8a650dd307dd32aca13bae590d8960f0989beea67c54f7f6d7d5
7
- data.tar.gz: 7a8a129e74ccec6299ab3af1c728cab2754a1cc98911507704c3f52a01c33b321250bfe715deef835b61963e22c66ec878500d10c6fea93d4fda7cc39b101676
6
+ metadata.gz: dc027c3d982da4f60e13924ef494fe4df964ee64ccd405eaf69a522494e23d394d0560dfa32c2007a8f43831118ad20df6480ed5692dbe70b389dfcc724e7266
7
+ data.tar.gz: 61e1c4f7ce7514869e63d24e7eb3270861ea4ad6343c34127b04f757bd80009dd599ae94be25c925b1de265fb4dc5a68f9619b9e3293de46b4aabd0cd1595dae
checksums.yaml.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,5 +1,49 @@
1
1
  ### Development
2
- [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.11.0...3-11-maintenance)
2
+ [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.3...3-12-maintenance)
3
+
4
+ ### 3.12.3 / 2023-04-20
5
+ [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.2...v3.12.3)
6
+
7
+ Bug Fixes:
8
+
9
+ * Fix `include` matcher when fuzzy matching on keys with a hash-like actual which
10
+ has a non standard `key?` method which may raise.
11
+ (Jon Rowe, #1416)
12
+
13
+ ### 3.12.2 / 2023-01-07
14
+ [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.1...v3.12.2)
15
+
16
+ Bug Fixes:
17
+
18
+ * Prevent deprecation warning when using the `exist` matcher with `Dir`.
19
+ (Steve Dierker, #1398)
20
+
21
+ ### 3.12.1 / 2022-12-16
22
+ [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.0...v3.12.1)
23
+
24
+ Bug Fixes:
25
+
26
+ * Pass keyword arguments through to aliased (and thus negated) matchers. (Jon Rowe, #1394)
27
+ * When handling failures in an aggregated_failures block (or example) prevent
28
+ the failure list leaking out. (Maciek Rząsa, #1392)
29
+
30
+ ### 3.12.0 / 2022-10-26
31
+ [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.11.1...v3.12.0)
32
+
33
+ Enhancements:
34
+
35
+ * Add `an_array_matching` alias for `match_array` to improve readability as an argument
36
+ matcher. (Mark Schneider, #1361)
37
+
38
+ ### 3.11.1 / 2022-09-12
39
+ [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.11.0...v3.11.1)
40
+
41
+ Bug Fixes:
42
+
43
+ * Allow the `contain_exactly` matcher to be reused by resetting its
44
+ internals on `matches?` (@bclayman-sq, #1326)
45
+ * Using the exist matcher on `FileTest` no longer produces a deprecation warning.
46
+ (Ryo Nakamura, #1383)
3
47
 
4
48
  ### 3.11.0 / 2022-02-09
5
49
  [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.10.2...v3.11.0)
@@ -296,10 +340,8 @@ Enhancements:
296
340
  can cause uses of `super` to trigger infinite recursion. (Myron Marston, #816)
297
341
  * Stop rescuing `NoMemoryError`, `SignalExcepetion`, `Interrupt` and
298
342
  `SystemExit`. It is dangerous to interfere with these. (Myron Marston, #845)
299
- * Add `#with_captures` to the
300
- [match matcher](https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/match-matcher)
301
- which allows a user to specify expected captures when matching a regex
302
- against a string. (Sam Phippen, #848)
343
+ * Add `#with_captures` to the match matcher which allows a user to specify expected
344
+ captures when matching a regex against a string. (Sam Phippen, #848)
303
345
  * Always print compound failure messages in the multi-line form. Trying
304
346
  to print it all on a single line didn't read very well. (Myron Marston, #859)
305
347
 
@@ -4,6 +4,21 @@ module RSpec
4
4
  class FailureAggregator
5
5
  attr_reader :block_label, :metadata
6
6
 
7
+ # @private
8
+ class AggregatedFailure
9
+ # @private
10
+ MESSAGE =
11
+ 'AggregatedFailure: This method caused a failure which has been ' \
12
+ 'suppressed to be aggregated into our failure report by returning ' \
13
+ 'this value, further errors can be ignored.'
14
+
15
+ def inspect
16
+ MESSAGE
17
+ end
18
+ end
19
+
20
+ AGGREGATED_FAILURE = AggregatedFailure.new
21
+
7
22
  def aggregate
8
23
  RSpec::Support.with_failure_notifier(self) do
9
24
  begin
@@ -48,6 +63,8 @@ module RSpec
48
63
  @seen_source_ids[source_id] = true
49
64
  assign_backtrace(failure) unless failure.backtrace
50
65
  failures << failure
66
+
67
+ AGGREGATED_FAILURE
51
68
  end
52
69
 
53
70
  private
@@ -2,7 +2,7 @@ module RSpec
2
2
  module Expectations
3
3
  # @private
4
4
  module Version
5
- STRING = '3.11.0'
5
+ STRING = '3.12.3'
6
6
  end
7
7
  end
8
8
  end
@@ -99,14 +99,14 @@ module RSpec
99
99
  # by going through the effort of defining a negated matcher.
100
100
  #
101
101
  # However, if the override didn't actually change anything, then we
102
- # should return the opposite failure message instead -- the overriden
102
+ # should return the opposite failure message instead -- the overridden
103
103
  # message is going to be confusing if we return it as-is, as it represents
104
104
  # the non-negated failure message for a negated match (or vice versa).
105
105
  def optimal_failure_message(same, inverted)
106
106
  if DefaultFailureMessages.has_default_failure_messages?(@base_matcher)
107
107
  base_message = @base_matcher.__send__(same)
108
- overriden = @description_block.call(base_message)
109
- return overriden if overriden != base_message
108
+ overridden = @description_block.call(base_message)
109
+ return overridden if overridden != base_message
110
110
  end
111
111
 
112
112
  @base_matcher.__send__(inverted)
@@ -171,7 +171,7 @@ module RSpec
171
171
  @match_results.fetch(matcher) do
172
172
  raise ArgumentError, "Your #{matcher.description} has no match " \
173
173
  "results, this can occur when an unexpected call stack or " \
174
- "local jump occurs. Prehaps one of your matchers needs to " \
174
+ "local jump occurs. Perhaps one of your matchers needs to " \
175
175
  "declare `expects_call_stack_jump?` as `true`?"
176
176
  end
177
177
  end
@@ -1,7 +1,7 @@
1
1
  module RSpec
2
2
  module Matchers
3
3
  module BuiltIn
4
- # rubocop:disable ClassLength
4
+ # rubocop:disable Metrics/ClassLength
5
5
  # @api private
6
6
  # Provides the implementation for `contain_exactly` and `match_array`.
7
7
  # Not intended to be instantiated directly.
@@ -31,6 +31,14 @@ module RSpec
31
31
  "contain exactly#{list}"
32
32
  end
33
33
 
34
+ def matches?(actual)
35
+ @pairings_maximizer = nil
36
+ @best_solution = nil
37
+ @extra_items = nil
38
+ @missing_items = nil
39
+ super(actual)
40
+ end
41
+
34
42
  private
35
43
 
36
44
  def generate_failure_message
@@ -296,7 +304,7 @@ module RSpec
296
304
  end
297
305
  end
298
306
  end
299
- # rubocop:enable ClassLength
307
+ # rubocop:enable Metrics/ClassLength
300
308
  end
301
309
  end
302
310
  end
@@ -2,7 +2,7 @@ module RSpec
2
2
  module Matchers
3
3
  module BuiltIn
4
4
  # @api private
5
- # Asbtract class to implement `once`, `at_least` and other
5
+ # Abstract class to implement `once`, `at_least` and other
6
6
  # count constraints.
7
7
  module CountExpectation
8
8
  # @api public
@@ -81,7 +81,7 @@ module RSpec
81
81
  end
82
82
 
83
83
  def deprecated(predicate, actual)
84
- predicate == :exists? && File == actual
84
+ predicate == :exists? && (File == actual || FileTest == actual || Dir == actual)
85
85
  end
86
86
  end
87
87
  end
@@ -153,8 +153,15 @@ module RSpec
153
153
  def actual_hash_has_key?(expected_key)
154
154
  # We check `key?` first for perf:
155
155
  # `key?` is O(1), but `any?` is O(N).
156
- actual.key?(expected_key) ||
157
- actual.keys.any? { |key| values_match?(expected_key, key) }
156
+
157
+ has_exact_key =
158
+ begin
159
+ actual.key?(expected_key)
160
+ rescue
161
+ false
162
+ end
163
+
164
+ has_exact_key || actual.keys.any? { |key| values_match?(expected_key, key) }
158
165
  end
159
166
 
160
167
  def actual_collection_includes?(expected_item)
@@ -4,8 +4,8 @@ module RSpec
4
4
  # @api private
5
5
  # Provides the implementation for `raise_error`.
6
6
  # Not intended to be instantiated directly.
7
- # rubocop:disable ClassLength
8
- # rubocop:disable RescueException
7
+ # rubocop:disable Metrics/ClassLength
8
+ # rubocop:disable Lint/RescueException
9
9
  class RaiseError
10
10
  include Composable
11
11
 
@@ -43,7 +43,7 @@ module RSpec
43
43
  self
44
44
  end
45
45
 
46
- # rubocop:disable MethodLength
46
+ # rubocop:disable Metrics/MethodLength
47
47
  # @private
48
48
  def matches?(given_proc, negative_expectation=false, &block)
49
49
  @given_proc = given_proc
@@ -73,7 +73,7 @@ module RSpec
73
73
 
74
74
  expectation_matched?
75
75
  end
76
- # rubocop:enable MethodLength
76
+ # rubocop:enable Metrics/MethodLength
77
77
 
78
78
  # @private
79
79
  def does_not_match?(given_proc)
@@ -264,8 +264,8 @@ module RSpec
264
264
  warning if @actual_error
265
265
  end
266
266
  end
267
- # rubocop:enable RescueException
268
- # rubocop:enable ClassLength
267
+ # rubocop:enable Lint/RescueException
268
+ # rubocop:enable Metrics/ClassLength
269
269
  end
270
270
  end
271
271
  end
@@ -13,7 +13,7 @@ module RSpec
13
13
  @caught_symbol = @caught_arg = nil
14
14
  end
15
15
 
16
- # rubocop:disable MethodLength
16
+ # rubocop:disable Metrics/MethodLength
17
17
  # @private
18
18
  def matches?(given_proc)
19
19
  @block = given_proc
@@ -48,7 +48,7 @@ module RSpec
48
48
  rescue => other_exception
49
49
  raise
50
50
  ensure
51
- # rubocop:disable EnsureReturn
51
+ # rubocop:disable Lint/EnsureReturn
52
52
  unless other_exception
53
53
  if @expected_symbol.nil?
54
54
  return !!@caught_symbol
@@ -60,10 +60,10 @@ module RSpec
60
60
  end
61
61
  end
62
62
  end
63
- # rubocop:enable EnsureReturn
63
+ # rubocop:enable Lint/EnsureReturn
64
64
  end
65
65
  end
66
- # rubocop:enable MethodLength
66
+ # rubocop:enable Metrics/MethodLength
67
67
 
68
68
  def does_not_match?(given_proc)
69
69
  !matches?(given_proc) && Proc === given_proc
@@ -83,7 +83,7 @@ module RSpec
83
83
  RSpec::Support::ObjectFormatter.format(object)
84
84
  end
85
85
 
86
- # Transforms the given data structue (typically a hash or array)
86
+ # Transforms the given data structure (typically a hash or array)
87
87
  # into a new data structure that, when `#inspect` is called on it,
88
88
  # will provide descriptions of any contained matchers rather than
89
89
  # the normal `#inspect` output.
@@ -4,7 +4,7 @@ module RSpec
4
4
  module Matchers
5
5
  # Defines the custom matcher DSL.
6
6
  module DSL
7
- # Defines a matcher alias. The returned matcher's `description` will be overriden
7
+ # Defines a matcher alias. The returned matcher's `description` will be overridden
8
8
  # to reflect the phrasing of the new name, which will be used in failure messages
9
9
  # when passed as an argument to another matcher in a composed matcher expression.
10
10
  #
@@ -25,7 +25,7 @@ module RSpec
25
25
  # @param old_name [Symbol] the original name for the matcher
26
26
  # @param options [Hash] options for the aliased matcher
27
27
  # @option options [Class] :klass the ruby class to use as the decorator. (Not normally used).
28
- # @yield [String] optional block that, when given, is used to define the overriden
28
+ # @yield [String] optional block that, when given, is used to define the overridden
29
29
  # logic. The yielded arg is the original description or failure message. If no
30
30
  # block is provided, a default override is used based on the old and new names.
31
31
  # @see RSpec::Matchers
@@ -40,10 +40,11 @@ module RSpec
40
40
  matcher.matcher_name = new_name if matcher.respond_to?(:matcher_name=)
41
41
  klass.new(matcher, description_override)
42
42
  end
43
+ ruby2_keywords new_name if respond_to?(:ruby2_keywords, true)
43
44
  end
44
45
 
45
46
  # Defines a negated matcher. The returned matcher's `description` and `failure_message`
46
- # will be overriden to reflect the phrasing of the new name, and the match logic will
47
+ # will be overridden to reflect the phrasing of the new name, and the match logic will
47
48
  # be based on the original matcher but negated.
48
49
  #
49
50
  # @example
@@ -53,7 +54,7 @@ module RSpec
53
54
  #
54
55
  # @param negated_name [Symbol] the name for the negated matcher
55
56
  # @param base_name [Symbol] the name of the original matcher that will be negated
56
- # @yield [String] optional block that, when given, is used to define the overriden
57
+ # @yield [String] optional block that, when given, is used to define the overridden
57
58
  # logic. The yielded arg is the original description or failure message. If no
58
59
  # block is provided, a default override is used based on the old and new names.
59
60
  # @see RSpec::Matchers
@@ -122,7 +123,7 @@ module RSpec
122
123
  #
123
124
  # By default the match block will swallow expectation errors (e.g.
124
125
  # caused by using an expectation such as `expect(1).to eq 2`), if you
125
- # with to allow these to bubble up, pass in the option
126
+ # wish to allow these to bubble up, pass in the option
126
127
  # `:notify_expectation_failures => true`.
127
128
  #
128
129
  # @param [Hash] options for defining the behavior of the match block.
@@ -151,7 +152,7 @@ module RSpec
151
152
  #
152
153
  # By default the match block will swallow expectation errors (e.g.
153
154
  # caused by using an expectation such as `expect(1).to eq 2`), if you
154
- # with to allow these to bubble up, pass in the option
155
+ # wish to allow these to bubble up, pass in the option
155
156
  # `:notify_expectation_failures => true`.
156
157
  #
157
158
  # @param [Hash] options for defining the behavior of the match block.
@@ -197,7 +198,7 @@ module RSpec
197
198
  end
198
199
  end
199
200
 
200
- # Customizes the failure messsage to use when this matcher is
201
+ # Customizes the failure message to use when this matcher is
201
202
  # asked to positively match. Only use this when the message
202
203
  # generated by default doesn't suit your needs.
203
204
  #
@@ -216,7 +217,7 @@ module RSpec
216
217
  define_user_override(__method__, definition)
217
218
  end
218
219
 
219
- # Customize the failure messsage to use when this matcher is asked
220
+ # Customize the failure message to use when this matcher is asked
220
221
  # to negatively match. Only use this when the message generated by
221
222
  # default doesn't suit your needs.
222
223
  #
@@ -330,7 +331,7 @@ module RSpec
330
331
  # - Defines the named method using a user-provided block
331
332
  # in @user_method_defs, which is included as an ancestor
332
333
  # in the singleton class in which we eval the `define` block.
333
- # - Defines an overriden definition for the same method
334
+ # - Defines an overridden definition for the same method
334
335
  # usign the provided `our_def` block.
335
336
  # - Provides a default `our_def` block for the common case
336
337
  # of needing to call the user's definition with `@actual`
@@ -36,7 +36,7 @@ module RSpec
36
36
  # expect([]).to be_empty # => [].empty?() | passes
37
37
  # expect([]).not_to be_empty # => [].empty?() | fails
38
38
  #
39
- # In addtion to prefixing the predicate matchers with "be_", you can also use "be_a_"
39
+ # In addition to prefixing the predicate matchers with "be_", you can also use "be_a_"
40
40
  # and "be_an_", making your specs read much more naturally:
41
41
  #
42
42
  # expect("a string").to be_an_instance_of(String) # =>"a string".instance_of?(String) # passes
@@ -704,7 +704,7 @@ module RSpec
704
704
 
705
705
  # An alternate form of `contain_exactly` that accepts
706
706
  # the expected contents as a single array arg rather
707
- # that splatted out as individual items.
707
+ # than splatted out as individual items.
708
708
  #
709
709
  # @example
710
710
  # expect(results).to contain_exactly(1, 2)
@@ -715,6 +715,9 @@ module RSpec
715
715
  def match_array(items)
716
716
  contain_exactly(*items)
717
717
  end
718
+ alias_matcher :an_array_matching, :match_array do |desc|
719
+ desc.sub("contain exactly", "an array containing exactly")
720
+ end
718
721
 
719
722
  # With no arg, passes if the block outputs `to_stdout` or `to_stderr`.
720
723
  # With a string, passes if the block outputs that specific string `to_stdout` or `to_stderr`.
@@ -753,8 +756,8 @@ module RSpec
753
756
 
754
757
  # With no args, matches if any error is raised.
755
758
  # With a named error, matches only if that specific error is raised.
756
- # With a named error and messsage specified as a String, matches only if both match.
757
- # With a named error and messsage specified as a Regexp, matches only if both match.
759
+ # With a named error and message specified as a String, matches only if both match.
760
+ # With a named error and message specified as a Regexp, matches only if both match.
758
761
  # Pass an optional block to perform extra verifications on the exception matched
759
762
  #
760
763
  # @example
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-expectations
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
4
+ version: 3.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Baker
@@ -45,7 +45,7 @@ cert_chain:
45
45
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
46
46
  F3MdtaDehhjC
47
47
  -----END CERTIFICATE-----
48
- date: 2022-02-09 00:00:00.000000000 Z
48
+ date: 2023-04-20 00:00:00.000000000 Z
49
49
  dependencies:
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rspec-support
@@ -53,14 +53,14 @@ dependencies:
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 3.11.0
56
+ version: 3.12.0
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: 3.11.0
63
+ version: 3.12.0
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: diff-lcs
66
66
  requirement: !ruby/object:Gem::Requirement
@@ -203,7 +203,7 @@ licenses:
203
203
  - MIT
204
204
  metadata:
205
205
  bug_tracker_uri: https://github.com/rspec/rspec-expectations/issues
206
- changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.11.0/Changelog.md
206
+ changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.12.3/Changelog.md
207
207
  documentation_uri: https://rspec.info/documentation/
208
208
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
209
209
  source_code_uri: https://github.com/rspec/rspec-expectations
@@ -223,8 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  - !ruby/object:Gem::Version
224
224
  version: '0'
225
225
  requirements: []
226
- rubygems_version: 3.3.3
226
+ rubygems_version: 3.3.26
227
227
  signing_key:
228
228
  specification_version: 4
229
- summary: rspec-expectations-3.11.0
229
+ summary: rspec-expectations-3.12.3
230
230
  test_files: []
metadata.gz.sig CHANGED
Binary file