rspec-expectations 3.10.2 → 3.11.0
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 +0 -0
- data/Changelog.md +14 -2
- data/README.md +1 -1
- data/lib/rspec/expectations/expectation_target.rb +39 -1
- data/lib/rspec/expectations/failure_aggregator.rb +1 -1
- data/lib/rspec/expectations/version.rb +1 -1
- 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 +14 -0
- data/lib/rspec/matchers/built_in/output.rb +7 -0
- data/lib/rspec/matchers/built_in/raise_error.rb +6 -0
- data/lib/rspec/matchers/built_in/throw_symbol.rb +6 -0
- data/lib/rspec/matchers/built_in/yield.rb +20 -0
- data/lib/rspec/matchers/dsl.rb +4 -0
- data/lib/rspec/matchers/matcher_protocol.rb +6 -0
- data.tar.gz.sig +0 -0
- metadata +6 -6
- 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: e651e80dd869915779a72a9ea43b38d20327f3dbfaf94a4851eff7974d1f3d0a
|
4
|
+
data.tar.gz: e1788055c911b97cbad1b3747fe9b9be005a999e2e97e6c361df4c91fa4fda25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1b6b68b80fddae764dbf88312817c35c1e76228c29748e2b89d8d9a69d95384aa4fe9daf7b8a650dd307dd32aca13bae590d8960f0989beea67c54f7f6d7d5
|
7
|
+
data.tar.gz: 7a8a129e74ccec6299ab3af1c728cab2754a1cc98911507704c3f52a01c33b321250bfe715deef835b61963e22c66ec878500d10c6fea93d4fda7cc39b101676
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
### Development
|
2
|
-
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.11.0...3-11-maintenance)
|
3
|
+
|
4
|
+
### 3.11.0 / 2022-02-09
|
5
|
+
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.10.2...v3.11.0)
|
6
|
+
|
7
|
+
Enhancements:
|
8
|
+
|
9
|
+
* Return `true` from `aggregate_failures` when no exception occurs. (Jon Rowe, #1225)
|
10
|
+
|
11
|
+
Deprecations:
|
12
|
+
|
13
|
+
* Print a deprecation message when using the implicit block expectation syntax.
|
14
|
+
(Phil Pirozhkov, #1139)
|
3
15
|
|
4
16
|
### 3.10.2 / 2022-01-14
|
5
17
|
[Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.10.1...v3.10.2)
|
@@ -128,7 +140,7 @@ Bug Fixes:
|
|
128
140
|
* Prevent composed `all` matchers from leaking into their siblings leading to duplicate
|
129
141
|
failures. (Jamie English, #1086)
|
130
142
|
* Prevent objects which change their hash on comparison from failing change checks.
|
131
|
-
(Phil Pirozhkov, #
|
143
|
+
(Phil Pirozhkov, #1100)
|
132
144
|
* Issue an `ArgumentError` rather than a `NoMethodError` when `be_an_instance_of` and
|
133
145
|
`be_kind_of` matchers encounter objects not supporting those methods.
|
134
146
|
(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
|
|
@@ -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
|
@@ -80,7 +80,7 @@ module RSpec
|
|
80
80
|
all_errors = failures + other_errors
|
81
81
|
|
82
82
|
case all_errors.size
|
83
|
-
when 0 then return
|
83
|
+
when 0 then return true
|
84
84
|
when 1 then RSpec::Support.notify_failure all_errors.first
|
85
85
|
else RSpec::Support.notify_failure MultipleExpectationsNotMetError.new(self)
|
86
86
|
end
|
@@ -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
|
@@ -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
|
data/lib/rspec/matchers/dsl.rb
CHANGED
@@ -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.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.11.0
|
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-
|
48
|
+
date: 2022-02-09 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.11.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.11.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.
|
206
|
+
changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.11.0/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.3
|
227
227
|
signing_key:
|
228
228
|
specification_version: 4
|
229
|
-
summary: rspec-expectations-3.
|
229
|
+
summary: rspec-expectations-3.11.0
|
230
230
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|