rubocop-rspec 3.0.2 → 3.0.4

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: a04549578a5df31cc51ccb63edef6de85bb5a02365f4004a916307df9b192d94
4
- data.tar.gz: 4fc0209d17164239f1e86b32da80b665ef597cb95fd8d2b71dd822e05c0f1c9b
3
+ metadata.gz: 169d3c16af254654f25f5b2d91abbee972be45feaa9b9103c54c00ce6592e41f
4
+ data.tar.gz: 140cfd9fe9b060eaaf697aa3eb7e94667ea089635cf2910047c1c63c90c55d76
5
5
  SHA512:
6
- metadata.gz: d0436f1c4ae1685ce24163a3a46ac70a157afbb438ca556f8e63f1b7b6f8280fcf8dfa2fcb4c0e88e408d5b3857fa129e6ddbbae1e75ebdfc5c3dc89dabbc482
7
- data.tar.gz: aff4399bc8a47869e4e2e3e183933bf768ca09d84973c627b13650686c65844beb8db333ecda4341a66ac2c29c928cc30b374d946cc43c029acd3c62ec7fce03
6
+ metadata.gz: ecb48dd3947d2e830c205bf170ba47a9d81bafa685ecfafcbfbd23baa7dc9bee1cdb0002d9de44f8fd3fd3f9249187c4764676259f465f5bb2d0b9b5b3ea38f9
7
+ data.tar.gz: 4d63767133ef37bebba948f952b120cb4ef95b891ecbfca78cf0450f9df8e0f712a10a272eb7e6b477869d0c50323926b9791f7afdc8c64df18f8ba03e2f5359
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Master (Unreleased)
4
4
 
5
+ ## 3.0.4 (2024-08-05)
6
+
7
+ - Fix false-negative for `UnspecifiedException` when matcher is chained. ([@r7kamura])
8
+
9
+ ## 3.0.3 (2024-07-12)
10
+
11
+ - Add support for Unicode RIGHT SINGLE QUOTATION MARK in `RSpec/ExampleWording`. ([@jdufresne])
12
+ - Suppress deprecation warning for `RSpec/MultipleExpectations`, `RSpec/MultipleMemoizedHelpers`, and `RSpec/NestedGroups` cops. ([@koic])
13
+
5
14
  ## 3.0.2 (2024-07-02)
6
15
 
7
16
  - Fix wrong autocorrect for `RSpec/ScatteredSetup` when hook contains heredoc. ([@earlopain])
@@ -55,8 +55,8 @@ module RuboCop
55
55
  MSG_INSUFFICIENT_DESCRIPTION = 'Your example description is ' \
56
56
  'insufficient.'
57
57
 
