rubocop-rspec 3.8.0 → 3.10.0

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +25 -0
  3. data/config/default.yml +22 -0
  4. data/lib/rubocop/cop/rspec/around_block.rb +22 -0
  5. data/lib/rubocop/cop/rspec/contain_exactly.rb +8 -22
  6. data/lib/rubocop/cop/rspec/context_method.rb +1 -1
  7. data/lib/rubocop/cop/rspec/context_wording.rb +1 -1
  8. data/lib/rubocop/cop/rspec/described_class.rb +3 -1
  9. data/lib/rubocop/cop/rspec/discarded_matcher.rb +113 -0
  10. data/lib/rubocop/cop/rspec/empty_example_group.rb +3 -2
  11. data/lib/rubocop/cop/rspec/empty_hook.rb +1 -1
  12. data/lib/rubocop/cop/rspec/empty_line_after_example.rb +1 -1
  13. data/lib/rubocop/cop/rspec/empty_line_after_example_group.rb +1 -1
  14. data/lib/rubocop/cop/rspec/empty_line_after_final_let.rb +7 -2
  15. data/lib/rubocop/cop/rspec/empty_line_after_hook.rb +1 -0
  16. data/lib/rubocop/cop/rspec/empty_line_after_subject.rb +1 -1
  17. data/lib/rubocop/cop/rspec/example_length.rb +1 -1
  18. data/lib/rubocop/cop/rspec/example_without_description.rb +1 -1
  19. data/lib/rubocop/cop/rspec/example_wording.rb +1 -1
  20. data/lib/rubocop/cop/rspec/expect_actual.rb +33 -13
  21. data/lib/rubocop/cop/rspec/expect_change.rb +1 -1
  22. data/lib/rubocop/cop/rspec/expect_in_hook.rb +1 -0
  23. data/lib/rubocop/cop/rspec/expect_in_let.rb +1 -1
  24. data/lib/rubocop/cop/rspec/hook_argument.rb +1 -0
  25. data/lib/rubocop/cop/rspec/hooks_before_examples.rb +1 -0
  26. data/lib/rubocop/cop/rspec/indexed_let.rb +1 -1
  27. data/lib/rubocop/cop/rspec/instance_spy.rb +1 -1
  28. data/lib/rubocop/cop/rspec/iterated_expectation.rb +13 -0
  29. data/lib/rubocop/cop/rspec/leading_subject.rb +1 -1
  30. data/lib/rubocop/cop/rspec/leaky_local_variable.rb +18 -0
  31. data/lib/rubocop/cop/rspec/let_before_examples.rb +1 -1
  32. data/lib/rubocop/cop/rspec/let_setup.rb +1 -1
  33. data/lib/rubocop/cop/rspec/match_with_simple_regex.rb +89 -0
  34. data/lib/rubocop/cop/rspec/missing_example_group_argument.rb +1 -1
  35. data/lib/rubocop/cop/rspec/mixin/inside_example.rb +16 -0
  36. data/lib/rubocop/cop/rspec/mixin/metadata.rb +1 -0
  37. data/lib/rubocop/cop/rspec/multiple_expectations.rb +1 -1
  38. data/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb +1 -1
  39. data/lib/rubocop/cop/rspec/multiple_subjects.rb +1 -1
  40. data/lib/rubocop/cop/rspec/named_subject.rb +1 -1
  41. data/lib/rubocop/cop/rspec/no_expectation_example.rb +1 -0
  42. data/lib/rubocop/cop/rspec/output.rb +78 -0
  43. data/lib/rubocop/cop/rspec/overwriting_setup.rb +1 -1
  44. data/lib/rubocop/cop/rspec/predicate_matcher.rb +1 -1
  45. data/lib/rubocop/cop/rspec/redundant_around.rb +1 -0
  46. data/lib/rubocop/cop/rspec/repeated_description.rb +1 -1
  47. data/lib/rubocop/cop/rspec/repeated_example.rb +1 -1
  48. data/lib/rubocop/cop/rspec/return_from_stub.rb +1 -1
  49. data/lib/rubocop/cop/rspec/scattered_let.rb +11 -5
  50. data/lib/rubocop/cop/rspec/scattered_setup.rb +12 -2
  51. data/lib/rubocop/cop/rspec/shared_context.rb +1 -1
  52. data/lib/rubocop/cop/rspec/skip_block_inside_example.rb +3 -6
  53. data/lib/rubocop/cop/rspec/spec_file_path_format.rb +17 -10
  54. data/lib/rubocop/cop/rspec/subject_declaration.rb +17 -1
  55. data/lib/rubocop/cop/rspec/undescriptive_literals_description.rb +1 -1
  56. data/lib/rubocop/cop/rspec/void_expect.rb +3 -5
  57. data/lib/rubocop/cop/rspec/yield.rb +1 -1
  58. data/lib/rubocop/cop/rspec_cops.rb +3 -0
  59. data/lib/rubocop/rspec/description_extractor.rb +1 -1
  60. data/lib/rubocop/rspec/hook.rb +13 -0
  61. data/lib/rubocop/rspec/version.rb +1 -1
  62. data/lib/rubocop-rspec.rb +1 -0
  63. metadata +28 -4
@@ -50,7 +50,7 @@ module RuboCop
50
50
  end
51
51
 
52
52
  def description
