rubocop-rspec 2.14.1 → 2.14.2

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: 740118ee4ac02188e4bc7a4f62e03b31a6dda33ab3017377d954718cb7b356b1
4
- data.tar.gz: 7f17bb68eb575fb53dd8f0d2662afff8057bde7faeb19b6d94b0c3f1cb62f73d
3
+ metadata.gz: bbd70ea9708a7d87e0a1307234e3ac5cc37cc6197e6b1cc72487342b772ec6f1
4
+ data.tar.gz: 0c50303e8a0d4218508c51e778d5cb6633b54fe6f823951ea5f8df68d162dfda
5
5
  SHA512:
6
- metadata.gz: 18fa9f2be3305f4e6388756e5223ccabdd85e951534f64e881c31a96d77a37f435c06197cd39a7808fb1690f56825ba442386668cfabe4335e784879f57d6ef2
7
- data.tar.gz: 1dd7abd8c281bb4c7ad6dd41bdb56c2de9be9e322935ae14d820863e7a64e2b39ad5f31e9603a88b77d52fb0ead146bae0c96297b2487831c2e263fe029244ec
6
+ metadata.gz: 2e1a6e55fb7aeef036448fe57f03b2d80b796e6971fbd22cd63db496e61b1e211a64e89e987cccc74f5124746713581fb621c805d458f7ff273d436432599483
7
+ data.tar.gz: 76655025092f103fbd6ca3eda6d466236a8a9857f207e11bc3f8e51c38238367346971c4a0f3feeca6b9069a53fa48bf8281d5dff61f68c6562edce4405a10f0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Master (Unreleased)
4
4
 
5
+ ## 2.14.2 (2022-10-25)
6
+
7
+ - Fix an incorrect autocorrect for `FactoryBot/ConsistentParenthesesStyle` with `omit_parentheses` option when method name and first argument are not on same line. ([@ydah])
8
+ - Fix autocorrection loop in `RSpec/ExampleWording` for insufficient example wording. ([@pirj])
9
+ - Fix `RSpec/SortMetadata` not to reorder arguments of `include_`/`it_behaves_like`. ([@pirj])
10
+ - Fix a false positive for `RSpec/NoExpectationExample` when allowed pattern methods with arguments. ([@ydah])
11
+ - Change `RSpec/FilePath` so that it only checks suffix when path is under spec/routing or type is defined as routing. ([@r7kamura])
12
+
5
13
  ## 2.14.1 (2022-10-24)
6
14
 
7
15
  - Fix an error for `RSpec/Rails/InferredSpecType` with redundant type before other Hash metadata. ([@ydah])
@@ -68,20 +68,15 @@ module RuboCop
68
68
  add_wording_offense(description_node, MSG_SHOULD)
69
69
  elsif message.match?(IT_PREFIX)
70
70
  add_wording_offense(description_node, MSG_IT)
71
- else
72
- check_and_handle_insufficient_examples(description_node)
71
+ elsif insufficient_docstring?(description_node)
72
+ add_offense(docstring(description_node),
73
+ message: MSG_INSUFFICIENT_DESCRIPTION)
73
74
  end
74
75
  end
75
76
  end
76
77
 
77
78
  private
78
79
 
79
- def check_and_handle_insufficient_examples(description)
80
- if insufficient_examples.include?(preprocess(text(description)))
81
- add_wording_offense(description, MSG_INSUFFICIENT_DESCRIPTION)
82
- end
83
- end
84
-
85
80
  def add_wording_offense(node, message)
86
81
  docstring = docstring(node)
87
82
 
@@ -137,6 +132,10 @@ module RuboCop
137
132
  cop_config.fetch('IgnoredWords', [])
138
133
  end
139
134
 
135
+ def insufficient_docstring?(description_node)
136
+ insufficient_examples.include?(preprocess(text(description_node)))
137
+ end
138
+
140
139
  def insufficient_examples
141
140
  examples = cop_config.fetch('DisallowedExamples', [])
142
141
  examples.map! { |example| preprocess(example) }
@@ -30,6 +30,16 @@ module RuboCop
30
30
  # create :login
31
31
  # create :login
32
32
  #
