rubocop-rspec 2.12.1 → 2.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +114 -86
  3. data/config/default.yml +44 -6
  4. data/config/obsoletion.yml +14 -0
  5. data/lib/rubocop/cop/rspec/align_left_let_brace.rb +8 -9
  6. data/lib/rubocop/cop/rspec/align_right_let_brace.rb +8 -9
  7. data/lib/rubocop/cop/rspec/any_instance.rb +1 -0
  8. data/lib/rubocop/cop/rspec/around_block.rb +26 -3
  9. data/lib/rubocop/cop/rspec/be.rb +0 -1
  10. data/lib/rubocop/cop/rspec/be_eq.rb +0 -1
  11. data/lib/rubocop/cop/rspec/be_eql.rb +0 -1
  12. data/lib/rubocop/cop/rspec/before_after_all.rb +1 -0
  13. data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +9 -3
  14. data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +2 -1
  15. data/lib/rubocop/cop/rspec/capybara/specific_finders.rb +86 -0
  16. data/lib/rubocop/cop/rspec/capybara/specific_matcher.rb +91 -10
  17. data/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb +0 -1
  18. data/lib/rubocop/cop/rspec/change_by_zero.rb +60 -5
  19. data/lib/rubocop/cop/rspec/class_check.rb +101 -0
  20. data/lib/rubocop/cop/rspec/context_method.rb +2 -1
  21. data/lib/rubocop/cop/rspec/context_wording.rb +49 -18
  22. data/lib/rubocop/cop/rspec/describe_class.rb +1 -1
  23. data/lib/rubocop/cop/rspec/describe_method.rb +1 -0
  24. data/lib/rubocop/cop/rspec/described_class.rb +4 -14
  25. data/lib/rubocop/cop/rspec/dialect.rb +1 -0
  26. data/lib/rubocop/cop/rspec/empty_example_group.rb +19 -4
  27. data/lib/rubocop/cop/rspec/empty_hook.rb +2 -1
  28. data/lib/rubocop/cop/rspec/empty_line_after_example.rb +4 -9
  29. data/lib/rubocop/cop/rspec/empty_line_after_example_group.rb +1 -1
  30. data/lib/rubocop/cop/rspec/empty_line_after_final_let.rb +2 -1
  31. data/lib/rubocop/cop/rspec/empty_line_after_hook.rb +32 -2
  32. data/lib/rubocop/cop/rspec/empty_line_after_subject.rb +2 -1
  33. data/lib/rubocop/cop/rspec/example_length.rb +2 -1
  34. data/lib/rubocop/cop/rspec/example_without_description.rb +2 -1
  35. data/lib/rubocop/cop/rspec/example_wording.rb +2 -1
  36. data/lib/rubocop/cop/rspec/excessive_docstring_spacing.rb +1 -0
  37. data/lib/rubocop/cop/rspec/expect_actual.rb +3 -0
  38. data/lib/rubocop/cop/rspec/expect_change.rb +1 -1
  39. data/lib/rubocop/cop/rspec/expect_in_hook.rb +4 -1
  40. data/lib/rubocop/cop/rspec/expect_output.rb +1 -0
  41. data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +2 -1
  42. data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +26 -12
  43. data/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb +1 -0
  44. data/lib/rubocop/cop/rspec/file_path.rb +6 -3
  45. data/lib/rubocop/cop/rspec/focus.rb +18 -0
  46. data/lib/rubocop/cop/rspec/hook_argument.rb +7 -2
  47. data/lib/rubocop/cop/rspec/hooks_before_examples.rb +10 -9
  48. data/lib/rubocop/cop/rspec/identical_equality_assertion.rb +0 -1
  49. data/lib/rubocop/cop/rspec/implicit_block_expectation.rb +1 -0
  50. data/lib/rubocop/cop/rspec/implicit_expect.rb +0 -2
  51. data/lib/rubocop/cop/rspec/instance_spy.rb +1 -1
  52. data/lib/rubocop/cop/rspec/instance_variable.rb +0 -1
  53. data/lib/rubocop/cop/rspec/it_behaves_like.rb +1 -0
  54. data/lib/rubocop/cop/rspec/iterated_expectation.rb +16 -0
  55. data/lib/rubocop/cop/rspec/leading_subject.rb +15 -15
  56. data/lib/rubocop/cop/rspec/let_before_examples.rb +7 -8
  57. data/lib/rubocop/cop/rspec/let_setup.rb +4 -4
  58. data/lib/rubocop/cop/rspec/message_chain.rb +1 -1
  59. data/lib/rubocop/cop/rspec/missing_example_group_argument.rb +2 -1
  60. data/lib/rubocop/cop/rspec/mixin/css_selector.rb +99 -0
  61. data/lib/rubocop/cop/rspec/mixin/namespace.rb +23 -0
  62. data/lib/rubocop/cop/rspec/multiple_describes.rb +1 -0
  63. data/lib/rubocop/cop/rspec/multiple_expectations.rb +1 -5
  64. data/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb +1 -3
  65. data/lib/rubocop/cop/rspec/multiple_subjects.rb +17 -2
  66. data/lib/rubocop/cop/rspec/named_subject.rb +2 -1
  67. data/lib/rubocop/cop/rspec/nested_groups.rb +45 -25
  68. data/lib/rubocop/cop/rspec/no_expectation_example.rb +64 -0
  69. data/lib/rubocop/cop/rspec/not_to_not.rb +1 -2
  70. data/lib/rubocop/cop/rspec/overwriting_setup.rb +2 -1
  71. data/lib/rubocop/cop/rspec/pending.rb +1 -0
  72. data/lib/rubocop/cop/rspec/predicate_matcher.rb +2 -1
  73. data/lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb +1 -2
  74. data/lib/rubocop/cop/rspec/receive_counts.rb +14 -15
  75. data/lib/rubocop/cop/rspec/receive_never.rb +4 -5
  76. data/lib/rubocop/cop/rspec/repeated_description.rb +25 -26
  77. data/lib/rubocop/cop/rspec/repeated_example.rb +1 -1
  78. data/lib/rubocop/cop/rspec/repeated_example_group_body.rb +28 -29
  79. data/lib/rubocop/cop/rspec/repeated_example_group_description.rb +28 -29
  80. data/lib/rubocop/cop/rspec/repeated_include_example.rb +32 -33
  81. data/lib/rubocop/cop/rspec/return_from_stub.rb +1 -1
  82. data/lib/rubocop/cop/rspec/scattered_let.rb +1 -5
  83. data/lib/rubocop/cop/rspec/scattered_setup.rb +1 -1
  84. data/lib/rubocop/cop/rspec/shared_context.rb +1 -1
  85. data/lib/rubocop/cop/rspec/stubbed_mock.rb +0 -1
  86. data/lib/rubocop/cop/rspec/subject_declaration.rb +0 -1
  87. data/lib/rubocop/cop/rspec/subject_stub.rb +2 -2
  88. data/lib/rubocop/cop/rspec/unspecified_exception.rb +15 -15
  89. data/lib/rubocop/cop/rspec/variable_definition.rb +1 -0
  90. data/lib/rubocop/cop/rspec/variable_name.rb +6 -7
  91. data/lib/rubocop/cop/rspec/verified_doubles.rb +1 -0
  92. data/lib/rubocop/cop/rspec/void_expect.rb +2 -1
  93. data/lib/rubocop/cop/rspec/yield.rb +2 -1
  94. data/lib/rubocop/cop/rspec_cops.rb +3 -0
  95. data/lib/rubocop/rspec/config_formatter.rb +14 -3
  96. data/lib/rubocop/rspec/inject.rb +1 -3
  97. data/lib/rubocop/rspec/language/node_pattern.rb +4 -0
  98. data/lib/rubocop/rspec/language.rb +6 -1
  99. data/lib/rubocop/rspec/version.rb +1 -1
  100. data/lib/rubocop/rspec/wording.rb +2 -2
  101. data/lib/rubocop/rspec.rb +14 -0
  102. data/lib/rubocop-rspec.rb +3 -0
  103. metadata +11 -88
@@ -21,17 +21,18 @@ module RuboCop
21
21
  .gsub(EXTENSION_ROOT_DEPARTMENT, "\n\\1")
22
22
  .gsub(*AMENDMENTS, "\n\\0")
23
23
  .gsub(/^(\s+)- /, '\1 - ')
24
+ .gsub('"~"', '~')
24
25
  end
25
26
 
26
27
  private
27
28
 
28
29
  def unified_config
29
30
  cops.each_with_object(config.dup) do |cop, unified|
30
- next if SUBDEPARTMENTS.include?(cop)
31
- next if AMENDMENTS.include?(cop)
31
+ next if SUBDEPARTMENTS.include?(cop) || AMENDMENTS.include?(cop)
32
32
 
33
+ replace_nil(unified[cop])
33
34
  unified[cop].merge!(descriptions.fetch(cop))
34
- unified[cop]['Reference'] = COP_DOC_BASE_URL + cop.sub('RSpec/', '')
35
+ unified[cop]['Reference'] = reference(cop)
35
36
  end
36
37
  end
37
38
 
@@ -39,6 +40,16 @@ module RuboCop
39
40
  (descriptions.keys | config.keys).grep(EXTENSION_ROOT_DEPARTMENT)
40
41
  end
41
42
 
43
+ def replace_nil(config)
44
+ config.each do |key, value|
45
+ config[key] = '~' if value.nil?
46
+ end
47
+ end
48
+
49
+ def reference(cop)
50
+ COP_DOC_BASE_URL + cop.sub('RSpec/', '')
51
+ end
52
+
42
53
  attr_reader :config, :descriptions
43
54
  end
44
55
  end
@@ -6,9 +6,7 @@ module RuboCop
6
6
  # bit of our configuration.
7
7
  module Inject
8
8
  def self.defaults!
9
- project_root = Pathname.new(__dir__).parent.parent.parent.expand_path
10
- config_default = project_root.join('config', 'default.yml')
11
- path = config_default.to_s
9
+ path = CONFIG_DEFAULT.to_s
12
10
  hash = ConfigLoader.send(:load_yaml_configuration, path)
13
11
  config = RuboCop::Config.new(hash, path)
14
12
  puts "configuration from #{path}" if ConfigLoader.debug?
@@ -12,6 +12,10 @@ module RuboCop
12
12
  def block_pattern(string)
13
13
  "(block #{send_pattern(string)} ...)"
14
14
  end
15
+
16
+ def numblock_pattern(string)
17
+ "(numblock #{send_pattern(string)} ...)"
18
+ end
15
19
  end
16
20
  end
17
21
  end
@@ -41,7 +41,12 @@ module RuboCop
41
41
  def_node_matcher :example?, block_pattern('#Examples.all')
42
42
 
43
43
  # @!method hook?(node)
44
- def_node_matcher :hook?, block_pattern('#Hooks.all')
44
+ def_node_matcher :hook?, <<-PATTERN
45
+ {
46
+ #{block_pattern('#Hooks.all')}
47
+ #{numblock_pattern('#Hooks.all')}
48
+ }
49
+ PATTERN
45
50
 
46
51
  # @!method let?(node)
47
52
  def_node_matcher :let?, <<-PATTERN
@@ -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.12.1'
7
+ STRING = '2.13.1'
8
8
  end
9
9
  end
10
10
  end
@@ -31,8 +31,8 @@ module RuboCop
31
31
  attr_reader :text, :ignores, :replacements
32
32
 
33
33
  def replace_prefix(pattern, replacement)
34
- text.sub(pattern) do |shouldnt|
35
- uppercase?(shouldnt) ? replacement.upcase : replacement
34
+ text.sub(pattern) do |matched|
35
+ uppercase?(matched) ? replacement.upcase : replacement
36
36
  end
37
37
  end
38
38
 
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ # RuboCop RSpec project namespace
5
+ module RSpec
6
+ PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
7
+ CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
8
+
9
+ private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
10
+
11
+ ::RuboCop::ConfigObsoletion.files << PROJECT_ROOT.join('config',
12
+ 'obsoletion.yml')
13
+ end
14
+ end
data/lib/rubocop-rspec.rb CHANGED
@@ -5,6 +5,7 @@ require 'yaml'
5
5
 
6
6
  require 'rubocop'
7
7
 
8
+ require_relative 'rubocop/rspec'
8
9
  require_relative 'rubocop/rspec/version'
9
10
  require_relative 'rubocop/rspec/inject'
10
11
  require_relative 'rubocop/rspec/node'
@@ -20,6 +21,8 @@ require_relative 'rubocop/cop/rspec/mixin/final_end_location'
20
21
  require_relative 'rubocop/cop/rspec/mixin/comments_help'
21
22
  require_relative 'rubocop/cop/rspec/mixin/empty_line_separation'
22
23
  require_relative 'rubocop/cop/rspec/mixin/inside_example_group'
24
+ require_relative 'rubocop/cop/rspec/mixin/namespace'
25
+ require_relative 'rubocop/cop/rspec/mixin/css_selector'
23
26
 
24
27
  require_relative 'rubocop/rspec/concept'