53
- yardoc.docstring.split("\n\n").first.to_s
53
+ yardoc.docstring.split("\n\n").first.to_s.tr("\n", ' ')
54
54
  end
55
55
 
56
56
  def rspec_cop_namespace?
@@ -25,6 +25,13 @@ module RuboCop
25
25
  scope.equal?(:each)
26
26
  end
27
27
 
28
+ def inside_class_method? # rubocop:disable Metrics/CyclomaticComplexity
29
+ parent = node.parent
30
+ return false unless parent
31
+
32
+ parent.defs_type? || (parent.def_type? && inside_class_self?(parent))
33
+ end
34
+
28
35
  def scope
29
36
  return :each if scope_argument&.hash_type?
30
37
 
@@ -76,6 +83,12 @@ module RuboCop
76
83
  def scope_argument
77
84
  node.send_node.first_argument
78
85
  end
86
+
87
+ def inside_class_self?(node)
88
+ node.parent&.sclass_type? ||
89
+ (node.parent&.begin_type? && node.parent.parent&.sclass_type?) ||
90
+ false
91
+ end
79
92
  end
80
93
  end
81
94
  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.8.0'
7
+ STRING = '3.10.0'
8
8
  end
9
9
  end
10
10
  end
data/lib/rubocop-rspec.rb CHANGED
@@ -14,6 +14,7 @@ require_relative 'rubocop/rspec/wording'
14
14
 
15
15
  require_relative 'rubocop/cop/rspec/mixin/file_help'
16
16
  require_relative 'rubocop/cop/rspec/mixin/final_end_location'
17
+ require_relative 'rubocop/cop/rspec/mixin/inside_example'
17
18
  require_relative 'rubocop/cop/rspec/mixin/inside_example_group'
18
19
  require_relative 'rubocop/cop/rspec/mixin/location_help'
19
20
  require_relative 'rubocop/cop/rspec/mixin/metadata'
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.8.0
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Backus
@@ -25,20 +25,40 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.1'
28
+ - !ruby/object:Gem::Dependency
29
+ name: regexp_parser
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '2.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '2.0'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: rubocop
30
44
  requirement: !ruby/object:Gem::Requirement
31
45
  requirements:
32
46
  - - "~>"
33
47
  - !ruby/object:Gem::Version
34
- version: '1.81'
48
+ version: '1.86'
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 1.86.2
35
52
  type: :runtime
36
53
  prerelease: false
37
54
  version_requirements: !ruby/object:Gem::Requirement
38
55
  requirements:
39
56
  - - "~>"
40
57
  - !ruby/object:Gem::Version
41
- version: '1.81'
58
+ version: '1.86'
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.86.2
42
62
  description: |
43
63
  Code style checking for RSpec files.
44
64
  A plugin for the RuboCop code style enforcing & linting tool.
@@ -81,6 +101,7 @@ files:
81
101
  - lib/rubocop/cop/rspec/described_class.rb
82
102
  - lib/rubocop/cop/rspec/described_class_module_wrapping.rb
83
103
  - lib/rubocop/cop/rspec/dialect.rb
104
+ - lib/rubocop/cop/rspec/discarded_matcher.rb
84
105
  - lib/rubocop/cop/rspec/duplicated_metadata.rb
85
106
  - lib/rubocop/cop/rspec/empty_example_group.rb
86
107
  - lib/rubocop/cop/rspec/empty_hook.rb
@@ -121,6 +142,7 @@ files:
121
142
  - lib/rubocop/cop/rspec/let_before_examples.rb
122
143
  - lib/rubocop/cop/rspec/let_setup.rb
123
144
  - lib/rubocop/cop/rspec/match_array.rb
145
+ - lib/rubocop/cop/rspec/match_with_simple_regex.rb
124
146
  - lib/rubocop/cop/rspec/message_chain.rb
125
147
  - lib/rubocop/cop/rspec/message_expectation.rb
126
148
  - lib/rubocop/cop/rspec/message_spies.rb
@@ -131,6 +153,7 @@ files:
131
153
  - lib/rubocop/cop/rspec/mixin/empty_line_separation.rb
132
154
  - lib/rubocop/cop/rspec/mixin/file_help.rb
133
155
  - lib/rubocop/cop/rspec/mixin/final_end_location.rb
156
+ - lib/rubocop/cop/rspec/mixin/inside_example.rb
134
157
  - lib/rubocop/cop/rspec/mixin/inside_example_group.rb
135
158
  - lib/rubocop/cop/rspec/mixin/location_help.rb
136
159
  - lib/rubocop/cop/rspec/mixin/metadata.rb
@@ -146,6 +169,7 @@ files:
146
169
  - lib/rubocop/cop/rspec/nested_groups.rb
147
170
  - lib/rubocop/cop/rspec/no_expectation_example.rb
148
171
  - lib/rubocop/cop/rspec/not_to_not.rb
172
+ - lib/rubocop/cop/rspec/output.rb
149
173
  - lib/rubocop/cop/rspec/overwriting_setup.rb
150
174
  - lib/rubocop/cop/rspec/pending.rb
151
175
  - lib/rubocop/cop/rspec/pending_without_reason.rb
@@ -222,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
246
  - !ruby/object:Gem::Version
223
247
  version: '0'
224
248
  requirements: []
225
- rubygems_version: 3.6.9
249
+ rubygems_version: 4.0.10
226
250
  specification_version: 4
227
251
  summary: Code style checking for RSpec files
228
252
  test_files: []