33
+ # # also good
34
+ # # when method name and first argument are not on same line
35
+ # create(
36
+ # :user
37
+ # )
38
+ # build(
39
+ # :user,
40
+ # name: 'foo'
41
+ # )
42
+ #
33
43
  class ConsistentParenthesesStyle < Base
34
44
  extend AutoCorrector
35
45
  include ConfigurableEnforcedStyle
@@ -66,6 +76,7 @@ module RuboCop
66
76
 
67
77
  def process_with_parentheses(node)
68
78
  return unless style == :omit_parentheses
79
+ return unless same_line?(node, node.first_argument)
69
80
 
70
81
  add_offense(node.loc.selector,
71
82
  message: MSG_OMIT_PARENS) do |corrector|
@@ -76,8 +76,6 @@ module RuboCop
76
76
  return unless top_level_groups.one?
77
77
 
78
78
  example_group(node) do |send_node, example_group, arguments|
79
- next if routing_spec?(arguments)
80
-
81
79
  ensure_correct_file_path(send_node, example_group, arguments)
82
80
  end
83
81
  end
@@ -85,7 +83,7 @@ module RuboCop
85
83
  private
86
84
 
87
85
  def ensure_correct_file_path(send_node, example_group, arguments)
88
- pattern = pattern_for(example_group, arguments.first)
86
+ pattern = pattern_for(example_group, arguments)
89
87
  return if filename_ends_with?(pattern)
90
88
 
91
89
  # For the suffix shown in the offense message, modify the regular
@@ -97,11 +95,13 @@ module RuboCop
97
95
  end
98
96
 
99
97
  def routing_spec?(args)
100
- args.any?(&method(:routing_metadata?))
98
+ args.any?(&method(:routing_metadata?)) || routing_spec_path?
101
99
  end
102
100
 
103
- def pattern_for(example_group, method_name)
104
- if spec_suffix_only? || !example_group.const_type?
101
+ def pattern_for(example_group, arguments)
102
+ method_name = arguments.first
103
+ if spec_suffix_only? || !example_group.const_type? ||
104
+ routing_spec?(arguments)
105
105
  return pattern_for_spec_suffix_only
106
106
  end
107
107
 
@@ -149,8 +149,7 @@ module RuboCop
149
149
  end
150
150
 
151
151
  def filename_ends_with?(pattern)
152
- filename = File.expand_path(processed_source.buffer.name)
153
- filename.match?("#{pattern}$")
152
+ expanded_file_path.match?("#{pattern}$")
154
153
  end
155
154
 
156
155
  def relevant_rubocop_rspec_file?(_file)
@@ -160,6 +159,14 @@ module RuboCop
160
159
  def spec_suffix_only?
161
160
  cop_config['SpecSuffixOnly']
162
161
  end
162
+
163
+ def routing_spec_path?
164
+ expanded_file_path.include?('spec/routing/')
165
+ end
166
+
167
+ def expanded_file_path
168
+ File.expand_path(processed_source.buffer.name)
169
+ end
163
170
  end
164
171
  end
165
172
  end
@@ -77,7 +77,7 @@ module RuboCop
77
77
  def_node_search :includes_expectation?, <<~PATTERN
78
78
  {
79
79
  #{send_pattern('#Expectations.all')}
80
- (send nil? `#matches_allowed_pattern?)
80
+ (send nil? `#matches_allowed_pattern? ...)
81
81
  }
82
82
  PATTERN
83
83
 
@@ -26,8 +26,7 @@ module RuboCop
26
26
  def_node_matcher :rspec_metadata, <<~PATTERN
27
27
  (block
28
28
  (send
29
- #rspec? {#Examples.all #ExampleGroups.all #SharedGroups.all #Hooks.all #Includes.all}
30
- _ ${send str sym}* (hash $...)?)
29
+ #rspec? {#Examples.all #ExampleGroups.all #SharedGroups.all #Hooks.all} _ ${send str sym}* (hash $...)?)
31
30
  ...)
32
31
  PATTERN
33
32
 
@@ -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 = '2.14.1'
7
+ STRING = '2.14.2'
8
8
  end
9
9
  end
10
10
  end
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: 2.14.1
4
+ version: 2.14.2
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: 2022-10-24 00:00:00.000000000 Z
13
+ date: 2022-10-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop