rspec-support 3.13.4 → 3.13.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3dda956ef658b6fbdb2fc49fb6d6102cf3bc4325a95d52a40bb5bf470097dd26
4
- data.tar.gz: de254d0c76e3cf0994f4a0287dfc833d69de45201edb95d4907376589e22d916
3
+ metadata.gz: 627c7e28fcb4a040f33ce0f321252d4c659389a6f1230df267c9f923be43c3d9
4
+ data.tar.gz: 6147b06d1eb09093a6c94ebb4b2779a24f40bf6d137e3800827671f2eac077ff
5
5
  SHA512:
6
- metadata.gz: 48b8dfb6ee3ca756e5bb3cfd39839cd5bfcefa6a9394eeb64b6aa7258cfe97556f74bdf98c141e023b3c17926ab4a7db85daca8db07ad68541d974654264ec34
7
- data.tar.gz: e5ff093696533a98b04225f31e4eb3cc03cdd3d74d63110e531e5bda48d1f8a42ede69c8352f040f1ccf3e27ea077c497b9544610c5e0db7bae90fffdd2bbc22
6
+ metadata.gz: 9c7110b65063601e4f8fc2cc6f49a43dcd363b5c2bcc94671b515362be6b780e3ab0e7e3c27ed3bd63333574bac38ff697e5d43cf771763c1712a90a4c099c93
7
+ data.tar.gz: 30b20b1b6134613b68a467f5af2c8edf2570e7f8fe7a6feeb74e751d4f7f577dc7e02243f43fab83c8dfeb0cd7a7809767a4d18394daf1979d4dd11814acffd5
checksums.yaml.gz.sig CHANGED
Binary file
data/Changelog.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ### Development
2
- [Full Changelog](https://github.com/rspec/rspec/compare/rspec-support-v3.13.2...3-13-maintenance)
2
+ [Full Changelog](https://github.com/rspec/rspec/compare/rspec-support-v3.13.5...3-13-maintenance)
3
+
4
+ ### 3.13.5
5
+ [Full Changelog](http://github.com/rspec/rspec/compare/rspec-support-v3.13.4...rspec-support-v3.13.5)
6
+
7
+ Bug Fixes:
8
+
9
+ * Fix regression in `RSpec::Support::MethodSignature` where positional argument arity confused
10
+ a check for keyword arguments, meaning a hash would be wrongly detected as keyword arguments
11
+ when it should have been a positional argument. (Malcolm O'Hare, rspec/rspec#121)
3
12
 
4
13
  ### 3.13.4
5
14
  [Full Changelog](http://github.com/rspec/rspec/compare/rspec-support-v3.13.3...rspec-support-v3.13.4)
@@ -79,12 +79,37 @@ module RSpec
79
79
  given_kw_args - @allowed_kw_args
80
80
  end
81
81
 
82
- # If the last argument is Hash, Ruby will treat only symbol keys as keyword arguments
83
- # the rest will be grouped in another Hash and passed as positional argument.
84
- def has_kw_args_in?(args)
85
- Hash === args.last &&
86
- could_contain_kw_args?(args) &&
87
- (RubyFeatures.kw_arg_separation? || args.last.empty? || args.last.keys.any? { |x| x.is_a?(Symbol) })
82
+ # Considering the arg types, are there kw_args?
83
+ if RubyFeatures.kw_arg_separation?
84
+ def has_kw_args_in?(args)
85
+ # If the last arg is a hash, depending on the signature it could be kw_args or a positional parameter.
86
+ return false unless Hash === args.last && could_contain_kw_args?(args)
87
+
88
+ # If the position of the hash is beyond the count of required and optional positional
89
+ # args then it is the kwargs hash
90
+ return true if args.count > @max_non_kw_args
91
+
92
+ # This is the proper way to disambiguate between positional args and keywords hash
93
+ # but relies on beginning of the call chain annotating the method with
94
+ # ruby2_keywords, so only use it for positive feedback as without the annotation
95
+ # this is always false
96
+ return true if Hash.ruby2_keywords_hash?(args[-1])
97
+
98
+ # Otherwise, the hash could be defined kw_args or an optional positional parameter
99
+ # inspect the keys against known kwargs to determine what it is
100
+ # Note: the problem with this is that if a user passes only invalid keyword args,
101
+ # rspec no longer detects is and will assign this to a positional argument
102
+ return arbitrary_kw_args? || args.last.keys.all? { |x| @allowed_kw_args.include?(x) }
103
+ end
104
+ else
105
+ def has_kw_args_in?(args)
106
+ # Version <= Ruby 2.7
107
+ # If the last argument is Hash, Ruby will treat only symbol keys as keyword arguments
108
+ # the rest will be grouped in another Hash and passed as positional argument.
109
+ Hash === args.last &&
110
+ could_contain_kw_args?(args) &&
111
+ (args.last.empty? || args.last.keys.any? { |x| x.is_a?(Symbol) })
112
+ end
88
113
  end
89
114
 
90
115
  # Without considering what the last arg is, could it
@@ -282,7 +307,7 @@ module RSpec
282
307
 
283
308
  def initialize(signature, args=[])
284
309
  @signature = signature
285
- @non_kw_args, @kw_args = split_args(*args)
310
+ @non_kw_args, @kw_args = split_args(args.clone)
286
311
  @min_non_kw_args = @max_non_kw_args = @non_kw_args
287
312
  @arbitrary_kw_args = @unlimited_args = false
288
313
  end
@@ -362,7 +387,7 @@ module RSpec
362
387
  !@unlimited_args || @signature.unlimited_args?
363
388
  end
364
389
 
365
- def split_args(*args)
390
+ def split_args(args)
366
391
  kw_args = if @signature.has_kw_args_in?(args) && !RubyFeatures.kw_arg_separation?
367
392
  last = args.pop
368
393
  non_kw_args = last.reject { |k, _| k.is_a?(Symbol) }
@@ -395,13 +420,13 @@ module RSpec
395
420
  class LooseSignatureVerifier < MethodSignatureVerifier
396
421
  private
397
422
 
398
- def split_args(*args)
423
+ def split_args(args)
399
424
  if RSpec::Support.is_a_matcher?(args.last) && @signature.could_contain_kw_args?(args)
400
425
  args.pop
401
426
  @signature = SignatureWithKeywordArgumentsMatcher.new(@signature)
402
427
  end
403
428
 
404
- super(*args)
429
+ super(args)
405
430
  end
406
431
 
407
432
  # If a matcher is used in a signature in place of keyword arguments, all
@@ -3,7 +3,7 @@
3
3
  module RSpec
4
4
  module Support
5
5
  module Version
6
- STRING = '3.13.4'
6
+ STRING = '3.13.5'
7
7
  end
8
8
  end
9
9
  end
data.tar.gz.sig CHANGED
Binary file
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.13.4
4
+ version: 3.13.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
@@ -123,11 +123,11 @@ licenses:
123
123
  - MIT
124
124
  metadata:
125
125
  bug_tracker_uri: https://github.com/rspec/rspec/issues
126
- changelog_uri: https://github.com/rspec/rspec/blob/rspec-support-v3.13.4/rspec-support/Changelog.md
126
+ changelog_uri: https://github.com/rspec/rspec/blob/rspec-support-v3.13.5/rspec-support/Changelog.md
127
127
  documentation_uri: https://rspec.info/documentation/
128
128
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
129
129
  rubygems_mfa_required: 'true'
130
- source_code_uri: https://github.com/rspec/rspec/blob/rspec-support-v3.13.4/rspec-support
130
+ source_code_uri: https://github.com/rspec/rspec/blob/rspec-support-v3.13.5/rspec-support
131
131
  rdoc_options:
132
132
  - "--charset=UTF-8"
133
133
  require_paths:
@@ -145,5 +145,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  requirements: []
146
146
  rubygems_version: 3.6.7
147
147
  specification_version: 4
148
- summary: rspec-support-3.13.4
148
+ summary: rspec-support-3.13.5
149
149
  test_files: []
metadata.gz.sig CHANGED
Binary file