rubocop-rspec 1.40.0 → 1.43.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -0
  3. data/CODE_OF_CONDUCT.md +17 -0
  4. data/config/default.yml +12 -2
  5. data/lib/rubocop-rspec.rb +3 -1
  6. data/lib/rubocop/cop/rspec/align_left_let_brace.rb +12 -19
  7. data/lib/rubocop/cop/rspec/align_right_let_brace.rb +12 -19
  8. data/lib/rubocop/cop/rspec/any_instance.rb +1 -1
  9. data/lib/rubocop/cop/rspec/around_block.rb +1 -1
  10. data/lib/rubocop/cop/rspec/base.rb +74 -0
  11. data/lib/rubocop/cop/rspec/be.rb +2 -2
  12. data/lib/rubocop/cop/rspec/be_eql.rb +6 -6
  13. data/lib/rubocop/cop/rspec/before_after_all.rb +1 -1
  14. data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +19 -17
  15. data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +14 -12
  16. data/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb +1 -1
  17. data/lib/rubocop/cop/rspec/context_method.rb +7 -9
  18. data/lib/rubocop/cop/rspec/context_wording.rb +3 -3
  19. data/lib/rubocop/cop/rspec/cop.rb +2 -66
  20. data/lib/rubocop/cop/rspec/describe_class.rb +20 -27
  21. data/lib/rubocop/cop/rspec/describe_method.rb +14 -6
  22. data/lib/rubocop/cop/rspec/describe_symbol.rb +2 -2
  23. data/lib/rubocop/cop/rspec/described_class.rb +12 -9
  24. data/lib/rubocop/cop/rspec/described_class_module_wrapping.rb +1 -1
  25. data/lib/rubocop/cop/rspec/dialect.rb +5 -12
  26. data/lib/rubocop/cop/rspec/empty_example_group.rb +91 -7
  27. data/lib/rubocop/cop/rspec/empty_hook.rb +6 -10
  28. data/lib/rubocop/cop/rspec/empty_line_after_example.rb +5 -7
  29. data/lib/rubocop/cop/rspec/empty_line_after_example_group.rb +5 -9
  30. data/lib/rubocop/cop/rspec/empty_line_after_final_let.rb +8 -8
  31. data/lib/rubocop/cop/rspec/empty_line_after_hook.rb +5 -9
  32. data/lib/rubocop/cop/rspec/empty_line_after_subject.rb +6 -6
  33. data/lib/rubocop/cop/rspec/example_length.rb +1 -1
  34. data/lib/rubocop/cop/rspec/example_without_description.rb +1 -1
  35. data/lib/rubocop/cop/rspec/example_wording.rb +10 -11
  36. data/lib/rubocop/cop/rspec/expect_actual.rb +8 -11
  37. data/lib/rubocop/cop/rspec/expect_change.rb +10 -35
  38. data/lib/rubocop/cop/rspec/expect_in_hook.rb +3 -3
  39. data/lib/rubocop/cop/rspec/expect_output.rb +2 -2
  40. data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +24 -21
  41. data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +20 -22
  42. data/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb +7 -8
  43. data/lib/rubocop/cop/rspec/file_path.rb +25 -17
  44. data/lib/rubocop/cop/rspec/focus.rb +7 -11
  45. data/lib/rubocop/cop/rspec/hook_argument.rb +16 -23
  46. data/lib/rubocop/cop/rspec/hooks_before_examples.rb +13 -14
  47. data/lib/rubocop/cop/rspec/implicit_block_expectation.rb +1 -1
  48. data/lib/rubocop/cop/rspec/implicit_expect.rb +7 -15
  49. data/lib/rubocop/cop/rspec/implicit_subject.rb +16 -11
  50. data/lib/rubocop/cop/rspec/instance_spy.rb +18 -12
  51. data/lib/rubocop/cop/rspec/instance_variable.rb +4 -8
  52. data/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb +3 -6
  53. data/lib/rubocop/cop/rspec/it_behaves_like.rb +5 -6
  54. data/lib/rubocop/cop/rspec/iterated_expectation.rb +1 -1
  55. data/lib/rubocop/cop/rspec/leading_subject.rb +27 -20
  56. data/lib/rubocop/cop/rspec/leaky_constant_declaration.rb +2 -5
  57. data/lib/rubocop/cop/rspec/let_before_examples.rb +13 -11
  58. data/lib/rubocop/cop/rspec/let_setup.rb +21 -6
  59. data/lib/rubocop/cop/rspec/message_chain.rb +7 -6
  60. data/lib/rubocop/cop/rspec/message_expectation.rb +2 -2
  61. data/lib/rubocop/cop/rspec/message_spies.rb +2 -3
  62. data/lib/rubocop/cop/rspec/missing_example_group_argument.rb +1 -1
  63. data/lib/rubocop/cop/rspec/multiple_describes.rb +11 -8
  64. data/lib/rubocop/cop/rspec/multiple_expectations.rb +7 -11
  65. data/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb +148 -0
  66. data/lib/rubocop/cop/rspec/multiple_subjects.rb +18 -19
  67. data/lib/rubocop/cop/rspec/named_subject.rb +2 -2
  68. data/lib/rubocop/cop/rspec/nested_groups.rb +12 -13
  69. data/lib/rubocop/cop/rspec/not_to_not.rb +5 -6
  70. data/lib/rubocop/cop/rspec/overwriting_setup.rb +1 -1
  71. data/lib/rubocop/cop/rspec/pending.rb +1 -1
  72. data/lib/rubocop/cop/rspec/predicate_matcher.rb +32 -69
  73. data/lib/rubocop/cop/rspec/rails/http_status.rb +5 -9
  74. data/lib/rubocop/cop/rspec/receive_counts.rb +15 -17
  75. data/lib/rubocop/cop/rspec/receive_never.rb +12 -12
  76. data/lib/rubocop/cop/rspec/repeated_description.rb +1 -1
  77. data/lib/rubocop/cop/rspec/repeated_example.rb +2 -2
  78. data/lib/rubocop/cop/rspec/repeated_example_group_body.rb +1 -1
  79. data/lib/rubocop/cop/rspec/repeated_example_group_description.rb +1 -1
  80. data/lib/rubocop/cop/rspec/return_from_stub.rb +12 -22
  81. data/lib/rubocop/cop/rspec/scattered_let.rb +8 -11
  82. data/lib/rubocop/cop/rspec/scattered_setup.rb +1 -1
  83. data/lib/rubocop/cop/rspec/shared_context.rb +8 -21
  84. data/lib/rubocop/cop/rspec/shared_examples.rb +6 -9
  85. data/lib/rubocop/cop/rspec/single_argument_message_chain.rb +15 -18
  86. data/lib/rubocop/cop/rspec/subject_stub.rb +5 -11
  87. data/lib/rubocop/cop/rspec/unspecified_exception.rb +1 -1
  88. data/lib/rubocop/cop/rspec/variable_definition.rb +6 -6
  89. data/lib/rubocop/cop/rspec/variable_name.rb +28 -9
  90. data/lib/rubocop/cop/rspec/verified_doubles.rb +1 -1
  91. data/lib/rubocop/cop/rspec/void_expect.rb +1 -1
  92. data/lib/rubocop/cop/rspec/yield.rb +14 -11
  93. data/lib/rubocop/cop/rspec_cops.rb +1 -0
  94. data/lib/rubocop/rspec/corrector/move_node.rb +7 -5
  95. data/lib/rubocop/rspec/description_extractor.rb +1 -1
  96. data/lib/rubocop/rspec/{blank_line_separation.rb → empty_line_separation.rb} +13 -10
  97. data/lib/rubocop/rspec/example_group.rb +21 -49
  98. data/lib/rubocop/rspec/factory_bot.rb +7 -1
  99. data/lib/rubocop/rspec/language.rb +6 -4
  100. data/lib/rubocop/rspec/language/node_pattern.rb +10 -1
  101. data/lib/rubocop/rspec/top_level_describe.rb +2 -2
  102. data/lib/rubocop/rspec/top_level_group.rb +57 -0
  103. data/lib/rubocop/rspec/variable.rb +1 -1
  104. data/lib/rubocop/rspec/version.rb +1 -1
  105. metadata +29 -11
