rspec-expectations 3.10.1 → 3.12.2
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 +4 -4
- checksums.yaml.gz.sig +4 -1
- data/Changelog.md +63 -1
- data/README.md +1 -1
- data/lib/rspec/expectations/expectation_target.rb +42 -6
- data/lib/rspec/expectations/failure_aggregator.rb +18 -1
- data/lib/rspec/expectations/version.rb +1 -1
- data/lib/rspec/matchers/aliased_matcher.rb +3 -3
- data/lib/rspec/matchers/built_in/base_matcher.rb +5 -0
- data/lib/rspec/matchers/built_in/change.rb +22 -0
- data/lib/rspec/matchers/built_in/compound.rb +15 -1
- data/lib/rspec/matchers/built_in/contain_exactly.rb +10 -2
- data/lib/rspec/matchers/built_in/count_expectation.rb +1 -1
- data/lib/rspec/matchers/built_in/exist.rb +1 -1
- data/lib/rspec/matchers/built_in/include.rb +1 -1
- data/lib/rspec/matchers/built_in/output.rb +7 -0
- data/lib/rspec/matchers/built_in/raise_error.rb +21 -9
- data/lib/rspec/matchers/built_in/throw_symbol.rb +10 -4
- data/lib/rspec/matchers/built_in/yield.rb +20 -0
- data/lib/rspec/matchers/composable.rb +1 -1
- data/lib/rspec/matchers/dsl.rb +14 -9
- data/lib/rspec/matchers/matcher_protocol.rb +6 -0
- data/lib/rspec/matchers.rb +7 -4
- data.tar.gz.sig +0 -0
- metadata +9 -9
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0b59eb5a0bf0dcaf99ae45b411fa1d8e73a3cf5b0694f06170205ff36b22bc1
|
4
|
+
data.tar.gz: 91f0f17601c3853d8e10219dfb2c41a53fba78b4d3c546870ebe1fac9de70a6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99e2aff242508b307566d95120c66e507cde5da5e6aec973365b747e1b16fde3ab34445ce2cfddf153baeac2c3f75c05b1e0f105465118544aad8fb9dafbe37e
|
7
|
+
data.tar.gz: c69b2d96fc2c3abec310e9e36b346cc3a1017a160906c795b1218b1e1a2dbea10055a80fc89da6510c89eb9cc7ef82e7f24c63ff2893f3c692a008de0ec838f1
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,3 @@
|
|
1
|
-
|
1
|
+
�v���!���lu�AA���[��z�Op�C���XsH#�w*��ʪ�c�#X��o��'�@sS�wP��j��a���њ<�tt��玦Ռ����@�U�n���aoS�н�rϟD�qPa/�#��irg�y��s��{7���IW1�Ʈ&�d����}����Ȃۈ�+3�Mf�Dtp*`Yåy�>���x�,��F���-�%�G��i�AhB��oO��v�wV�6�m}�#���5�S�^�x�XY�$���}]H�qP]Q:4A�6�j�4��\P\�H�o�ηY�0?�Hz8��{k�&Y��S��А^9�ʙ�6�I�s�j���&��KŔ��)�(�V��+�,���,lQ�+G��K�{��Z�g��W4��M���Ђ��|��"��d�}ux��{ds>�C�Sx��m%���tA�pJ���k#<�1-O��6�N+j�E:P�Rn
|
2
|
+
5��^s�&���a��+��R7�hy����|_�,w�Y�'r�b��b!�ߖ��@��_k
|
3
|
+
�C��g���
|
4
|
+
U������G۱ez�E��^��S(7�|��PW����ϕ±��~�=��&h��ِ�]��nZ�0��b�4�t f�(�i|�EG�ޡ���_,��N3����L����B�r.9�����X�Ȱ���?$ʟ����Z�� �
|
data/Changelog.md
CHANGED
@@ -1,3 +1,65 @@
|
|
1
|
+
### Development
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.1...3-12-maintenance)
|
3
|
+
|
4
|
+
### 3.12.2 / 2023-01-07
|
5
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.1...v3.12.2)
|
6
|
+
|
7
|
+
Bug Fixes:
|
8
|
+
|
9
|
+
* Prevent deprecation warning when using the `exist` matcher with `Dir`.
|
10
|
+
(Steve Dierker, #1398)
|
11
|
+
|
12
|
+
### 3.12.1 / 2022-12-16
|
13
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.12.0...v3.12.1)
|
14
|
+
|
15
|
+
Bug Fixes:
|
16
|
+
|
17
|
+
* Pass keyword arguments through to aliased (and thus negated) matchers. (Jon Rowe, #1394)
|
18
|
+
* When handling failures in an aggregated_failures block (or example) prevent
|
19
|
+
the failure list leaking out. (Maciek Rząsa, #1392)
|
20
|
+
|
21
|
+
### 3.12.0 / 2022-10-26
|
22
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.11.1...v3.12.0)
|
23
|
+
|
24
|
+
Enhancements:
|
25
|
+
|
26
|
+
* Add `an_array_matching` alias for `match_array` to improve readability as an argument
|
27
|
+
matcher. (Mark Schneider, #1361)
|
28
|
+
|
29
|
+
### 3.11.1 / 2022-09-12
|
30
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.11.0...v3.11.1)
|
31
|
+
|
32
|
+
Bug Fixes:
|
33
|
+
|
34
|
+
* Allow the `contain_exactly` matcher to be reused by resetting its
|
35
|
+
internals on `matches?` (@bclayman-sq, #1326)
|
36
|
+
* Using the exist matcher on `FileTest` no longer produces a deprecation warning.
|
37
|
+
(Ryo Nakamura, #1383)
|
38
|
+
|
39
|
+
### 3.11.0 / 2022-02-09
|
40
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.10.2...v3.11.0)
|
41
|
+
|
42
|
+
Enhancements:
|
43
|
+
|
44
|
+
* Return `true` from `aggregate_failures` when no exception occurs. (Jon Rowe, #1225)
|
45
|
+
|
46
|
+
Deprecations:
|
47
|
+
|
48
|
+
* Print a deprecation message when using the implicit block expectation syntax.
|
49
|
+
(Phil Pirozhkov, #1139)
|
50
|
+
|
51
|
+
### 3.10.2 / 2022-01-14
|
52
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.10.1...v3.10.2)
|
53
|
+
|
54
|
+
Bug Fixes:
|
55
|
+
|
56
|
+
* Fix support for dynamic matchers for expectation target checks (Phil Pirozhkov, #1294)
|
57
|
+
* Fix `expect(array).to include(hash).times`, previously this would fail due to
|
58
|
+
matching the entire array as a single hash, rather than a member of the hash.
|
59
|
+
(Slava Kardakov, #1322)
|
60
|
+
* Ensure `raise_error` matches works with the `error_highlight` option from Ruby 3.1.
|
61
|
+
(Peter Goldstein, #1339)
|
62
|
+
|
1
63
|
### 3.10.1 / 2020-12-27
|
2
64
|
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.10.0...v3.10.1)
|
3
65
|
|
@@ -113,7 +175,7 @@ Bug Fixes:
|
|
113
175
|
* Prevent composed `all` matchers from leaking into their siblings leading to duplicate
|
114
176
|
failures. (Jamie English, #1086)
|
115
177
|
* Prevent objects which change their hash on comparison from failing change checks.
|
116
|
-
(Phil Pirozhkov, #
|
178
|
+
(Phil Pirozhkov, #1100)
|
117
179
|
* Issue an `ArgumentError` rather than a `NoMethodError` when `be_an_instance_of` and
|
118
180
|
`be_kind_of` matchers encounter objects not supporting those methods.
|
119
181
|
(Taichi Ishitani, #1107)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# RSpec Expectations [](https://github.com/rspec/rspec-expectations/actions) [](https://codeclimate.com/github/rspec/rspec-expectations)
|
2
2
|
|
3
3
|
RSpec::Expectations lets you express expected outcomes on an object in an
|
4
4
|
example.
|
@@ -42,7 +42,7 @@ module RSpec
|
|
42
42
|
elsif block
|
43
43
|
raise ArgumentError, "You cannot pass both an argument and a block to `expect`."
|
44
44
|
else
|
45
|
-
new(value)
|
45
|
+
ValueExpectationTarget.new(value)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -57,7 +57,7 @@ module RSpec
|
|
57
57
|
# expect { perform }.to raise_error
|
58
58
|
# @param [Matcher]
|
59
59
|
# matcher
|
60
|
-
# @param [String
|
60
|
+
# @param [String, Proc] message optional message to display when the expectation fails
|
61
61
|
# @return [Boolean] true if the expectation succeeds (else raises)
|
62
62
|
# @see RSpec::Matchers
|
63
63
|
def to(matcher=nil, message=nil, &block)
|
@@ -70,7 +70,7 @@ module RSpec
|
|
70
70
|
# expect(value).not_to eq(5)
|
71
71
|
# @param [Matcher]
|
72
72
|
# matcher
|
73
|
-
# @param [String
|
73
|
+
# @param [String, Proc] message optional message to display when the expectation fails
|
74
74
|
# @return [Boolean] false if the negative expectation succeeds (else raises)
|
75
75
|
# @see RSpec::Matchers
|
76
76
|
def not_to(matcher=nil, message=nil, &block)
|
@@ -90,6 +90,44 @@ module RSpec
|
|
90
90
|
include InstanceMethods
|
91
91
|
end
|
92
92
|
|
93
|
+
# @private
|
94
|
+
# Validates the provided matcher to ensure it supports block
|
95
|
+
# expectations, in order to avoid user confusion when they
|
96
|
+
# use a block thinking the expectation will be on the return
|
97
|
+
# value of the block rather than the block itself.
|
98
|
+
class ValueExpectationTarget < ExpectationTarget
|
99
|
+
def to(matcher=nil, message=nil, &block)
|
100
|
+
enforce_value_expectation(matcher)
|
101
|
+
super
|
102
|
+
end
|
103
|
+
|
104
|
+
def not_to(matcher=nil, message=nil, &block)
|
105
|
+
enforce_value_expectation(matcher)
|
106
|
+
super
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def enforce_value_expectation(matcher)
|
112
|
+
return if supports_value_expectations?(matcher)
|
113
|
+
|
114
|
+
RSpec.deprecate(
|
115
|
+
"expect(value).to #{RSpec::Support::ObjectFormatter.format(matcher)}",
|
116
|
+
:message =>
|
117
|
+
"The implicit block expectation syntax is deprecated, you should pass " \
|
118
|
+
"a block rather than an argument to `expect` to use the provided " \
|
119
|
+
"block expectation matcher or the matcher must implement " \
|
120
|
+
"`supports_value_expectations?`. e.g `expect { value }.to " \
|
121
|
+
"#{RSpec::Support::ObjectFormatter.format(matcher)}` not " \
|
122
|
+
"`expect(value).to #{RSpec::Support::ObjectFormatter.format(matcher)}`"
|
123
|
+
)
|
124
|
+
end
|
125
|
+
|
126
|
+
def supports_value_expectations?(matcher)
|
127
|
+
!matcher.respond_to?(:supports_value_expectations?) || matcher.supports_value_expectations?
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
93
131
|
# @private
|
94
132
|
# Validates the provided matcher to ensure it supports block
|
95
133
|
# expectations, in order to avoid user confusion when they
|
@@ -118,9 +156,7 @@ module RSpec
|
|
118
156
|
end
|
119
157
|
|
120
158
|
def supports_block_expectations?(matcher)
|
121
|
-
matcher.supports_block_expectations?
|
122
|
-
rescue NoMethodError
|
123
|
-
false
|
159
|
+
matcher.respond_to?(:supports_block_expectations?) && matcher.supports_block_expectations?
|
124
160
|
end
|
125
161
|
end
|
126
162
|
end
|
@@ -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
|
@@ -80,7 +97,7 @@ module RSpec
|
|
80
97
|
all_errors = failures + other_errors
|
81
98
|
|
82
99
|
case all_errors.size
|
83
|
-
when 0 then return
|
100
|
+
when 0 then return true
|
84
101
|
when 1 then RSpec::Support.notify_failure all_errors.first
|
85
102
|
else RSpec::Support.notify_failure MultipleExpectationsNotMetError.new(self)
|
86
103
|
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
|
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
|
-
|
109
|
-
return
|
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)
|
@@ -77,6 +77,11 @@ module RSpec
|
|
77
77
|
true
|
78
78
|
end
|
79
79
|
|
80
|
+
# @private
|
81
|
+
def supports_value_expectations?
|
82
|
+
false
|
83
|
+
end
|
84
|
+
|
80
85
|
private
|
81
86
|
|
82
87
|
def initialize(receiver=nil, message=nil, &block)
|
@@ -158,6 +163,11 @@ module RSpec
|
|
158
163
|
true
|
159
164
|
end
|
160
165
|
|
166
|
+
# @private
|
167
|
+
def supports_value_expectations?
|
168
|
+
false
|
169
|
+
end
|
170
|
+
|
161
171
|
private
|
162
172
|
|
163
173
|
def failure_reason
|
@@ -201,6 +211,11 @@ module RSpec
|
|
201
211
|
true
|
202
212
|
end
|
203
213
|
|
214
|
+
# @private
|
215
|
+
def supports_value_expectations?
|
216
|
+
false
|
217
|
+
end
|
218
|
+
|
204
219
|
private
|
205
220
|
|
206
221
|
def perform_change(event_proc)
|
@@ -337,6 +352,8 @@ module RSpec
|
|
337
352
|
class ChangeDetails
|
338
353
|
attr_reader :actual_after
|
339
354
|
|
355
|
+
UNDEFINED = Module.new.freeze
|
356
|
+
|
340
357
|
def initialize(matcher_name, receiver=nil, message=nil, &block)
|
341
358
|
if receiver && !message
|
342
359
|
raise(
|
@@ -351,6 +368,11 @@ module RSpec
|
|
351
368
|
@receiver = receiver
|
352
369
|
@message = message
|
353
370
|
@value_proc = block
|
371
|
+
# TODO: temporary measure to mute warning of access to an initialized
|
372
|
+
# instance variable when a deprecated implicit block expectation
|
373
|
+
# syntax is used. This may be removed once `fail` is used, and the
|
374
|
+
# matcher never issues this warning.
|
375
|
+
@actual_after = UNDEFINED
|
354
376
|
end
|
355
377
|
|
356
378
|
def value_representation
|
@@ -26,11 +26,19 @@ module RSpec
|
|
26
26
|
"#{matcher_1.description} #{conjunction} #{matcher_2.description}"
|
27
27
|
end
|
28
28
|
|
29
|
+
# @api private
|
29
30
|
def supports_block_expectations?
|
30
31
|
matcher_supports_block_expectations?(matcher_1) &&
|
31
32
|
matcher_supports_block_expectations?(matcher_2)
|
32
33
|
end
|
33
34
|
|
35
|
+
# @api private
|
36
|
+
def supports_value_expectations?
|
37
|
+
matcher_supports_value_expectations?(matcher_1) &&
|
38
|
+
matcher_supports_value_expectations?(matcher_2)
|
39
|
+
end
|
40
|
+
|
41
|
+
# @api private
|
34
42
|
def expects_call_stack_jump?
|
35
43
|
NestedEvaluator.matcher_expects_call_stack_jump?(matcher_1) ||
|
36
44
|
NestedEvaluator.matcher_expects_call_stack_jump?(matcher_2)
|
@@ -102,6 +110,12 @@ module RSpec
|
|
102
110
|
false
|
103
111
|
end
|
104
112
|
|
113
|
+
def matcher_supports_value_expectations?(matcher)
|
114
|
+
matcher.supports_value_expectations?
|
115
|
+
rescue NoMethodError
|
116
|
+
true
|
117
|
+
end
|
118
|
+
|
105
119
|
def matcher_is_diffable?(matcher)
|
106
120
|
matcher.diffable?
|
107
121
|
rescue NoMethodError
|
@@ -157,7 +171,7 @@ module RSpec
|
|
157
171
|
@match_results.fetch(matcher) do
|
158
172
|
raise ArgumentError, "Your #{matcher.description} has no match " \
|
159
173
|
"results, this can occur when an unexpected call stack or " \
|
160
|
-
"local jump occurs.
|
174
|
+
"local jump occurs. Perhaps one of your matchers needs to " \
|
161
175
|
"declare `expects_call_stack_jump?` as `true`?"
|
162
176
|
end
|
163
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
|
@@ -182,7 +182,7 @@ module RSpec
|
|
182
182
|
when String
|
183
183
|
actual.scan(expected.first).length
|
184
184
|
when Enumerable
|
185
|
-
count_enumerable(expected.first)
|
185
|
+
count_enumerable(Hash === expected ? expected : expected.first)
|
186
186
|
else
|
187
187
|
raise NotImplementedError, 'Count constraints are implemented for Enumerable and String values only'
|
188
188
|
end
|
@@ -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
|
@@ -59,7 +59,7 @@ module RSpec
|
|
59
59
|
given_proc.call
|
60
60
|
rescue Exception => @actual_error
|
61
61
|
if values_match?(@expected_error, @actual_error) ||
|
62
|
-
values_match?(@expected_error,
|
62
|
+
values_match?(@expected_error, actual_error_message)
|
63
63
|
@raised_expected_error = true
|
64
64
|
@with_expected_message = verify_message
|
65
65
|
end
|
@@ -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)
|
@@ -86,6 +86,12 @@ module RSpec
|
|
86
86
|
true
|
87
87
|
end
|
88
88
|
|
89
|
+
# @private
|
90
|
+
def supports_value_expectations?
|
91
|
+
false
|
92
|
+
end
|
93
|
+
|
94
|
+
# @private
|
89
95
|
def expects_call_stack_jump?
|
90
96
|
true
|
91
97
|
end
|
@@ -93,7 +99,7 @@ module RSpec
|
|
93
99
|
# @api private
|
94
100
|
# @return [String]
|
95
101
|
def failure_message
|
96
|
-
@eval_block ?
|
102
|
+
@eval_block ? actual_error_message : "expected #{expected_error}#{given_error}"
|
97
103
|
end
|
98
104
|
|
99
105
|
# @api private
|
@@ -110,6 +116,12 @@ module RSpec
|
|
110
116
|
|
111
117
|
private
|
112
118
|
|
119
|
+
def actual_error_message
|
120
|
+
return nil unless @actual_error
|
121
|
+
|
122
|
+
@actual_error.respond_to?(:original_message) ? @actual_error.original_message : @actual_error.message
|
123
|
+
end
|
124
|
+
|
113
125
|
def expectation_matched?
|
114
126
|
error_and_message_match? && block_matches?
|
115
127
|
end
|
@@ -138,7 +150,7 @@ module RSpec
|
|
138
150
|
|
139
151
|
def verify_message
|
140
152
|
return true if @expected_message.nil?
|
141
|
-
values_match?(@expected_message,
|
153
|
+
values_match?(@expected_message, actual_error_message.to_s)
|
142
154
|
end
|
143
155
|
|
144
156
|
def warn_for_negative_false_positives!
|
@@ -252,8 +264,8 @@ module RSpec
|
|
252
264
|
warning if @actual_error
|
253
265
|
end
|
254
266
|
end
|
255
|
-
# rubocop:enable RescueException
|
256
|
-
# rubocop:enable ClassLength
|
267
|
+
# rubocop:enable Lint/RescueException
|
268
|
+
# rubocop:enable Metrics/ClassLength
|
257
269
|
end
|
258
270
|
end
|
259
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
|
@@ -94,6 +94,12 @@ module RSpec
|
|
94
94
|
true
|
95
95
|
end
|
96
96
|
|
97
|
+
# @api private
|
98
|
+
def supports_value_expectations?
|
99
|
+
false
|
100
|
+
end
|
101
|
+
|
102
|
+
# @api private
|
97
103
|
def expects_call_stack_jump?
|
98
104
|
true
|
99
105
|
end
|
@@ -129,6 +129,11 @@ module RSpec
|
|
129
129
|
true
|
130
130
|
end
|
131
131
|
|
132
|
+
# @private
|
133
|
+
def supports_value_expectations?
|
134
|
+
false
|
135
|
+
end
|
136
|
+
|
132
137
|
private
|
133
138
|
|
134
139
|
def failure_reason
|
@@ -169,6 +174,11 @@ module RSpec
|
|
169
174
|
true
|
170
175
|
end
|
171
176
|
|
177
|
+
# @private
|
178
|
+
def supports_value_expectations?
|
179
|
+
false
|
180
|
+
end
|
181
|
+
|
172
182
|
private
|
173
183
|
|
174
184
|
def positive_failure_reason
|
@@ -231,6 +241,11 @@ module RSpec
|
|
231
241
|
true
|
232
242
|
end
|
233
243
|
|
244
|
+
# @private
|
245
|
+
def supports_value_expectations?
|
246
|
+
false
|
247
|
+
end
|
248
|
+
|
234
249
|
private
|
235
250
|
|
236
251
|
def positive_failure_reason
|
@@ -328,6 +343,11 @@ module RSpec
|
|
328
343
|
true
|
329
344
|
end
|
330
345
|
|
346
|
+
# @private
|
347
|
+
def supports_value_expectations?
|
348
|
+
false
|
349
|
+
end
|
350
|
+
|
331
351
|
private
|
332
352
|
|
333
353
|
def expected_arg_description
|
@@ -83,7 +83,7 @@ module RSpec
|
|
83
83
|
RSpec::Support::ObjectFormatter.format(object)
|
84
84
|
end
|
85
85
|
|
86
|
-
# Transforms the given data
|
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.
|
data/lib/rspec/matchers/dsl.rb
CHANGED
@@ -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
|
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
|
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
|
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
|
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
|
-
#
|
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
|
-
#
|
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
|
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
|
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
|
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`
|
@@ -403,6 +404,10 @@ module RSpec
|
|
403
404
|
false
|
404
405
|
end
|
405
406
|
|
407
|
+
def supports_value_expectations?
|
408
|
+
true
|
409
|
+
end
|
410
|
+
|
406
411
|
# Most matchers do not expect call stack jumps.
|
407
412
|
def expects_call_stack_jump?
|
408
413
|
false
|
@@ -60,6 +60,12 @@ module RSpec
|
|
60
60
|
# @return [Boolean] true if this matcher can be used in block expressions.
|
61
61
|
# @note If not defined, RSpec assumes a value of `false` for this method.
|
62
62
|
|
63
|
+
# @!method supports_value_expectations?
|
64
|
+
# Indicates that this matcher can be used in a value expectation expression,
|
65
|
+
# such as `expect(foo).to eq(bar)`.
|
66
|
+
# @return [Boolean] true if this matcher can be used in value expressions.
|
67
|
+
# @note If not defined, RSpec assumes a value of `true` for this method.
|
68
|
+
|
63
69
|
# @!method expects_call_stack_jump?
|
64
70
|
# Indicates that when this matcher is used in a block expectation
|
65
71
|
# expression, it expects the block to use a ruby construct that causes
|
data/lib/rspec/matchers.rb
CHANGED
@@ -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
|
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
|
-
#
|
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
|
757
|
-
# With a named error and
|
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.
|
4
|
+
version: 3.12.2
|
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:
|
48
|
+
date: 2023-01-07 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.
|
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.
|
63
|
+
version: 3.12.0
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: diff-lcs
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,14 +99,14 @@ dependencies:
|
|
99
99
|
name: cucumber
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- - "
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '1.3'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- - "
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '1.3'
|
112
112
|
- !ruby/object:Gem::Dependency
|
@@ -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.
|
206
|
+
changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.12.2/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.
|
226
|
+
rubygems_version: 3.3.26
|
227
227
|
signing_key:
|
228
228
|
specification_version: 4
|
229
|
-
summary: rspec-expectations-3.
|
229
|
+
summary: rspec-expectations-3.12.2
|
230
230
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|