rspec-expectations 3.0.4 → 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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data/.document +1 -1
- data/.yardopts +1 -1
- data/Changelog.md +530 -5
- data/{License.txt → LICENSE.md} +5 -4
- data/README.md +73 -31
- data/lib/rspec/expectations/block_snippet_extractor.rb +253 -0
- data/lib/rspec/expectations/configuration.rb +96 -1
- data/lib/rspec/expectations/expectation_target.rb +82 -38
- data/lib/rspec/expectations/fail_with.rb +11 -6
- data/lib/rspec/expectations/failure_aggregator.rb +229 -0
- data/lib/rspec/expectations/handler.rb +36 -15
- data/lib/rspec/expectations/minitest_integration.rb +43 -2
- data/lib/rspec/expectations/syntax.rb +5 -5
- data/lib/rspec/expectations/version.rb +1 -1
- data/lib/rspec/expectations.rb +15 -1
- data/lib/rspec/matchers/aliased_matcher.rb +79 -4
- data/lib/rspec/matchers/built_in/all.rb +11 -0
- data/lib/rspec/matchers/built_in/base_matcher.rb +111 -28
- data/lib/rspec/matchers/built_in/be.rb +28 -114
- data/lib/rspec/matchers/built_in/be_between.rb +1 -1
- data/lib/rspec/matchers/built_in/be_instance_of.rb +5 -1
- data/lib/rspec/matchers/built_in/be_kind_of.rb +5 -1
- data/lib/rspec/matchers/built_in/be_within.rb +5 -12
- data/lib/rspec/matchers/built_in/change.rb +171 -63
- data/lib/rspec/matchers/built_in/compound.rb +201 -30
- data/lib/rspec/matchers/built_in/contain_exactly.rb +73 -12
- data/lib/rspec/matchers/built_in/count_expectation.rb +169 -0
- data/lib/rspec/matchers/built_in/eq.rb +3 -38
- data/lib/rspec/matchers/built_in/eql.rb +2 -2
- data/lib/rspec/matchers/built_in/equal.rb +3 -3
- data/lib/rspec/matchers/built_in/exist.rb +7 -3
- data/lib/rspec/matchers/built_in/has.rb +93 -30
- data/lib/rspec/matchers/built_in/have_attributes.rb +114 -0
- data/lib/rspec/matchers/built_in/include.rb +133 -25
- data/lib/rspec/matchers/built_in/match.rb +79 -2
- data/lib/rspec/matchers/built_in/operators.rb +14 -5
- data/lib/rspec/matchers/built_in/output.rb +59 -2
- data/lib/rspec/matchers/built_in/raise_error.rb +130 -27
- data/lib/rspec/matchers/built_in/respond_to.rb +117 -15
- data/lib/rspec/matchers/built_in/satisfy.rb +28 -14
- data/lib/rspec/matchers/built_in/{start_and_end_with.rb → start_or_end_with.rb} +20 -8
- data/lib/rspec/matchers/built_in/throw_symbol.rb +15 -5
- data/lib/rspec/matchers/built_in/yield.rb +129 -156
- data/lib/rspec/matchers/built_in.rb +5 -3
- data/lib/rspec/matchers/composable.rb +24 -36
- data/lib/rspec/matchers/dsl.rb +203 -37
- data/lib/rspec/matchers/english_phrasing.rb +58 -0
- data/lib/rspec/matchers/expecteds_for_multiple_diffs.rb +82 -0
- data/lib/rspec/matchers/fail_matchers.rb +42 -0
- data/lib/rspec/matchers/generated_descriptions.rb +1 -2
- data/lib/rspec/matchers/matcher_delegator.rb +3 -4
- data/lib/rspec/matchers/matcher_protocol.rb +105 -0
- data/lib/rspec/matchers.rb +267 -144
- data.tar.gz.sig +0 -0
- metadata +71 -49
- metadata.gz.sig +0 -0
- data/lib/rspec/matchers/pretty.rb +0 -77
@@ -4,7 +4,7 @@ module RSpec
|
|
4
4
|
# @api private
|
5
5
|
# Base class for the `end_with` and `start_with` matchers.
|
6
6
|
# Not intended to be instantiated directly.
|
7
|
-
class
|
7
|
+
class StartOrEndWith < BaseMatcher
|
8
8
|
def initialize(*expected)
|
9
9
|
@actual_does_not_have_ordered_elements = false
|
10
10
|
@expected = expected.length == 1 ? expected.first : expected
|
@@ -26,16 +26,18 @@ module RSpec
|
|
26
26
|
# @return [String]
|
27
27
|
def description
|
28
28
|
return super unless Hash === expected
|
29
|
-
|
29
|
+
english_name = EnglishPhrasing.split_words(self.class.matcher_name)
|
30
|
+
description_of_expected = surface_descriptions_in(expected).inspect
|
31
|
+
"#{english_name} #{description_of_expected}"
|
30
32
|
end
|
31
33
|
|
32
34
|
private
|
33
35
|
|
34
|
-
def match(
|
36
|
+
def match(_expected, actual)
|
35
37
|
return false unless actual.respond_to?(:[])
|
36
38
|
|
37
39
|
begin
|
38
|
-
return
|
40
|
+
return true if subsets_comparable? && subset_matches?
|
39
41
|
element_matches?
|
40
42
|
rescue ArgumentError
|
41
43
|
@actual_does_not_have_ordered_elements = true
|
@@ -43,15 +45,25 @@ module RSpec
|
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
46
|
-
def
|
47
|
-
|
48
|
+
def subsets_comparable?
|
49
|
+
# Structs support the Enumerable interface but don't really have
|
50
|
+
# the semantics of a subset of a larger set...
|
51
|
+
return false if Struct === expected
|
52
|
+
|
53
|
+
expected.respond_to?(:length)
|
48
54
|
end
|
49
55
|
end
|
50
56
|
|
57
|
+
# For RSpec 3.1, the base class was named `StartAndEndWith`. For SemVer reasons,
|
58
|
+
# we still provide this constant until 4.0.
|
59
|
+
# @deprecated Use StartOrEndWith instead.
|
60
|
+
# @private
|
61
|
+
StartAndEndWith = StartOrEndWith
|
62
|
+
|
51
63
|
# @api private
|
52
64
|
# Provides the implementation for `start_with`.
|
53
65
|
# Not intended to be instantiated directly.
|
54
|
-
class StartWith <
|
66
|
+
class StartWith < StartOrEndWith
|
55
67
|
private
|
56
68
|
|
57
69
|
def subset_matches?
|
@@ -66,7 +78,7 @@ module RSpec
|
|
66
78
|
# @api private
|
67
79
|
# Provides the implementation for `end_with`.
|
68
80
|
# Not intended to be instantiated directly.
|
69
|
-
class EndWith <
|
81
|
+
class EndWith < StartOrEndWith
|
70
82
|
private
|
71
83
|
|
72
84
|
def subset_matches?
|
@@ -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,16 @@ 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
|
103
|
+
def expects_call_stack_jump?
|
104
|
+
true
|
105
|
+
end
|
106
|
+
|
97
107
|
private
|
98
108
|
|
99
109
|
def actual_result
|
@@ -110,7 +120,7 @@ module RSpec
|
|
110
120
|
end
|
111
121
|
|
112
122
|
def throw_description(symbol, arg)
|
113
|
-
symbol_description = symbol.is_a?(String) ? symbol : symbol
|
123
|
+
symbol_description = symbol.is_a?(String) ? symbol : description_of(symbol)
|
114
124
|
|
115
125
|
arg_description = if arg
|
116
126
|
" with #{description_of arg}"
|
@@ -1,3 +1,7 @@
|
|
1
|
+
require 'rspec/matchers/built_in/count_expectation'
|
2
|
+
|
3
|
+
RSpec::Support.require_rspec_support 'method_signature_verifier'
|
4
|
+
|
1
5
|
module RSpec
|
2
6
|
module Matchers
|
3
7
|
module BuiltIn
|
@@ -6,34 +10,42 @@ module RSpec
|
|
6
10
|
# yield matchers is used. Provides information about
|
7
11
|
# the yield behavior of the object-under-test.
|
8
12
|
class YieldProbe
|
9
|
-
def self.probe(block)
|
10
|
-
probe = new(block)
|
13
|
+
def self.probe(block, &callback)
|
14
|
+
probe = new(block, &callback)
|
11
15
|
return probe unless probe.has_block?
|
12
|
-
probe.
|
13
|
-
block.call(probe)
|
14
|
-
probe.assert_used!
|
15
|
-
probe
|
16
|
+
probe.probe
|
16
17
|
end
|
17
18
|
|
18
19
|
attr_accessor :num_yields, :yielded_args
|
19
20
|
|
20
|
-
def initialize(block)
|
21
|
+
def initialize(block, &callback)
|
21
22
|
@block = block
|
23
|
+
@callback = callback || Proc.new {}
|
22
24
|
@used = false
|
23
|
-
self.num_yields
|
25
|
+
self.num_yields = 0
|
26
|
+
self.yielded_args = []
|
24
27
|
end
|
25
28
|
|
26
29
|
def has_block?
|
27
30
|
Proc === @block
|
28
31
|
end
|
29
32
|
|
33
|
+
def probe
|
34
|
+
assert_valid_expect_block!
|
35
|
+
@block.call(self)
|
36
|
+
assert_used!
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
30
40
|
def to_proc
|
31
41
|
@used = true
|
32
42
|
|
33
43
|
probe = self
|
44
|
+
callback = @callback
|
34
45
|
Proc.new do |*args|
|
35
46
|
probe.num_yields += 1
|
36
47
|
probe.yielded_args << args
|
48
|
+
callback.call(*args)
|
37
49
|
nil # to indicate the block does not return a meaningful value
|
38
50
|
end
|
39
51
|
end
|
@@ -48,30 +60,38 @@ module RSpec
|
|
48
60
|
when 0 then false
|
49
61
|
else
|
50
62
|
raise "The #{matcher_name} matcher is not designed to be used with a " \
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def successive_yield_args
|
57
|
-
yielded_args.map do |arg_array|
|
58
|
-
arg_array.size == 1 ? arg_array.first : arg_array
|
63
|
+
'method that yields multiple times. Use the yield_successive_args ' \
|
64
|
+
'matcher for that case.'
|
59
65
|
end
|
60
66
|
end
|
61
67
|
|
62
68
|
def assert_used!
|
63
69
|
return if @used
|
64
|
-
raise
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
raise 'You must pass the argument yielded to your expect block on ' \
|
71
|
+
'to the method-under-test as a block. It acts as a probe that ' \
|
72
|
+
'allows the matcher to detect whether or not the method-under-test ' \
|
73
|
+
'yields, and, if so, how many times, and what the yielded arguments ' \
|
74
|
+
'are.'
|
75
|
+
end
|
76
|
+
|
77
|
+
if RUBY_VERSION.to_f > 1.8
|
78
|
+
def assert_valid_expect_block!
|
79
|
+
block_signature = RSpec::Support::BlockSignature.new(@block)
|
80
|
+
return if RSpec::Support::StrictSignatureVerifier.new(block_signature, [self]).valid?
|
81
|
+
raise 'Your expect block must accept an argument to be used with this ' \
|
82
|
+
'matcher. Pass the argument as a block on to the method you are testing.'
|
83
|
+
end
|
84
|
+
else
|
85
|
+
# :nocov:
|
86
|
+
# On 1.8.7, `lambda { }.arity` and `lambda { |*a| }.arity` both return -1,
|
87
|
+
# so we can't distinguish between accepting no args and an arg splat.
|
88
|
+
# It's OK to skip, this, though; it just provides a nice error message
|
89
|
+
# when the user forgets to accept an arg in their block. They'll still get
|
90
|
+
# the `assert_used!` error message from above, which is sufficient.
|
91
|
+
def assert_valid_expect_block!
|
92
|
+
# nothing to do
|
93
|
+
end
|
94
|
+
# :nocov:
|
75
95
|
end
|
76
96
|
end
|
77
97
|
|
@@ -79,62 +99,12 @@ module RSpec
|
|
79
99
|
# Provides the implementation for `yield_control`.
|
80
100
|
# Not intended to be instantiated directly.
|
81
101
|
class YieldControl < BaseMatcher
|
82
|
-
|
83
|
-
@expectation_type = nil
|
84
|
-
@expected_yields_count = nil
|
85
|
-
end
|
86
|
-
|
87
|
-
# @api public
|
88
|
-
# Specifies that the method is expected to yield once.
|
89
|
-
def once
|
90
|
-
exactly(1)
|
91
|
-
self
|
92
|
-
end
|
93
|
-
|
94
|
-
# @api public
|
95
|
-
# Specifies that the method is expected to yield once.
|
96
|
-
def twice
|
97
|
-
exactly(2)
|
98
|
-
self
|
99
|
-
end
|
100
|
-
|
101
|
-
# @api public
|
102
|
-
# Specifies that the method is expected to yield the given number of times.
|
103
|
-
def exactly(number)
|
104
|
-
set_expected_yields_count(:==, number)
|
105
|
-
self
|
106
|
-
end
|
107
|
-
|
108
|
-
# @api public
|
109
|
-
# Specifies the maximum number of times the method is expected to yield
|
110
|
-
def at_most(number)
|
111
|
-
set_expected_yields_count(:<=, number)
|
112
|
-
self
|
113
|
-
end
|
114
|
-
|
115
|
-
# @api public
|
116
|
-
# Specifies the minimum number of times the method is expected to yield
|
117
|
-
def at_least(number)
|
118
|
-
set_expected_yields_count(:>=, number)
|
119
|
-
self
|
120
|
-
end
|
121
|
-
|
122
|
-
# @api public
|
123
|
-
# No-op. Provides syntactic sugar.
|
124
|
-
def times
|
125
|
-
self
|
126
|
-
end
|
127
|
-
|
102
|
+
include CountExpectation
|
128
103
|
# @private
|
129
104
|
def matches?(block)
|
130
105
|
@probe = YieldProbe.probe(block)
|
131
106
|
return false unless @probe.has_block?
|
132
|
-
|
133
|
-
if @expectation_type
|
134
|
-
@probe.num_yields.__send__(@expectation_type, @expected_yields_count)
|
135
|
-
else
|
136
|
-
@probe.yielded_once?(:yield_control)
|
137
|
-
end
|
107
|
+
expected_count_matches?(@probe.num_yields)
|
138
108
|
end
|
139
109
|
|
140
110
|
# @private
|
@@ -159,37 +129,17 @@ module RSpec
|
|
159
129
|
true
|
160
130
|
end
|
161
131
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
@expectation_type = relativity
|
166
|
-
@expected_yields_count = case n
|
167
|
-
when Numeric then n
|
168
|
-
when :once then 1
|
169
|
-
when :twice then 2
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
def failure_reason
|
174
|
-
return " but was not a block" unless @probe.has_block?
|
175
|
-
return '' unless @expected_yields_count
|
176
|
-
" #{human_readable_expecation_type}#{human_readable_count}"
|
132
|
+
# @private
|
133
|
+
def supports_value_expectations?
|
134
|
+
false
|
177
135
|
end
|
178
136
|
|
179
|
-
|
180
|
-
case @expectation_type
|
181
|
-
when :<= then 'at most '
|
182
|
-
when :>= then 'at least '
|
183
|
-
else ''
|
184
|
-
end
|
185
|
-
end
|
137
|
+
private
|
186
138
|
|
187
|
-
def
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
else "#{@expected_yields_count} times"
|
192
|
-
end
|
139
|
+
def failure_reason
|
140
|
+
return ' but was not a block' unless @probe.has_block?
|
141
|
+
return "#{count_expectation_description} but did not yield" if @probe.num_yields == 0
|
142
|
+
count_failure_reason('yielded')
|
193
143
|
end
|
194
144
|
end
|
195
145
|
|
@@ -224,36 +174,44 @@ module RSpec
|
|
224
174
|
true
|
225
175
|
end
|
226
176
|
|
177
|
+
# @private
|
178
|
+
def supports_value_expectations?
|
179
|
+
false
|
180
|
+
end
|
181
|
+
|
227
182
|
private
|
228
183
|
|
229
184
|
def positive_failure_reason
|
230
|
-
return
|
231
|
-
return
|
232
|
-
"yielded with arguments: #{@probe.single_yield_args
|
185
|
+
return 'was not a block' unless @probe.has_block?
|
186
|
+
return 'did not yield' if @probe.num_yields.zero?
|
187
|
+
"yielded with arguments: #{description_of @probe.single_yield_args}"
|
233
188
|
end
|
234
189
|
|
235
190
|
def negative_failure_reason
|
236
|
-
return
|
237
|
-
|
191
|
+
return 'was not a block' unless @probe.has_block?
|
192
|
+
'did'
|
238
193
|
end
|
239
194
|
end
|
240
195
|
|
241
196
|
# @api private
|
242
197
|
# Provides the implementation for `yield_with_args`.
|
243
198
|
# Not intended to be instantiated directly.
|
244
|
-
class YieldWithArgs
|
245
|
-
include Composable
|
246
|
-
|
199
|
+
class YieldWithArgs < BaseMatcher
|
247
200
|
def initialize(*args)
|
248
201
|
@expected = args
|
249
202
|
end
|
250
203
|
|
251
204
|
# @private
|
252
205
|
def matches?(block)
|
253
|
-
@
|
206
|
+
@args_matched_when_yielded = true
|
207
|
+
@probe = YieldProbe.new(block) do
|
208
|
+
@actual = @probe.single_yield_args
|
209
|
+
@actual_formatted = actual_formatted
|
210
|
+
@args_matched_when_yielded &&= args_currently_match?
|
211
|
+
end
|
254
212
|
return false unless @probe.has_block?
|
255
|
-
@
|
256
|
-
@probe.yielded_once?(:yield_with_args) &&
|
213
|
+
@probe.probe
|
214
|
+
@probe.yielded_once?(:yield_with_args) && @args_matched_when_yielded
|
257
215
|
end
|
258
216
|
|
259
217
|
# @private
|
@@ -273,8 +231,8 @@ module RSpec
|
|
273
231
|
|
274
232
|
# @private
|
275
233
|
def description
|
276
|
-
desc =
|
277
|
-
desc
|
234
|
+
desc = 'yield with args'
|
235
|
+
desc = "#{desc}(#{expected_arg_description})" unless @expected.empty?
|
278
236
|
desc
|
279
237
|
end
|
280
238
|
|
@@ -283,40 +241,45 @@ module RSpec
|
|
283
241
|
true
|
284
242
|
end
|
285
243
|
|
244
|
+
# @private
|
245
|
+
def supports_value_expectations?
|
246
|
+
false
|
247
|
+
end
|
248
|
+
|
286
249
|
private
|
287
250
|
|
288
251
|
def positive_failure_reason
|
289
|
-
return
|
290
|
-
return
|
252
|
+
return 'was not a block' unless @probe.has_block?
|
253
|
+
return 'did not yield' if @probe.num_yields.zero?
|
291
254
|
@positive_args_failure
|
292
255
|
end
|
293
256
|
|
294
257
|
def expected_arg_description
|
295
|
-
@expected.map { |e| description_of e }.join(
|
258
|
+
@expected.map { |e| description_of e }.join(', ')
|
296
259
|
end
|
297
260
|
|
298
261
|
def negative_failure_reason
|
299
262
|
if !@probe.has_block?
|
300
|
-
|
301
|
-
elsif
|
302
|
-
|
303
|
-
"\nexpected not: #{surface_descriptions_in(@expected).inspect}"
|
304
|
-
"\n got: #{@
|
263
|
+
'was not a block'
|
264
|
+
elsif @args_matched_when_yielded && !@expected.empty?
|
265
|
+
'yielded with expected arguments' \
|
266
|
+
"\nexpected not: #{surface_descriptions_in(@expected).inspect}" \
|
267
|
+
"\n got: #{@actual_formatted}"
|
305
268
|
else
|
306
|
-
|
269
|
+
'did'
|
307
270
|
end
|
308
271
|
end
|
309
272
|
|
310
|
-
def
|
273
|
+
def args_currently_match?
|
311
274
|
if @expected.empty? # expect {...}.to yield_with_args
|
312
|
-
@positive_args_failure =
|
275
|
+
@positive_args_failure = 'yielded with no arguments' if @actual.empty?
|
313
276
|
return !@actual.empty?
|
314
277
|
end
|
315
278
|
|
316
279
|
unless (match = all_args_match?)
|
317
|
-
@positive_args_failure =
|
318
|
-
"\nexpected: #{surface_descriptions_in(@expected).inspect}"
|
319
|
-
"\n got: #{@
|
280
|
+
@positive_args_failure = 'yielded with unexpected arguments' \
|
281
|
+
"\nexpected: #{surface_descriptions_in(@expected).inspect}" \
|
282
|
+
"\n got: #{@actual_formatted}"
|
320
283
|
end
|
321
284
|
|
322
285
|
match
|
@@ -330,19 +293,28 @@ module RSpec
|
|
330
293
|
# @api private
|
331
294
|
# Provides the implementation for `yield_successive_args`.
|
332
295
|
# Not intended to be instantiated directly.
|
333
|
-
class YieldSuccessiveArgs
|
334
|
-
include Composable
|
335
|
-
|
296
|
+
class YieldSuccessiveArgs < BaseMatcher
|
336
297
|
def initialize(*args)
|
337
298
|
@expected = args
|
338
299
|
end
|
339
300
|
|
340
301
|
# @private
|
341
302
|
def matches?(block)
|
342
|
-
@
|
303
|
+
@actual_formatted = []
|
304
|
+
@actual = []
|
305
|
+
args_matched_when_yielded = true
|
306
|
+
yield_count = 0
|
307
|
+
|
308
|
+
@probe = YieldProbe.probe(block) do |*arg_array|
|
309
|
+
arg_or_args = arg_array.size == 1 ? arg_array.first : arg_array
|
310
|
+
@actual_formatted << RSpec::Support::ObjectFormatter.format(arg_or_args)
|
311
|
+
@actual << arg_or_args
|
312
|
+
args_matched_when_yielded &&= values_match?(@expected[yield_count], arg_or_args)
|
313
|
+
yield_count += 1
|
314
|
+
end
|
315
|
+
|
343
316
|
return false unless @probe.has_block?
|
344
|
-
|
345
|
-
args_match?
|
317
|
+
args_matched_when_yielded && yield_count == @expected.length
|
346
318
|
end
|
347
319
|
|
348
320
|
def does_not_match?(block)
|
@@ -351,19 +323,19 @@ module RSpec
|
|
351
323
|
|
352
324
|
# @private
|
353
325
|
def failure_message
|
354
|
-
|
326
|
+
'expected given block to yield successively with arguments, ' \
|
327
|
+
"but #{positive_failure_reason}"
|
355
328
|
end
|
356
329
|
|
357
330
|
# @private
|
358
331
|
def failure_message_when_negated
|
359
|
-
|
332
|
+
'expected given block not to yield successively with arguments, ' \
|
333
|
+
"but #{negative_failure_reason}"
|
360
334
|
end
|
361
335
|
|
362
336
|
# @private
|
363
337
|
def description
|
364
|
-
|
365
|
-
desc << "(#{expected_arg_description})"
|
366
|
-
desc
|
338
|
+
"yield successive args(#{expected_arg_description})"
|
367
339
|
end
|
368
340
|
|
369
341
|
# @private
|
@@ -371,30 +343,31 @@ module RSpec
|
|
371
343
|
true
|
372
344
|
end
|
373
345
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
values_match?(@expected, @actual)
|
346
|
+
# @private
|
347
|
+
def supports_value_expectations?
|
348
|
+
false
|
378
349
|
end
|
379
350
|
|
351
|
+
private
|
352
|
+
|
380
353
|
def expected_arg_description
|
381
|
-
@expected.map { |e| description_of e }.join(
|
354
|
+
@expected.map { |e| description_of e }.join(', ')
|
382
355
|
end
|
383
356
|
|
384
357
|
def positive_failure_reason
|
385
|
-
return
|
358
|
+
return 'was not a block' unless @probe.has_block?
|
386
359
|
|
387
|
-
|
360
|
+
'yielded with unexpected arguments' \
|
388
361
|
"\nexpected: #{surface_descriptions_in(@expected).inspect}" \
|
389
|
-
"\n got: #{@
|
362
|
+
"\n got: [#{@actual_formatted.join(", ")}]"
|
390
363
|
end
|
391
364
|
|
392
365
|
def negative_failure_reason
|
393
|
-
return
|
366
|
+
return 'was not a block' unless @probe.has_block?
|
394
367
|
|
395
|
-
|
368
|
+
'yielded with expected arguments' \
|
396
369
|
"\nexpected not: #{surface_descriptions_in(@expected).inspect}" \
|
397
|
-
"\n got: #{@
|
370
|
+
"\n got: [#{@actual_formatted.join(", ")}]"
|
398
371
|
end
|
399
372
|
end
|
400
373
|
end
|
@@ -16,20 +16,22 @@ module RSpec
|
|
16
16
|
autoload :Be, 'rspec/matchers/built_in/be'
|
17
17
|
autoload :BeComparedTo, 'rspec/matchers/built_in/be'
|
18
18
|
autoload :BeFalsey, 'rspec/matchers/built_in/be'
|
19
|
+
autoload :BeHelpers, 'rspec/matchers/built_in/be'
|
19
20
|
autoload :BeNil, 'rspec/matchers/built_in/be'
|
20
|
-
autoload :BePredicate, 'rspec/matchers/built_in/
|
21
|
+
autoload :BePredicate, 'rspec/matchers/built_in/has'
|
21
22
|
autoload :BeTruthy, 'rspec/matchers/built_in/be'
|
22
23
|
autoload :BeWithin, 'rspec/matchers/built_in/be_within'
|
23
24
|
autoload :Change, 'rspec/matchers/built_in/change'
|
24
25
|
autoload :Compound, 'rspec/matchers/built_in/compound'
|
25
26
|
autoload :ContainExactly, 'rspec/matchers/built_in/contain_exactly'
|
26
27
|
autoload :Cover, 'rspec/matchers/built_in/cover'
|
27
|
-
autoload :EndWith, 'rspec/matchers/built_in/
|
28
|
+
autoload :EndWith, 'rspec/matchers/built_in/start_or_end_with'
|
28
29
|
autoload :Eq, 'rspec/matchers/built_in/eq'
|
29
30
|
autoload :Eql, 'rspec/matchers/built_in/eql'
|
30
31
|
autoload :Equal, 'rspec/matchers/built_in/equal'
|
31
32
|
autoload :Exist, 'rspec/matchers/built_in/exist'
|
32
33
|
autoload :Has, 'rspec/matchers/built_in/has'
|
34
|
+
autoload :HaveAttributes, 'rspec/matchers/built_in/have_attributes'
|
33
35
|
autoload :Include, 'rspec/matchers/built_in/include'
|
34
36
|
autoload :All, 'rspec/matchers/built_in/all'
|
35
37
|
autoload :Match, 'rspec/matchers/built_in/match'
|
@@ -40,7 +42,7 @@ module RSpec
|
|
40
42
|
autoload :RaiseError, 'rspec/matchers/built_in/raise_error'
|
41
43
|
autoload :RespondTo, 'rspec/matchers/built_in/respond_to'
|
42
44
|
autoload :Satisfy, 'rspec/matchers/built_in/satisfy'
|
43
|
-
autoload :StartWith, 'rspec/matchers/built_in/
|
45
|
+
autoload :StartWith, 'rspec/matchers/built_in/start_or_end_with'
|
44
46
|
autoload :ThrowSymbol, 'rspec/matchers/built_in/throw_symbol'
|
45
47
|
autoload :YieldControl, 'rspec/matchers/built_in/yield'
|
46
48
|
autoload :YieldSuccessiveArgs, 'rspec/matchers/built_in/yield'
|