@@ -16,7 +16,7 @@ module RuboCop
16
16
  private
17
17
 
18
18
  def top_level_describe?(node)
19
- return false unless node.method_name == :describe
19
+ return false unless node.method?(:describe)
20
20
 
21
21
  top_level_nodes.include?(node)
22
22
  end
@@ -44,7 +44,7 @@ module RuboCop
44
44
 
45
45
  def describe_statement_children(node)
46
46
  node.each_child_node(:send).select do |element|
47
- element.method_name == :describe
47
+ element.method?(:describe)
48
48
  end
49
49
  end
50
50
  end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module RSpec
5
+ # Helper methods for top level example group cops
6
+ module TopLevelGroup
7
+ extend RuboCop::NodePattern::Macros
8
+ include RuboCop::RSpec::Language
9
+
10
+ def_node_matcher :example_or_shared_group?,
11
+ (ExampleGroups::ALL + SharedGroups::ALL).block_pattern
12
+
13
+ def on_new_investigation
14
+ super
15
+
16
+ return unless root_node
17
+
18
+ top_level_groups.each do |node|
19
+ on_top_level_example_group(node) if example_group?(node)
20
+ on_top_level_group(node)
21
+ end
22
+ end
23
+
24
+ def top_level_groups
25
+ @top_level_groups ||=
26
+ top_level_nodes(root_node).select { |n| example_or_shared_group?(n) }
27
+ end
28
+
29
+ private
30
+
31
+ # Dummy methods to be overridden in the consumer
32
+ def on_top_level_example_group(_node); end
33
+
34
+ def on_top_level_group(_node); end
35
+
36
+ def top_level_group?(node)
37
+ top_level_groups.include?(node)
38
+ end
39
+
40
+ def top_level_nodes(node)
41
+ if node.nil?
42
+ []
43
+ elsif node.begin_type?
44
+ node.children
45
+ elsif node.module_type? || node.class_type?
46
+ top_level_nodes(node.body)
47
+ else
48
+ [node]
49
+ end
50
+ end
51
+
52
+ def root_node
53
+ processed_source.ast
54
+ end
55
+ end
56
+ end
57
+ end
@@ -8,7 +8,7 @@ module RuboCop
8
8
  extend RuboCop::NodePattern::Macros
9
9
 
10
10
  def_node_matcher :variable_definition?, <<~PATTERN
11
- (send #{RSPEC} #{(Helpers::ALL + Subject::ALL).node_pattern_union}
11
+ (send nil? #{(Helpers::ALL + Subject::ALL).node_pattern_union}
12
12
  $({sym str dsym dstr} ...) ...)
13
13
  PATTERN
14
14
  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 = '1.40.0'
7
+ STRING = '1.43.2'
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.40.0
4
+ version: 1.43.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Backus
8
8
  - Ian MacLeod
9
9
  - Nils Gemeinhardt
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-06-11 00:00:00.000000000 Z
13
+ date: 2020-08-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ">="
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: 0.68.1
21
+ version: '0.87'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ">="
26
+ - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: 0.68.1
28
+ version: '0.87'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rack
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -68,6 +68,20 @@ dependencies:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '3.4'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rubocop-performance
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '1.7'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '1.7'
71
85
  - !ruby/object:Gem::Dependency
72
86
  name: simplecov
73
87
  requirement: !ruby/object:Gem::Requirement
@@ -110,6 +124,7 @@ extra_rdoc_files:
110
124
  - README.md
111
125
  files:
112
126
  - CHANGELOG.md
127
+ - CODE_OF_CONDUCT.md
113
128
  - MIT-LICENSE.md
114
129
  - README.md
115
130
  - config/default.yml
@@ -118,6 +133,7 @@ files:
118
133
  - lib/rubocop/cop/rspec/align_right_let_brace.rb
119
134
  - lib/rubocop/cop/rspec/any_instance.rb
120
135
  - lib/rubocop/cop/rspec/around_block.rb
136
+ - lib/rubocop/cop/rspec/base.rb
121
137
  - lib/rubocop/cop/rspec/be.rb
122
138
  - lib/rubocop/cop/rspec/be_eql.rb
123
139
  - lib/rubocop/cop/rspec/before_after_all.rb
@@ -172,6 +188,7 @@ files:
172
188
  - lib/rubocop/cop/rspec/missing_example_group_argument.rb
173
189
  - lib/rubocop/cop/rspec/multiple_describes.rb
174
190
  - lib/rubocop/cop/rspec/multiple_expectations.rb
191
+ - lib/rubocop/cop/rspec/multiple_memoized_helpers.rb
175
192
  - lib/rubocop/cop/rspec/multiple_subjects.rb
176
193
  - lib/rubocop/cop/rspec/named_subject.rb
177
194
  - lib/rubocop/cop/rspec/nested_groups.rb
@@ -202,11 +219,11 @@ files:
202
219
  - lib/rubocop/cop/rspec_cops.rb
203
220
  - lib/rubocop/rspec.rb
204
221
  - lib/rubocop/rspec/align_let_brace.rb
205
- - lib/rubocop/rspec/blank_line_separation.rb
206
222
  - lib/rubocop/rspec/concept.rb
207
223
  - lib/rubocop/rspec/config_formatter.rb
208
224
  - lib/rubocop/rspec/corrector/move_node.rb
209
225
  - lib/rubocop/rspec/description_extractor.rb
226
+ - lib/rubocop/rspec/empty_line_separation.rb
210
227
  - lib/rubocop/rspec/example.rb
211
228
  - lib/rubocop/rspec/example_group.rb
212
229
  - lib/rubocop/rspec/factory_bot.rb
@@ -217,6 +234,7 @@ files:
217
234
  - lib/rubocop/rspec/language/node_pattern.rb
218
235
  - lib/rubocop/rspec/node.rb
219
236
  - lib/rubocop/rspec/top_level_describe.rb
237
+ - lib/rubocop/rspec/top_level_group.rb
220
238
  - lib/rubocop/rspec/variable.rb
221
239
  - lib/rubocop/rspec/version.rb
222
240
  - lib/rubocop/rspec/wording.rb
@@ -226,7 +244,7 @@ licenses:
226
244
  metadata:
227
245
  changelog_uri: https://github.com/rubocop-hq/rubocop-rspec/blob/master/CHANGELOG.md
228
246
  documentation_uri: https://rubocop-rspec.readthedocs.io/
229
- post_install_message:
247
+ post_install_message:
230
248
  rdoc_options: []
231
249
  require_paths:
232
250
  - lib
@@ -241,8 +259,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
259
  - !ruby/object:Gem::Version
242
260
  version: '0'
243
261
  requirements: []
244
- rubygems_version: 3.1.2
245
- signing_key:
262
+ rubygems_version: 3.0.3
263
+ signing_key:
246
264
  specification_version: 4
247
265
  summary: Code style checking for RSpec files
248
266
  test_files: []