25
28
  require_relative 'rubocop/rspec/example_group'
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.12.1
4
+ version: 2.13.1
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-07-03 00:00:00.000000000 Z
13
+ date: 2022-09-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -18,98 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '1.31'
21
+ version: '1.33'
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: '1.31'
29
- - !ruby/object:Gem::Dependency
30
- name: rack
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: '0'
36
- type: :development
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: '0'
43
- - !ruby/object:Gem::Dependency
44
- name: rake
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '0'
50
- type: :development
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: '0'
57
- - !ruby/object:Gem::Dependency
58
- name: rspec
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '3.4'
64
- type: :development
65
- prerelease: false
66
- version_requirements: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
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'
85
- - !ruby/object:Gem::Dependency
86
- name: rubocop-rake
87
- requirement: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - "~>"
90
- - !ruby/object:Gem::Version
91
- version: '0.6'
92
- type: :development
93
- prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - "~>"
97
- - !ruby/object:Gem::Version
98
- version: '0.6'
99
- - !ruby/object:Gem::Dependency
100
- name: yard
101
- requirement: !ruby/object:Gem::Requirement
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- version: '0'
106
- type: :development
107
- prerelease: false
108
- version_requirements: !ruby/object:Gem::Requirement
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: '0'
28
+ version: '1.33'
113
29
  description: |2
114
30
  Code style checking for RSpec files.
115
31
  A plugin for the RuboCop code style enforcing & linting tool.
@@ -128,6 +44,7 @@ files:
128
44
  - MIT-LICENSE.md
129
45
  - README.md
130
46
  - config/default.yml
47
+ - config/obsoletion.yml
131
48
  - lib/rubocop-rspec.rb
132
49
  - lib/rubocop/cop/rspec/align_left_let_brace.rb
133
50
  - lib/rubocop/cop/rspec/align_right_let_brace.rb
@@ -141,9 +58,11 @@ files:
141
58
  - lib/rubocop/cop/rspec/before_after_all.rb
142
59
  - lib/rubocop/cop/rspec/capybara/current_path_expectation.rb
143
60
  - lib/rubocop/cop/rspec/capybara/feature_methods.rb
61
+ - lib/rubocop/cop/rspec/capybara/specific_finders.rb
144
62
  - lib/rubocop/cop/rspec/capybara/specific_matcher.rb
145
63
  - lib/rubocop/cop/rspec/capybara/visibility_matcher.rb
146
64
  - lib/rubocop/cop/rspec/change_by_zero.rb
65
+ - lib/rubocop/cop/rspec/class_check.rb
147
66
  - lib/rubocop/cop/rspec/context_method.rb
148
67
  - lib/rubocop/cop/rspec/context_wording.rb
149
68
  - lib/rubocop/cop/rspec/describe_class.rb
@@ -192,9 +111,11 @@ files:
192
111
  - lib/rubocop/cop/rspec/message_spies.rb
193
112
  - lib/rubocop/cop/rspec/missing_example_group_argument.rb
194
113
  - lib/rubocop/cop/rspec/mixin/comments_help.rb
114
+ - lib/rubocop/cop/rspec/mixin/css_selector.rb
195
115
  - lib/rubocop/cop/rspec/mixin/empty_line_separation.rb
196
116
  - lib/rubocop/cop/rspec/mixin/final_end_location.rb
197
117
  - lib/rubocop/cop/rspec/mixin/inside_example_group.rb
118
+ - lib/rubocop/cop/rspec/mixin/namespace.rb
198
119
  - lib/rubocop/cop/rspec/mixin/top_level_group.rb
199
120
  - lib/rubocop/cop/rspec/mixin/variable.rb
200
121
  - lib/rubocop/cop/rspec/multiple_describes.rb
@@ -203,6 +124,7 @@ files:
203
124
  - lib/rubocop/cop/rspec/multiple_subjects.rb
204
125
  - lib/rubocop/cop/rspec/named_subject.rb
205
126
  - lib/rubocop/cop/rspec/nested_groups.rb
127
+ - lib/rubocop/cop/rspec/no_expectation_example.rb
206
128
  - lib/rubocop/cop/rspec/not_to_not.rb
207
129
  - lib/rubocop/cop/rspec/overwriting_setup.rb
208
130
  - lib/rubocop/cop/rspec/pending.rb
@@ -234,6 +156,7 @@ files:
234
156
  - lib/rubocop/cop/rspec/void_expect.rb
235
157
  - lib/rubocop/cop/rspec/yield.rb
236
158
  - lib/rubocop/cop/rspec_cops.rb
159
+ - lib/rubocop/rspec.rb
237
160
  - lib/rubocop/rspec/align_let_brace.rb
238
161
  - lib/rubocop/rspec/concept.rb
239
162
  - lib/rubocop/rspec/config_formatter.rb