rspec-support 3.5.0.beta3 → 3.5.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +18 -2
- data/lib/rspec/support/method_signature_verifier.rb +111 -9
- data/lib/rspec/support/spec/library_wide_checks.rb +1 -3
- data/lib/rspec/support/spec/shell_out.rb +11 -0
- data/lib/rspec/support/version.rb +1 -1
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84d1bc98a925d004f624058ae1b2355360156ad3
|
4
|
+
data.tar.gz: c744684300e9dc6c0e63649f689a9a44cbefd151
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a988e90cc6f7e44425a2904d29bd8bf694277dce686fbc97c8fa0e9da2352a3a36b47d44b84316fd25a22d85d51575679f8c16d9a7a6ab6c2c289c8055372bd2
|
7
|
+
data.tar.gz: 4ef5d0461477029eb0045ffc0b933fe8c6469d066b4075d5e907bd6f19094fa57bba02d2ef645ec9c20d1a203aa45b00050bef22585c386d963d4ce3c317d044
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,14 +1,30 @@
|
|
1
|
-
### Development
|
2
|
-
[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.5.0.
|
1
|
+
### 3.5 Development
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.5.0.beta4...master)
|
3
|
+
|
4
|
+
### 3.5.0.beta4 / 2016-06-05
|
5
|
+
[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.5.0.beta3...v3.5.0.beta4)
|
6
|
+
|
7
|
+
Enhancements:
|
8
|
+
* Improve `MethodSignature` to better support keyword arguments. (#250, Rob Smith).
|
9
|
+
|
10
|
+
### 3.5.0.beta3 / 2016-04-02
|
11
|
+
[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.5.0.beta2...v3.5.0.beta3)
|
3
12
|
|
4
13
|
Bug Fixes:
|
5
14
|
|
15
|
+
* Fix `EncodedString` to properly handle the behavior of `String#split`
|
16
|
+
on JRuby when the string contains invalid bytes. (Jon Rowe, #268)
|
6
17
|
* Fix `ObjectFormatter` so that formatting objects that don't respond to
|
7
18
|
`#inspect` (such as `BasicObject`) does not cause `NoMethodError`.
|
8
19
|
(Yuji Nakayama, #269)
|
9
20
|
* Fix `ObjectFormatter` so that formatting recursive array or hash does not
|
10
21
|
cause `SystemStackError`. (Yuji Nakayama, #270, #272)
|
11
22
|
|
23
|
+
### 3.5.0.beta2 / 2016-03-10
|
24
|
+
[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.5.0.beta1...v3.5.0.beta2)
|
25
|
+
|
26
|
+
No user-facing changes.
|
27
|
+
|
12
28
|
### 3.5.0.beta1 / 2016-02-06
|
13
29
|
[Full Changelog](http://github.com/rspec/rspec-support/compare/v3.4.1...v3.5.0.beta1)
|
14
30
|
|
@@ -8,7 +8,7 @@ module RSpec
|
|
8
8
|
# keyword args of a given method.
|
9
9
|
#
|
10
10
|
# @private
|
11
|
-
class MethodSignature
|
11
|
+
class MethodSignature # rubocop:disable ClassLength
|
12
12
|
attr_reader :min_non_kw_args, :max_non_kw_args, :optional_kw_args, :required_kw_args
|
13
13
|
|
14
14
|
def initialize(method)
|
@@ -26,9 +26,11 @@ module RSpec
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def valid_non_kw_args?(positional_arg_count)
|
29
|
+
def valid_non_kw_args?(positional_arg_count, optional_max_arg_count=positional_arg_count)
|
30
|
+
return true if positional_arg_count.nil?
|
31
|
+
|
30
32
|
min_non_kw_args <= positional_arg_count &&
|
31
|
-
|
33
|
+
optional_max_arg_count <= max_non_kw_args
|
32
34
|
end
|
33
35
|
|
34
36
|
if RubyFeatures.optional_and_splat_args_supported?
|
@@ -74,6 +76,14 @@ module RSpec
|
|
74
76
|
@allows_any_kw_args || @allowed_kw_args.any?
|
75
77
|
end
|
76
78
|
|
79
|
+
def arbitrary_kw_args?
|
80
|
+
@allows_any_kw_args
|
81
|
+
end
|
82
|
+
|
83
|
+
def unlimited_args?
|
84
|
+
@max_non_kw_args == INFINITY
|
85
|
+
end
|
86
|
+
|
77
87
|
def classify_parameters
|
78
88
|
optional_non_kw_args = @min_non_kw_args = 0
|
79
89
|
@allows_any_kw_args = false
|
@@ -119,6 +129,14 @@ module RSpec
|
|
119
129
|
false
|
120
130
|
end
|
121
131
|
|
132
|
+
def arbitrary_kw_args?
|
133
|
+
false
|
134
|
+
end
|
135
|
+
|
136
|
+
def unlimited_args?
|
137
|
+
false
|
138
|
+
end
|
139
|
+
|
122
140
|
def classify_parameters
|
123
141
|
arity = @method.arity
|
124
142
|
if arity < 0
|
@@ -153,6 +171,50 @@ module RSpec
|
|
153
171
|
end
|
154
172
|
end
|
155
173
|
|
174
|
+
# Encapsulates expectations about the number of arguments and
|
175
|
+
# allowed/required keyword args of a given method.
|
176
|
+
#
|
177
|
+
# @api private
|
178
|
+
class MethodSignatureExpectation
|
179
|
+
def initialize
|
180
|
+
@min_count = nil
|
181
|
+
@max_count = nil
|
182
|
+
@keywords = []
|
183
|
+
|
184
|
+
@expect_unlimited_arguments = false
|
185
|
+
@expect_arbitrary_keywords = false
|
186
|
+
end
|
187
|
+
|
188
|
+
attr_reader :min_count, :max_count, :keywords
|
189
|
+
|
190
|
+
attr_accessor :expect_unlimited_arguments, :expect_arbitrary_keywords
|
191
|
+
|
192
|
+
def max_count=(number)
|
193
|
+
raise ArgumentError, 'must be a non-negative integer or nil' \
|
194
|
+
unless number.nil? || (number.is_a?(Integer) && number >= 0)
|
195
|
+
|
196
|
+
@max_count = number
|
197
|
+
end
|
198
|
+
|
199
|
+
def min_count=(number)
|
200
|
+
raise ArgumentError, 'must be a non-negative integer or nil' \
|
201
|
+
unless number.nil? || (number.is_a?(Integer) && number >= 0)
|
202
|
+
|
203
|
+
@min_count = number
|
204
|
+
end
|
205
|
+
|
206
|
+
def empty?
|
207
|
+
@min_count.nil? &&
|
208
|
+
@keywords.to_a.empty? &&
|
209
|
+
!@expect_arbitrary_keywords &&
|
210
|
+
!@expect_unlimited_arguments
|
211
|
+
end
|
212
|
+
|
213
|
+
def keywords=(values)
|
214
|
+
@keywords = values.to_a || []
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
156
218
|
# Deals with the slightly different semantics of block arguments.
|
157
219
|
# For methods, arguments are required unless a default value is provided.
|
158
220
|
# For blocks, arguments are optional, even if no default value is provided.
|
@@ -175,17 +237,49 @@ module RSpec
|
|
175
237
|
#
|
176
238
|
# @api private
|
177
239
|
class MethodSignatureVerifier
|
178
|
-
attr_reader :non_kw_args, :kw_args
|
240
|
+
attr_reader :non_kw_args, :kw_args, :min_non_kw_args, :max_non_kw_args
|
179
241
|
|
180
|
-
def initialize(signature, args)
|
242
|
+
def initialize(signature, args=[])
|
181
243
|
@signature = signature
|
182
244
|
@non_kw_args, @kw_args = split_args(*args)
|
245
|
+
@min_non_kw_args = @max_non_kw_args = @non_kw_args
|
246
|
+
@arbitrary_kw_args = @unlimited_args = false
|
247
|
+
end
|
248
|
+
|
249
|
+
def with_expectation(expectation) # rubocop:disable MethodLength
|
250
|
+
return self unless MethodSignatureExpectation === expectation
|
251
|
+
|
252
|
+
if expectation.empty?
|
253
|
+
@min_non_kw_args = @max_non_kw_args = @non_kw_args = nil
|
254
|
+
@kw_args = []
|
255
|
+
else
|
256
|
+
@min_non_kw_args = @non_kw_args = expectation.min_count || 0
|
257
|
+
@max_non_kw_args = expectation.max_count || @min_non_kw_args
|
258
|
+
|
259
|
+
if RubyFeatures.optional_and_splat_args_supported?
|
260
|
+
@unlimited_args = expectation.expect_unlimited_arguments
|
261
|
+
else
|
262
|
+
@unlimited_args = false
|
263
|
+
end
|
264
|
+
|
265
|
+
if RubyFeatures.kw_args_supported?
|
266
|
+
@kw_args = expectation.keywords
|
267
|
+
@arbitrary_kw_args = expectation.expect_arbitrary_keywords
|
268
|
+
else
|
269
|
+
@kw_args = []
|
270
|
+
@arbitrary_kw_args = false
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
self
|
183
275
|
end
|
184
276
|
|
185
277
|
def valid?
|
186
278
|
missing_kw_args.empty? &&
|
187
279
|
invalid_kw_args.empty? &&
|
188
|
-
valid_non_kw_args?
|
280
|
+
valid_non_kw_args? &&
|
281
|
+
arbitrary_kw_args? &&
|
282
|
+
unlimited_args?
|
189
283
|
end
|
190
284
|
|
191
285
|
def error_message
|
@@ -200,7 +294,7 @@ module RSpec
|
|
200
294
|
elsif !valid_non_kw_args?
|
201
295
|
"Wrong number of arguments. Expected %s, got %s." % [
|
202
296
|
@signature.non_kw_args_arity_description,
|
203
|
-
non_kw_args
|
297
|
+
non_kw_args
|
204
298
|
]
|
205
299
|
end
|
206
300
|
end
|
@@ -208,7 +302,7 @@ module RSpec
|
|
208
302
|
private
|
209
303
|
|
210
304
|
def valid_non_kw_args?
|
211
|
-
@signature.valid_non_kw_args?(
|
305
|
+
@signature.valid_non_kw_args?(min_non_kw_args, max_non_kw_args)
|
212
306
|
end
|
213
307
|
|
214
308
|
def missing_kw_args
|
@@ -219,6 +313,14 @@ module RSpec
|
|
219
313
|
@signature.invalid_kw_args_from(kw_args)
|
220
314
|
end
|
221
315
|
|
316
|
+
def arbitrary_kw_args?
|
317
|
+
!@arbitrary_kw_args || @signature.arbitrary_kw_args?
|
318
|
+
end
|
319
|
+
|
320
|
+
def unlimited_args?
|
321
|
+
!@unlimited_args || @signature.unlimited_args?
|
322
|
+
end
|
323
|
+
|
222
324
|
def split_args(*args)
|
223
325
|
kw_args = if @signature.has_kw_args_in?(args)
|
224
326
|
args.pop.keys
|
@@ -226,7 +328,7 @@ module RSpec
|
|
226
328
|
[]
|
227
329
|
end
|
228
330
|
|
229
|
-
[args, kw_args]
|
331
|
+
[args.length, kw_args]
|
230
332
|
end
|
231
333
|
end
|
232
334
|
|
@@ -68,9 +68,7 @@ RSpec.shared_examples_for "library wide checks" do |lib, options|
|
|
68
68
|
run_ruby_with_current_load_path(command, *options)
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
|
-
stderr = stderr.split("\n").reject { |l| l =~ %r{bundler/source/rubygems} }.join("\n")
|
73
|
-
[stdout, stderr, status.exitstatus]
|
71
|
+
[stdout, strip_known_warnings(stderr), status.exitstatus]
|
74
72
|
end
|
75
73
|
|
76
74
|
define_method :load_all_lib_files do
|
@@ -53,6 +53,17 @@ module RSpec
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
def strip_known_warnings(input)
|
57
|
+
input.split("\n").reject do |l|
|
58
|
+
# Ignore bundler warning.
|
59
|
+
l =~ %r{bundler/source/rubygems} ||
|
60
|
+
# Ignore bundler + rubygems warning.
|
61
|
+
l =~ %r{site_ruby/\d\.\d\.\d/rubygems} ||
|
62
|
+
# This is required for windows for some reason
|
63
|
+
l =~ %r{lib/bundler/rubygems}
|
64
|
+
end.join("\n")
|
65
|
+
end
|
66
|
+
|
56
67
|
private
|
57
68
|
|
58
69
|
if Ruby.jruby?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.0.
|
4
|
+
version: 3.5.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Chelimsky
|
@@ -48,7 +48,7 @@ cert_chain:
|
|
48
48
|
ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
|
49
49
|
F3MdtaDehhjC
|
50
50
|
-----END CERTIFICATE-----
|
51
|
-
date: 2016-
|
51
|
+
date: 2016-06-05 00:00:00.000000000 Z
|
52
52
|
dependencies:
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: bundler
|
@@ -149,8 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: 1.3.1
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.2.2
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
|
-
summary: rspec-support-3.5.0.
|
155
|
+
summary: rspec-support-3.5.0.beta4
|
156
156
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|