rspec-expectations 3.12.2 → 3.12.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0b59eb5a0bf0dcaf99ae45b411fa1d8e73a3cf5b0694f06170205ff36b22bc1
4
- data.tar.gz: 91f0f17601c3853d8e10219dfb2c41a53fba78b4d3c546870ebe1fac9de70a6b
3
+ metadata.gz: 1a4b2b9ff3e6aa95cb68edc11fb142d4ed9af33134ece089bb4fa2f524b4fed9
4
+ data.tar.gz: cde69140cecbddef69efa9a51148983786cec5023695c56686ef4141490dd657
5
5
  SHA512:
6
- metadata.gz: 99e2aff242508b307566d95120c66e507cde5da5e6aec973365b747e1b16fde3ab34445ce2cfddf153baeac2c3f75c05b1e0f105465118544aad8fb9dafbe37e
7
- data.tar.gz: c69b2d96fc2c3abec310e9e36b346cc3a1017a160906c795b1218b1e1a2dbea10055a80fc89da6510c89eb9cc7ef82e7f24c63ff2893f3c692a008de0ec838f1
6
+ metadata.gz: a391ea2eb336a05f2cabaea19ddd759499dac7f0ca1578504ad9668752d0c758f83f75281b4ba041db55ff62695e99368fb37576566068baf0ad95de43f16b1a
7
+ data.tar.gz: 1f2b528c2073230317a0557b371a28be61a35895b8849f310f6696ce6cf6cc7074878ea8657a8e137cae9da5f7c58219716946fe56229b49eb91a60ae2125dfc
checksums.yaml.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,5 +1,22 @@
1
1
  ### Development
2
- [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.1...3-12-maintenance)
2
+ [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.4...3-12-maintenance)
3
+
4
+ ### 3.12.4 / 2024-02-04
5
+ [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.3...v3.12.4)
6
+
7
+ Bug Fixes:
8
+
9
+ * Fix the diff for redefined `actual` and reassigned `@actual` in compound
10
+ expectations failure messages. (Phil Pirozhkov, #1440)
11
+
12
+ ### 3.12.3 / 2023-04-20
13
+ [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.2...v3.12.3)
14
+
15
+ Bug Fixes:
16
+
17
+ * Fix `include` matcher when fuzzy matching on keys with a hash-like actual which
18
+ has a non standard `key?` method which may raise.
19
+ (Jon Rowe, #1416)
3
20
 
4
21
  ### 3.12.2 / 2023-01-07
5
22
  [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.1...v3.12.2)
@@ -331,10 +348,8 @@ Enhancements:
331
348
  can cause uses of `super` to trigger infinite recursion. (Myron Marston, #816)
332
349
  * Stop rescuing `NoMemoryError`, `SignalExcepetion`, `Interrupt` and
333
350
  `SystemExit`. It is dangerous to interfere with these. (Myron Marston, #845)
334
- * Add `#with_captures` to the
335
- [match matcher](https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers/match-matcher)
336
- which allows a user to specify expected captures when matching a regex
337
- against a string. (Sam Phippen, #848)
351
+ * Add `#with_captures` to the match matcher which allows a user to specify expected
352
+ captures when matching a regex against a string. (Sam Phippen, #848)
338
353
  * Always print compound failure messages in the multi-line form. Trying
339
354
  to print it all on a single line didn't read very well. (Myron Marston, #859)
340
355
 
@@ -30,7 +30,7 @@ module RSpec
30
30
  "appropriate failure_message[_when_negated] method to return a string?"
31
31
  end
32
32
 
33
- message = ::RSpec::Matchers::ExpectedsForMultipleDiffs.from(expected).message_with_diff(message, differ, actual)
33
+ message = ::RSpec::Matchers::MultiMatcherDiff.from(expected, actual).message_with_diff(message, differ)
34
34
 
35
35
  RSpec::Support.notify_failure(RSpec::Expectations::ExpectationNotMetError.new message)
36
36
  end
@@ -2,7 +2,7 @@ module RSpec
2
2
  module Expectations
3
3
  # @private
4
4
  module Version
5
- STRING = '3.12.2'
5
+ STRING = '3.12.4'
6
6
  end
7
7
  end
8
8
  end
@@ -51,10 +51,10 @@ module RSpec
51
51
  end
52
52
 
53
53
  # @api private
54
- # @return [RSpec::Matchers::ExpectedsForMultipleDiffs]
54
+ # @return [RSpec::Matchers::MultiMatcherDiff]
55
55
  def expected
56
56
  return nil unless evaluator
57
- ::RSpec::Matchers::ExpectedsForMultipleDiffs.for_many_matchers(diffable_matcher_list)
57
+ ::RSpec::Matchers::MultiMatcherDiff.for_many_matchers(diffable_matcher_list)
58
58
  end
59
59
 
60
60
  protected
@@ -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)
@@ -1,9 +1,9 @@
1
1
  module RSpec
2
2
  module Matchers
3
3
  # @api private
4
- # Handles list of expected values when there is a need to render
5
- # multiple diffs. Also can handle one value.
6
- class ExpectedsForMultipleDiffs
4
+ # Handles list of expected and actual value pairs when there is a need
5
+ # to render multiple diffs. Also can handle one pair.
6
+ class MultiMatcherDiff
7
7
  # @private
8
8
  # Default diff label when there is only one matcher in diff
9
9
  # output
@@ -19,22 +19,23 @@ module RSpec
19
19
 
20
20
  # @api private
21
21
  # Wraps provided expected value in instance of
22
- # ExpectedForMultipleDiffs. If provided value is already an
23
- # ExpectedForMultipleDiffs then it just returns it.
22
+ # MultiMatcherDiff. If provided value is already an
23
+ # MultiMatcherDiff then it just returns it.
24
24
  # @param [Any] expected value to be wrapped
25
- # @return [RSpec::Matchers::ExpectedsForMultipleDiffs]
26
- def self.from(expected)
25
+ # @param [Any] actual value
26
+ # @return [RSpec::Matchers::MultiMatcherDiff]
27
+ def self.from(expected, actual)
27
28
  return expected if self === expected
28
- new([[expected, DEFAULT_DIFF_LABEL]])
29
+ new([[expected, DEFAULT_DIFF_LABEL, actual]])
29
30
  end
30
31
 
31
32
  # @api private
32
33
  # Wraps provided matcher list in instance of
33
- # ExpectedForMultipleDiffs.
34
+ # MultiMatcherDiff.
34
35
  # @param [Array<Any>] matchers list of matchers to wrap
35
- # @return [RSpec::Matchers::ExpectedsForMultipleDiffs]
36
+ # @return [RSpec::Matchers::MultiMatcherDiff]
36
37
  def self.for_many_matchers(matchers)
37
- new(matchers.map { |m| [m.expected, diff_label_for(m)] })
38
+ new(matchers.map { |m| [m.expected, diff_label_for(m), m.actual] })
38
39
  end
39
40
 
40
41
  # @api private
@@ -42,10 +43,9 @@ module RSpec
42
43
  # factory and actual value if there are any
43
44
  # @param [String] message original failure message
44
45
  # @param [Proc] differ
45
- # @param [Any] actual value
46
46
  # @return [String]
47
- def message_with_diff(message, differ, actual)
48
- diff = diffs(differ, actual)
47
+ def message_with_diff(message, differ)
48
+ diff = diffs(differ)
49
49
  message = "#{message}\n#{diff}" unless diff.empty?
50
50
  message
51
51
  end
@@ -65,8 +65,8 @@ module RSpec
65
65
  end
66
66
  end
67
67
 
68
- def diffs(differ, actual)
69
- @expected_list.map do |(expected, diff_label)|
68
+ def diffs(differ)
69
+ @expected_list.map do |(expected, diff_label, actual)|
70
70
  diff = differ.diff(actual, expected)
71
71
  next if diff.strip.empty?
72
72
  if diff == "\e[0m\n\e[0m"
@@ -10,7 +10,7 @@ RSpec::Support.define_optimized_require_for_rspec(:matchers) { |f| require_relat
10
10
  dsl
11
11
  matcher_delegator
12
12
  aliased_matcher
13
- expecteds_for_multiple_diffs
13
+ multi_matcher_diff
14
14
  ].each { |file| RSpec::Support.require_rspec_matchers(file) }
15
15
 
16
16
  # RSpec's top level namespace. All of rspec-expectations is contained
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.12.2
4
+ version: 3.12.4
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: 2023-01-07 00:00:00.000000000 Z
48
+ date: 2024-02-04 00:00:00.000000000 Z
49
49
  dependencies:
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rspec-support
@@ -193,17 +193,17 @@ files:
193
193
  - lib/rspec/matchers/composable.rb
194
194
  - lib/rspec/matchers/dsl.rb
195
195
  - lib/rspec/matchers/english_phrasing.rb
196
- - lib/rspec/matchers/expecteds_for_multiple_diffs.rb
197
196
  - lib/rspec/matchers/fail_matchers.rb
198
197
  - lib/rspec/matchers/generated_descriptions.rb
199
198
  - lib/rspec/matchers/matcher_delegator.rb
200
199
  - lib/rspec/matchers/matcher_protocol.rb
200
+ - lib/rspec/matchers/multi_matcher_diff.rb
201
201
  homepage: https://github.com/rspec/rspec-expectations
202
202
  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.12.2/Changelog.md
206
+ changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.12.4/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
@@ -226,5 +226,5 @@ requirements: []
226
226
  rubygems_version: 3.3.26
227
227
  signing_key:
228
228
  specification_version: 4
229
- summary: rspec-expectations-3.12.2
229
+ summary: rspec-expectations-3.12.4
230
230
  test_files: []
metadata.gz.sig CHANGED
Binary file