58
- SHOULD_PREFIX = /\Ashould(?:n't)?\b/i.freeze
59
- WILL_PREFIX = /\A(?:will|won't)\b/i.freeze
58
+ SHOULD_PREFIX = /\Ashould(?:n't|n’t)?\b/i.freeze
59
+ WILL_PREFIX = /\A(?:will|won't|won’t)\b/i.freeze
60
60
  IT_PREFIX = /\Ait /i.freeze
61
61
 
62
62
  # @!method it_description(node)
@@ -67,13 +67,13 @@ module RuboCop
67
67
  # end
68
68
  #
69
69
  class MultipleExpectations < Base
70
- include ConfigurableMax
71
-
72
70
  MSG = 'Example has too many expectations [%<total>d/%<max>d].'
73
71
 
74
72
  ANYTHING = ->(_node) { true }
75
73
  TRUE_NODE = lambda(&:true_type?)
76
74
 
75
+ exclude_limit 'Max'
76
+
77
77
  # @!method aggregate_failures?(node)
78
78
  def_node_matcher :aggregate_failures?, <<~PATTERN
79
79
  (block {
@@ -82,11 +82,12 @@ module RuboCop
82
82
  # end
83
83
  #
84
84
  class MultipleMemoizedHelpers < Base
85
- include ConfigurableMax
86
85
  include Variable
87
86
 
88
87
  MSG = 'Example group has too many memoized helpers [%<count>d/%<max>d]'
89
88
 
89
+ exclude_limit 'Max'
90
+
90
91
  def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
91
92
  return unless spec_group?(node)
92
93
 
@@ -92,7 +92,6 @@ module RuboCop
92
92
  # end
93
93
  #
94
94
  class NestedGroups < Base
95
- include ConfigurableMax
96
95
  include TopLevelGroup
97
96
 
98
97
  MSG = 'Maximum example group nesting exceeded [%<total>d/%<max>d].'
@@ -103,6 +102,8 @@ module RuboCop
103
102
  "Configuration key `#{DEPRECATED_MAX_KEY}` for #{cop_name} is " \
104
103
  'deprecated in favor of `Max`. Please use that instead.'
105
104
 
105
+ exclude_limit 'Max'
106
+
106
107
  def on_top_level_group(node)
107
108
  find_nested_example_groups(node) do |example_group, nesting|
108
109
  self.max = nesting
@@ -32,34 +32,39 @@ module RuboCop
32
32
  #
33
33
  class UnspecifiedException < Base
34
34
  MSG = 'Specify the exception being captured'
35
- RESTRICT_ON_SEND = %i[to].freeze
36
35
 
37
- # @!method empty_raise_error_or_exception(node)
38
- def_node_matcher :empty_raise_error_or_exception, <<~PATTERN
39
- (send
40
- (block
41
- (send nil? :expect) ...)
42
- :to
43
- (send nil? {:raise_error :raise_exception})
44
- )
36
+ RESTRICT_ON_SEND = %i[
37
+ raise_exception
38
+ raise_error
39
+ ].freeze
40
+
41
+ # @!method expect_to?(node)
42
+ def_node_matcher :expect_to?, <<~PATTERN
43
+ (send (block (send nil? :expect) ...) :to ...)
45
44
  PATTERN
46
45
 
47
46
  def on_send(node)
48
47
  return unless empty_exception_matcher?(node)
49
48
 
50
- add_offense(node.children.last)
49
+ add_offense(node)
51
50
  end
52
51
 
53
52
  private
54
53
 
55
54
  def empty_exception_matcher?(node)
56
- empty_raise_error_or_exception(node) && !block_with_args?(node.parent)
57
- end
55
+ return false if node.arguments? || node.block_literal?
58
56
 
59
- def block_with_args?(node)
60
- return false unless node&.block_type?
57
+ expect_to = find_expect_to(node)
58
+ return false unless expect_to
59
+ return false if expect_to.block_node&.arguments?
60
+
61
+ true
62
+ end
61
63
 
62
- node.arguments?
64
+ def find_expect_to(node)
65
+ node.each_ancestor(:send).find do |ancestor|
66
+ expect_to?(ancestor)
67
+ end
63
68
  end
64
69
  end
65
70
  end
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module RSpec
5
5
  # Version information for the RSpec RuboCop plugin.
6
6
  module Version
7
- STRING = '3.0.2'
7
+ STRING = '3.0.4'
8
8
  end
9
9
  end
10
10
  end
@@ -4,10 +4,10 @@ module RuboCop
4
4
  module RSpec
5
5
  # RSpec example wording rewriter
6
6
  class Wording
7
- SHOULDNT_PREFIX = /\Ashould(?:n't| not)\b/i.freeze
7
+ SHOULDNT_PREFIX = /\Ashould(?:n't|n’t| not)\b/i.freeze
8
8
  SHOULDNT_BE_PREFIX = /#{SHOULDNT_PREFIX} be\b/i.freeze
9
9
  WILL_NOT_PREFIX = /\Awill not\b/i.freeze
10
- WONT_PREFIX = /\Awon't\b/i.freeze
10
+ WONT_PREFIX = /\Awo(?:n't|n’t)\b/i.freeze
11
11
  ES_SUFFIX_PATTERN = /(?:o|s|x|ch|sh|z)\z/i.freeze
12
12
  IES_SUFFIX_PATTERN = /[^aeou]y\z/i.freeze
13
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Backus
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-07-03 00:00:00.000000000 Z
13
+ date: 2024-08-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop