rubocop-rspec 1.37.0 → 1.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -0
  3. data/README.md +2 -62
  4. data/config/default.yml +155 -15
  5. data/lib/rubocop-rspec.rb +2 -1
  6. data/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb +69 -0
  7. data/lib/rubocop/cop/rspec/context_wording.rb +5 -1
  8. data/lib/rubocop/cop/rspec/cop.rb +9 -29
  9. data/lib/rubocop/cop/rspec/describe_class.rb +15 -2
  10. data/lib/rubocop/cop/rspec/describe_method.rb +0 -1
  11. data/lib/rubocop/cop/rspec/empty_hook.rb +50 -0
  12. data/lib/rubocop/cop/rspec/expect_actual.rb +27 -2
  13. data/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb +16 -1
  14. data/lib/rubocop/cop/rspec/file_path.rb +32 -4
  15. data/lib/rubocop/cop/rspec/hooks_before_examples.rb +3 -21
  16. data/lib/rubocop/cop/rspec/instance_variable.rb +13 -4
  17. data/lib/rubocop/cop/rspec/leading_subject.rb +3 -10
  18. data/lib/rubocop/cop/rspec/let_before_examples.rb +3 -21
  19. data/lib/rubocop/cop/rspec/message_chain.rb +1 -1
  20. data/lib/rubocop/cop/rspec/named_subject.rb +6 -6
  21. data/lib/rubocop/cop/rspec/rails/http_status.rb +2 -0
  22. data/lib/rubocop/cop/rspec/repeated_description.rb +17 -2
  23. data/lib/rubocop/cop/rspec/repeated_example_group_body.rb +97 -0
  24. data/lib/rubocop/cop/rspec/repeated_example_group_description.rb +96 -0
  25. data/lib/rubocop/cop/rspec/scattered_let.rb +13 -0
  26. data/lib/rubocop/cop/rspec/scattered_setup.rb +27 -9
  27. data/lib/rubocop/cop/rspec/shared_examples.rb +1 -0
  28. data/lib/rubocop/cop/rspec/subject_stub.rb +25 -47
  29. data/lib/rubocop/cop/rspec/variable_definition.rb +56 -0
  30. data/lib/rubocop/cop/rspec/variable_name.rb +47 -0
  31. data/lib/rubocop/cop/rspec_cops.rb +7 -1
  32. data/lib/rubocop/rspec/corrector/move_node.rb +52 -0
  33. data/lib/rubocop/rspec/description_extractor.rb +2 -6
  34. data/lib/rubocop/rspec/example.rb +1 -1
  35. data/lib/rubocop/rspec/hook.rb +44 -11
  36. data/lib/rubocop/rspec/language.rb +20 -0
  37. data/lib/rubocop/rspec/language/node_pattern.rb +1 -1
  38. data/lib/rubocop/rspec/variable.rb +16 -0
  39. data/lib/rubocop/rspec/version.rb +1 -1
  40. metadata +16 -9
  41. data/lib/rubocop/rspec/util.rb +0 -19
@@ -17,7 +17,7 @@ module RuboCop
17
17
 
18
18
  def_node_matcher :hook?, Hooks::ALL.block_pattern
19
19
 
20
- def_node_matcher :let?, Helpers::ALL.block_pattern
20
+ def_node_matcher :let?, Helpers::ALL.block_or_block_pass_pattern
21
21
 
22
22
  def_node_matcher :subject?, Subject::ALL.block_pattern
23
23
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module RSpec
5
+ # Helps check offenses with variable definitions
6
+ module Variable
7
+ include Language
8
+ extend RuboCop::NodePattern::Macros
9
+
10
+ def_node_matcher :variable_definition?, <<~PATTERN
11
+ (send #{RSPEC} #{(Helpers::ALL + Subject::ALL).node_pattern_union}
12
+ $({sym str dsym dstr} ...) ...)
13
+ PATTERN
14
+ end
15
+ end
16
+ 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.37.0'
7
+ STRING = '1.40.0'
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: 1.37.0
4
+ version: 1.40.0
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: 2019-11-25 00:00:00.000000000 Z
13
+ date: 2020-06-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -72,16 +72,16 @@ dependencies:
72
72
  name: simplecov
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ">="
75
+ - - "<"
76
76
  - !ruby/object:Gem::Version
77
- version: '0'
77
+ version: '0.18'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ">="
82
+ - - "<"
83
83
  - !ruby/object:Gem::Version
84
- version: '0'
84
+ version: '0.18'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: yard
87
87
  requirement: !ruby/object:Gem::Requirement
@@ -123,6 +123,7 @@ files:
123
123
  - lib/rubocop/cop/rspec/before_after_all.rb
124
124
  - lib/rubocop/cop/rspec/capybara/current_path_expectation.rb
125
125
  - lib/rubocop/cop/rspec/capybara/feature_methods.rb
126
+ - lib/rubocop/cop/rspec/capybara/visibility_matcher.rb
126
127
  - lib/rubocop/cop/rspec/context_method.rb
127
128
  - lib/rubocop/cop/rspec/context_wording.rb
128
129
  - lib/rubocop/cop/rspec/cop.rb
@@ -133,6 +134,7 @@ files:
133
134
  - lib/rubocop/cop/rspec/described_class_module_wrapping.rb
134
135
  - lib/rubocop/cop/rspec/dialect.rb
135
136
  - lib/rubocop/cop/rspec/empty_example_group.rb
137
+ - lib/rubocop/cop/rspec/empty_hook.rb
136
138
  - lib/rubocop/cop/rspec/empty_line_after_example.rb
137
139
  - lib/rubocop/cop/rspec/empty_line_after_example_group.rb
138
140
  - lib/rubocop/cop/rspec/empty_line_after_final_let.rb
@@ -182,6 +184,8 @@ files:
182
184
  - lib/rubocop/cop/rspec/receive_never.rb
183
185
  - lib/rubocop/cop/rspec/repeated_description.rb
184
186
  - lib/rubocop/cop/rspec/repeated_example.rb
187
+ - lib/rubocop/cop/rspec/repeated_example_group_body.rb
188
+ - lib/rubocop/cop/rspec/repeated_example_group_description.rb
185
189
  - lib/rubocop/cop/rspec/return_from_stub.rb
186
190
  - lib/rubocop/cop/rspec/scattered_let.rb
187
191
  - lib/rubocop/cop/rspec/scattered_setup.rb
@@ -190,6 +194,8 @@ files:
190
194
  - lib/rubocop/cop/rspec/single_argument_message_chain.rb
191
195
  - lib/rubocop/cop/rspec/subject_stub.rb
192
196
  - lib/rubocop/cop/rspec/unspecified_exception.rb
197
+ - lib/rubocop/cop/rspec/variable_definition.rb
198
+ - lib/rubocop/cop/rspec/variable_name.rb
193
199
  - lib/rubocop/cop/rspec/verified_doubles.rb
194
200
  - lib/rubocop/cop/rspec/void_expect.rb
195
201
  - lib/rubocop/cop/rspec/yield.rb
@@ -199,6 +205,7 @@ files:
199
205
  - lib/rubocop/rspec/blank_line_separation.rb
200
206
  - lib/rubocop/rspec/concept.rb
201
207
  - lib/rubocop/rspec/config_formatter.rb
208
+ - lib/rubocop/rspec/corrector/move_node.rb
202
209
  - lib/rubocop/rspec/description_extractor.rb
203
210
  - lib/rubocop/rspec/example.rb
204
211
  - lib/rubocop/rspec/example_group.rb
@@ -210,7 +217,7 @@ files:
210
217
  - lib/rubocop/rspec/language/node_pattern.rb
211
218
  - lib/rubocop/rspec/node.rb
212
219
  - lib/rubocop/rspec/top_level_describe.rb
213
- - lib/rubocop/rspec/util.rb
220
+ - lib/rubocop/rspec/variable.rb
214
221
  - lib/rubocop/rspec/version.rb
215
222
  - lib/rubocop/rspec/wording.rb
216
223
  homepage: https://github.com/rubocop-hq/rubocop-rspec
@@ -227,14 +234,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
234
  requirements:
228
235
  - - ">="
229
236
  - !ruby/object:Gem::Version
230
- version: 2.3.0
237
+ version: 2.4.0
231
238
  required_rubygems_version: !ruby/object:Gem::Requirement
232
239
  requirements:
233
240
  - - ">="
234
241
  - !ruby/object:Gem::Version
235
242
  version: '0'
236
243
  requirements: []
237
- rubygems_version: 3.0.3
244
+ rubygems_version: 3.1.2
238
245
  signing_key:
239
246
  specification_version: 4
240
247
  summary: Code style checking for RSpec files
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module RSpec
5
- # Utility methods
6
- module Util
7
- # Error raised by `Util.one` if size is less than zero or greater than one
8
- SizeError = Class.new(IndexError)
9
-
10
- # Return only element in array if it contains exactly one member
11
- def one(array)
12
- return array.first if array.one?
13
-
14
- raise SizeError,
15
- "expected size to be exactly 1 but size was #{array.size}"
16
- end
17
- end
18
- end
19
- end