rspec-expectations 3.8.5 → 3.8.6

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: 58597a62f47f10ecd74eda0086bcee4ca68878120d63cc670ebae37f9db1d252
4
- data.tar.gz: 7443ec753991ae3c88ac9be2e8a22aab784b7e10bd2be481bf8a83daf3b85778
3
+ metadata.gz: d1f0c43e7a6933605f4b96eb0a5545bd5e1b03a2b2de4471edada5000f3c5c37
4
+ data.tar.gz: 62b85e7625d066114174dfaa586dbb2cb419aa0bc470b68918c2524b841f8762
5
5
  SHA512:
6
- metadata.gz: 36dab83e0399bbf5c58f17f3302c865ca4ec92123c97cc6eea1f9bf80a5466e643adfbd3056e46a653c5bbc08fc93f5d804bc9ca4a2e841468b22f09e2a140ec
7
- data.tar.gz: f4b9263c27571536fa276eefee5a2c115a9f1f3d070f1abcaf4fba9e5e2cd2f11e04f48d146c870b26d019f6fb8533b3e2b605ff422ab32832f51d1531743515
6
+ metadata.gz: 5ba237ec4317b7af0780f5e929e10da26b501f76a23cb807684498a21118ef0f72598c1ded7ee0436a8a29f97ea16a0d4f887c7b345b22302f5b8ef50c660beb
7
+ data.tar.gz: 4138b8b208b668216660d55f5634440e8240c4a36f15489fc3e1e6093d4a8530fc419d9f958ea4526ac63e7e9e2d589c7716a21832d257adac823486d5dfae77
Binary file
data.tar.gz.sig CHANGED
@@ -1,4 +1,5 @@
1
- ���_��\���m��2��r��Ui��5sF
2
- Y��Z[�X0�ֆ�#+���긲����':����9�"��@��,�7}��6l�w�|-#삎���
3
- 8ז������  ���v���Wq!Mw���m�ulq
4
- unE��q?�ਰ?�� ֕7-#�8 g$XS�/�r�/���ͩc��JZdh�ke;(�/���B�!i�J�ߟߜ1�Ɋ�9J�#]�/ ��y��T3]"�dZV=�4mB��P�����x�f|J
5
- ����}�F����=��\���s�v�=��n��J@�0���w��cz�5�V�[���<�/�0E]Xp��y�͝&��Ö;���A� V%�g;m�����a`Y�uϥ����}igo��d3�Mw[���3�׶�n6��g,13I�����0q!��fƦ�����v�^;|F:������,��
1
+ p]���[���03$�iė?��
2
+ �6s���1ϑ�x ����6n�������7�u��
3
+ "�l����@򣙅!;E��(c}=>8�a���Br {�� 5�����e�����?O7�Q�����g� f�Ip+�H;m�-�#\ d�uZ�7�����8s�kug��2G+'1m')�V�����L�5^(�����L�0F�b8q��੦h�T�:�X�zB-тϳ.(��A������q}&b̟o����&�e�+��C��ø.��c���9|v��)h��C*�6،�� d۳
4
+ h{Q'���lF׈�7��������h��)#g����{�\�u9&��M�����l��
5
+ �a���$<�|�} 5�������}S�#��KW#c-�r ����t~�O�+T[���#HX�,&��)��^�!�ٓڿr��������� ���}��=dk<�N"3��u�\�22��8Y��' M [�i�T�ɚ �|?
@@ -1,3 +1,10 @@
1
+ ### 3.8.6 / 2019-10-07
2
+
3
+ Bug Fixes:
4
+
5
+ * Revert #1125 due to the change being incompatible with our semantic versioning
6
+ policy.
7
+
1
8
  ### 3.8.5 / 2019-10-02
2
9
  [Full Changelog](http://github.com/rspec/rspec-expectations/compare/v3.8.4...v3.8.5)
3
10
 
@@ -22,7 +29,7 @@ Bug Fixes:
22
29
  * Prevent composed `all` matchers from leaking into their siblings leading to duplicate
23
30
  failures. (Jamie English, #1086)
24
31
  * Prevent objects which change their hash on comparison from failing change checks.
25
- (Phil Pirozhkov, #1100)
32
+ (Phil Pirozhkov, #1110)
26
33
  * Issue an `ArgumentError` rather than a `NoMethodError` when `be_an_instance_of` and
27
34
  `be_kind_of` matchers encounter objects not supporting those methods.
28
35
  (Taichi Ishitani, #1107)
@@ -33,16 +33,16 @@ module RSpec
33
33
  end
34
34
 
35
35
  # @private
36
- def self.for(value, &block)
36
+ def self.for(value, block)
37
37
  if UndefinedValue.equal?(value)
38
- unless block_given?
38
+ unless block
39
39
  raise ArgumentError, "You must pass either an argument or a block to `expect`."
40
40
  end
41
41
  BlockExpectationTarget.new(block)
42
- elsif block_given?
42
+ elsif block
43
43
  raise ArgumentError, "You cannot pass both an argument and a block to `expect`."
44
44
  else
45
- ValueExpectationTarget.new(value)
45
+ new(value)
46
46
  end
47
47
  end
48
48
 
@@ -90,40 +90,6 @@ 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
- raise ExpectationNotMetError, "You must pass a block rather than an argument to `expect` to use the provided " \
115
- "block expectation matcher (#{RSpec::Support::ObjectFormatter.format(matcher)})."
116
- end
117
-
118
- def supports_value_expectations?(matcher)
119
- if matcher.respond_to?(:supports_value_expectations?)
120
- matcher.supports_value_expectations?
121
- else
122
- true
123
- end
124
- end
125
- end
126
-
127
93
  # @private
128
94
  # Validates the provided matcher to ensure it supports block
129
95
  # expectations, in order to avoid user confusion when they
@@ -152,11 +118,9 @@ module RSpec
152
118
  end
153
119
 
154
120
  def supports_block_expectations?(matcher)
155
- if matcher.respond_to?(:supports_block_expectations?)
156
- matcher.supports_block_expectations?
157
- else
158
- false
159
- end
121
+ matcher.supports_block_expectations?
122
+ rescue NoMethodError
123
+ false
160
124
  end
161
125
  end
162
126
  end
@@ -70,7 +70,7 @@ module RSpec
70
70
 
71
71
  syntax_host.module_exec do
72
72
  def expect(value=::RSpec::Expectations::ExpectationTarget::UndefinedValue, &block)
73
- ::RSpec::Expectations::ExpectationTarget.for(value, &block)
73
+ ::RSpec::Expectations::ExpectationTarget.for(value, block)
74
74
  end
75
75
  end
76
76
  end
@@ -2,7 +2,7 @@ module RSpec
2
2
  module Expectations
3
3
  # @private
4
4
  module Version
5
- STRING = '3.8.5'
5
+ STRING = '3.8.6'
6
6
  end
7
7
  end
8
8
  end
@@ -78,11 +78,6 @@ module RSpec
78
78
  false
79
79
  end
80
80
 
81
- # @private
82
- def supports_value_expectations?
83
- true
84
- end
85
-
86
81
  # @api private
87
82
  def expects_call_stack_jump?
88
83
  false
@@ -77,11 +77,6 @@ module RSpec
77
77
  true
78
78
  end
79
79
 
80
- # @private
81
- def supports_value_expectations?
82
- false
83
- end
84
-
85
80
  private
86
81
 
87
82
  def initialize(receiver=nil, message=nil, &block)
@@ -112,10 +107,12 @@ module RSpec
112
107
  end
113
108
 
114
109
  def positive_failure_reason
110
+ return "was not given a block" unless Proc === @event_proc
115
111
  "is still #{@actual_before_description}"
116
112
  end
117
113
 
118
114
  def negative_failure_reason
115
+ return "was not given a block" unless Proc === @event_proc
119
116
  "did change from #{@actual_before_description} " \
120
117
  "to #{description_of change_details.actual_after}"
121
118
  end
@@ -161,14 +158,10 @@ module RSpec
161
158
  true
162
159
  end
163
160
 
164
- # @private
165
- def supports_value_expectations?
166
- false
167
- end
168
-
169
161
  private
170
162
 
171
163
  def failure_reason
164
+ return "was not given a block" unless Proc === @event_proc
172
165
  "was changed by #{description_of @change_details.actual_delta}"
173
166
  end
174
167
  end
@@ -197,6 +190,7 @@ module RSpec
197
190
 
198
191
  # @private
199
192
  def failure_message
193
+ return not_given_a_block_failure unless Proc === @event_proc
200
194
  return before_value_failure unless @matches_before
201
195
  return did_not_change_failure unless @change_details.changed?
202
196
  after_value_failure
@@ -207,11 +201,6 @@ module RSpec
207
201
  true
208
202
  end
209
203
 
210
- # @private
211
- def supports_value_expectations?
212
- false
213
- end
214
-
215
204
  private
216
205
 
217
206
  def perform_change(event_proc)
@@ -253,6 +242,11 @@ module RSpec
253
242
  "did change from #{@actual_before_description} " \
254
243
  "to #{description_of @change_details.actual_after}"
255
244
  end
245
+
246
+ def not_given_a_block_failure
247
+ "expected #{@change_details.value_representation} to have changed " \
248
+ "#{change_description}, but was not given a block"
249
+ end
256
250
  end
257
251
 
258
252
  # @api private
@@ -284,6 +278,7 @@ module RSpec
284
278
 
285
279
  # @private
286
280
  def failure_message_when_negated
281
+ return not_given_a_block_failure unless Proc === @event_proc
287
282
  return before_value_failure unless @matches_before
288
283
  did_change_failure
289
284
  end
@@ -26,19 +26,11 @@ module RSpec
26
26
  "#{matcher_1.description} #{conjunction} #{matcher_2.description}"
27
27
  end
28
28
 
29
- # @api private
30
29
  def supports_block_expectations?
31
30
  matcher_supports_block_expectations?(matcher_1) &&
32
31
  matcher_supports_block_expectations?(matcher_2)
33
32
  end
34
33
 
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
42
34
  def expects_call_stack_jump?
43
35
  NestedEvaluator.matcher_expects_call_stack_jump?(matcher_1) ||
44
36
  NestedEvaluator.matcher_expects_call_stack_jump?(matcher_2)
@@ -110,12 +102,6 @@ module RSpec
110
102
  false
111
103
  end
112
104
 
113
- def matcher_supports_value_expectations?(matcher)
114
- matcher.supports_value_expectations?
115
- rescue NoMethodError
116
- true
117
- end
118
-
119
105
  def matcher_is_diffable?(matcher)
120
106
  matcher.diffable?
121
107
  rescue NoMethodError
@@ -94,13 +94,6 @@ module RSpec
94
94
  true
95
95
  end
96
96
 
97
- # @api private
98
- # Indicates this matcher matches against a block only.
99
- # @return [False]
100
- def supports_value_expectations?
101
- false
102
- end
103
-
104
97
  private
105
98
 
106
99
  def captured?
@@ -108,11 +101,13 @@ module RSpec
108
101
  end
109
102
 
110
103
  def positive_failure_reason
104
+ return "was not a block" unless Proc === @block
111
105
  return "output #{actual_output_description}" if @expected
112
106
  "did not"
113
107
  end
114
108
 
115
109
  def negative_failure_reason
110
+ return "was not a block" unless Proc === @block
116
111
  "output #{actual_output_description}"
117
112
  end
118
113
 
@@ -76,12 +76,6 @@ module RSpec
76
76
  true
77
77
  end
78
78
 
79
- # @private
80
- def supports_value_expectations?
81
- false
82
- end
83
-
84
- # @private
85
79
  def expects_call_stack_jump?
86
80
  true
87
81
  end
@@ -205,6 +199,7 @@ module RSpec
205
199
  end
206
200
 
207
201
  def given_error
202
+ return " but was not given a block" unless Proc === @given_proc
208
203
  return " but nothing was raised" unless @actual_error
209
204
 
210
205
  backtrace = format_backtrace(@actual_error.backtrace)
@@ -88,16 +88,12 @@ module RSpec
88
88
  end
89
89
 
90
90
  # @api private
91
+ # Indicates this matcher matches against a block.
92
+ # @return [True]
91
93
  def supports_block_expectations?
92
94
  true
93
95
  end
94
96
 
95
- # @api private
96
- def supports_value_expectations?
97
- false
98
- end
99
-
100
- # @api private
101
97
  def expects_call_stack_jump?
102
98
  true
103
99
  end
@@ -105,6 +101,7 @@ module RSpec
105
101
  private
106
102
 
107
103
  def actual_result
104
+ return "but was not a block" unless Proc === @block
108
105
  "got #{caught}"
109
106
  end
110
107
 
@@ -10,6 +10,7 @@ module RSpec
10
10
  class YieldProbe
11
11
  def self.probe(block, &callback)
12
12
  probe = new(block, &callback)
13
+ return probe unless probe.has_block?
13
14
  probe.probe
14
15
  end
15
16
 
@@ -23,6 +24,10 @@ module RSpec
23
24
  self.yielded_args = []
24
25
  end
25
26
 
27
+ def has_block?
28
+ Proc === @block
29
+ end
30
+
26
31
  def probe
27
32
  assert_valid_expect_block!
28
33
  @block.call(self)
@@ -147,12 +152,14 @@ module RSpec
147
152
  # @private
148
153
  def matches?(block)
149
154
  @probe = YieldProbe.probe(block)
155
+ return false unless @probe.has_block?
156
+
150
157
  @probe.num_yields.__send__(@expectation_type, @expected_yields_count)
151
158
  end
152
159
 
153
160
  # @private
154
161
  def does_not_match?(block)
155
- !matches?(block)
162
+ !matches?(block) && @probe.has_block?
156
163
  end
157
164
 
158
165
  # @api private
@@ -172,11 +179,6 @@ module RSpec
172
179
  true
173
180
  end
174
181
 
175
- # @private
176
- def supports_value_expectations?
177
- false
178
- end
179
-
180
182
  private
181
183
 
182
184
  def set_expected_yields_count(relativity, n)
@@ -190,6 +192,7 @@ module RSpec
190
192
  end
191
193
 
192
194
  def failure_reason
195
+ return ' but was not a block' unless @probe.has_block?
193
196
  return '' unless @expected_yields_count
194
197
  " #{human_readable_expectation_type}#{human_readable_count(@expected_yields_count)}" \
195
198
  " but yielded #{human_readable_count(@probe.num_yields)}"
@@ -219,12 +222,13 @@ module RSpec
219
222
  # @private
220
223
  def matches?(block)
221
224
  @probe = YieldProbe.probe(block)
225
+ return false unless @probe.has_block?
222
226
  @probe.yielded_once?(:yield_with_no_args) && @probe.single_yield_args.empty?
223
227
  end
224
228
 
225
229
  # @private
226
230
  def does_not_match?(block)
227
- !matches?(block)
231
+ !matches?(block) && @probe.has_block?
228
232
  end
229
233
 
230
234
  # @private
@@ -242,19 +246,16 @@ module RSpec
242
246
  true
243
247
  end
244
248
 
245
- # @private
246
- def supports_value_expectations?
247
- false
248
- end
249
-
250
249
  private
251
250
 
252
251
  def positive_failure_reason
252
+ return 'was not a block' unless @probe.has_block?
253
253
  return 'did not yield' if @probe.num_yields.zero?
254
254
  "yielded with arguments: #{description_of @probe.single_yield_args}"
255
255
  end
256
256
 
257
257
  def negative_failure_reason
258
+ return 'was not a block' unless @probe.has_block?
258
259
  'did'
259
260
  end
260
261
  end
@@ -275,13 +276,14 @@ module RSpec
275
276
  @actual_formatted = actual_formatted
276
277
  @args_matched_when_yielded &&= args_currently_match?
277
278
  end
279
+ return false unless @probe.has_block?
278
280
  @probe.probe
279
281
  @probe.yielded_once?(:yield_with_args) && @args_matched_when_yielded
280
282
  end
281
283
 
282
284
  # @private
283
285
  def does_not_match?(block)
284
- !matches?(block)
286
+ !matches?(block) && @probe.has_block?
285
287
  end
286
288
 
287
289
  # @private
@@ -306,14 +308,10 @@ module RSpec
306
308
  true
307
309
  end
308
310
 
309
- # @private
310
- def supports_value_expectations?
311
- false
312
- end
313
-
314
311
  private
315
312
 
316
313
  def positive_failure_reason
314
+ return 'was not a block' unless @probe.has_block?
317
315
  return 'did not yield' if @probe.num_yields.zero?
318
316
  @positive_args_failure
319
317
  end
@@ -323,7 +321,9 @@ module RSpec
323
321
  end
324
322
 
325
323
  def negative_failure_reason
326
- if @args_matched_when_yielded && !@expected.empty?
324
+ if !@probe.has_block?
325
+ 'was not a block'
326
+ elsif @args_matched_when_yielded && !@expected.empty?
327
327
  'yielded with expected arguments' \
328
328
  "\nexpected not: #{surface_descriptions_in(@expected).inspect}" \
329
329
  "\n got: #{@actual_formatted}"
@@ -375,11 +375,12 @@ module RSpec
375
375
  yield_count += 1
376
376
  end
377
377
 
378
+ return false unless @probe.has_block?
378
379
  args_matched_when_yielded && yield_count == @expected.length
379
380
  end
380
381
 
381
382
  def does_not_match?(block)
382
- !matches?(block)
383
+ !matches?(block) && @probe.has_block?
383
384
  end
384
385
 
385
386
  # @private
@@ -404,11 +405,6 @@ module RSpec
404
405
  true
405
406
  end
406
407
 
407
- # @private
408
- def supports_value_expectations?
409
- false
410
- end
411
-
412
408
  private
413
409
 
414
410
  def expected_arg_description
@@ -416,12 +412,16 @@ module RSpec
416
412
  end
417
413
 
418
414
  def positive_failure_reason
415
+ return 'was not a block' unless @probe.has_block?
416
+
419
417
  'yielded with unexpected arguments' \
420
418
  "\nexpected: #{surface_descriptions_in(@expected).inspect}" \
421
419
  "\n got: [#{@actual_formatted.join(", ")}]"
422
420
  end
423
421
 
424
422
  def negative_failure_reason
423
+ return 'was not a block' unless @probe.has_block?
424
+
425
425
  'yielded with expected arguments' \
426
426
  "\nexpected not: #{surface_descriptions_in(@expected).inspect}" \
427
427
  "\n got: [#{@actual_formatted.join(", ")}]"
@@ -394,10 +394,6 @@ module RSpec
394
394
  false
395
395
  end
396
396
 
397
- def supports_value_expectations?
398
- true
399
- end
400
-
401
397
  # Most matchers do not expect call stack jumps.
402
398
  def expects_call_stack_jump?
403
399
  false
@@ -60,12 +60,6 @@ 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
-
69
63
  # @!method expects_call_stack_jump?
70
64
  # Indicates that when this matcher is used in a block expectation
71
65
  # expression, it expects the block to use a ruby construct that causes
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.8.5
4
+ version: 3.8.6
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: 2019-10-02 00:00:00.000000000 Z
48
+ date: 2019-10-07 00:00:00.000000000 Z
49
49
  dependencies:
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rspec-support
@@ -188,7 +188,7 @@ licenses:
188
188
  - MIT
189
189
  metadata:
190
190
  bug_tracker_uri: https://github.com/rspec/rspec-expectations/issues
191
- changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.8.5/Changelog.md
191
+ changelog_uri: https://github.com/rspec/rspec-expectations/blob/v3.8.6/Changelog.md
192
192
  documentation_uri: https://rspec.info/documentation/
193
193
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
194
194
  source_code_uri: https://github.com/rspec/rspec-expectations
@@ -211,5 +211,5 @@ requirements: []
211
211
  rubygems_version: 3.0.6
212
212
  signing_key:
213
213
  specification_version: 4
214
- summary: rspec-expectations-3.8.5
214
+ summary: rspec-expectations-3.8.6
215
215
  test_files: []
metadata.gz.sig CHANGED
Binary file