rubocop-rspec 2.21.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +147 -9
  3. data/README.md +2 -2
  4. data/config/default.yml +159 -244
  5. data/config/obsoletion.yml +24 -0
  6. data/lib/rubocop/cop/rspec/around_block.rb +3 -3
  7. data/lib/rubocop/cop/rspec/base.rb +0 -1
  8. data/lib/rubocop/cop/rspec/be.rb +1 -1
  9. data/lib/rubocop/cop/rspec/be_empty.rb +1 -0
  10. data/lib/rubocop/cop/rspec/be_eq.rb +1 -1
  11. data/lib/rubocop/cop/rspec/be_eql.rb +1 -1
  12. data/lib/rubocop/cop/rspec/be_nil.rb +2 -2
  13. data/lib/rubocop/cop/rspec/before_after_all.rb +7 -13
  14. data/lib/rubocop/cop/rspec/change_by_zero.rb +30 -4
  15. data/lib/rubocop/cop/rspec/context_method.rb +2 -2
  16. data/lib/rubocop/cop/rspec/context_wording.rb +1 -1
  17. data/lib/rubocop/cop/rspec/describe_symbol.rb +1 -1
  18. data/lib/rubocop/cop/rspec/described_class.rb +33 -11
  19. data/lib/rubocop/cop/rspec/dialect.rb +13 -0
  20. data/lib/rubocop/cop/rspec/duplicated_metadata.rb +1 -1
  21. data/lib/rubocop/cop/rspec/empty_example_group.rb +4 -1
  22. data/lib/rubocop/cop/rspec/empty_hook.rb +1 -1
  23. data/lib/rubocop/cop/rspec/empty_line_after_example.rb +2 -2
  24. data/lib/rubocop/cop/rspec/empty_metadata.rb +46 -0
  25. data/lib/rubocop/cop/rspec/empty_output.rb +47 -0
  26. data/lib/rubocop/cop/rspec/eq.rb +47 -0
  27. data/lib/rubocop/cop/rspec/example_length.rb +11 -5
  28. data/lib/rubocop/cop/rspec/example_without_description.rb +11 -2
  29. data/lib/rubocop/cop/rspec/example_wording.rb +11 -2
  30. data/lib/rubocop/cop/rspec/excessive_docstring_spacing.rb +14 -5
  31. data/lib/rubocop/cop/rspec/expect_actual.rb +17 -14
  32. data/lib/rubocop/cop/rspec/expect_change.rb +2 -2
  33. data/lib/rubocop/cop/rspec/expect_in_hook.rb +1 -1
  34. data/lib/rubocop/cop/rspec/expect_in_let.rb +42 -0
  35. data/lib/rubocop/cop/rspec/expect_output.rb +1 -4
  36. data/lib/rubocop/cop/rspec/focus.rb +17 -2
  37. data/lib/rubocop/cop/rspec/hook_argument.rb +2 -2
  38. data/lib/rubocop/cop/rspec/hooks_before_examples.rb +1 -1
  39. data/lib/rubocop/cop/rspec/implicit_block_expectation.rb +2 -2
  40. data/lib/rubocop/cop/rspec/implicit_expect.rb +1 -1
  41. data/lib/rubocop/cop/rspec/implicit_subject.rb +2 -2
  42. data/lib/rubocop/cop/rspec/indexed_let.rb +32 -1
  43. data/lib/rubocop/cop/rspec/instance_spy.rb +2 -2
  44. data/lib/rubocop/cop/rspec/instance_variable.rb +4 -4
  45. data/lib/rubocop/cop/rspec/is_expected_specify.rb +45 -0
  46. data/lib/rubocop/cop/rspec/iterated_expectation.rb +3 -3
  47. data/lib/rubocop/cop/rspec/leaky_constant_declaration.rb +2 -2
  48. data/lib/rubocop/cop/rspec/let_before_examples.rb +5 -1
  49. data/lib/rubocop/cop/rspec/let_setup.rb +1 -1
  50. data/lib/rubocop/cop/rspec/message_expectation.rb +1 -2
  51. data/lib/rubocop/cop/rspec/message_spies.rb +0 -2
  52. data/lib/rubocop/cop/rspec/metadata_style.rb +202 -0
  53. data/lib/rubocop/cop/rspec/missing_expectation_target_method.rb +54 -0
  54. data/lib/rubocop/cop/rspec/mixin/file_help.rb +14 -0
  55. data/lib/rubocop/cop/rspec/mixin/metadata.rb +21 -7
  56. data/lib/rubocop/cop/rspec/mixin/skip_or_pending.rb +2 -2
  57. data/lib/rubocop/cop/rspec/multiple_describes.rb +1 -1
  58. data/lib/rubocop/cop/rspec/multiple_expectations.rb +16 -11
  59. data/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb +2 -4
  60. data/lib/rubocop/cop/rspec/named_subject.rb +6 -3
  61. data/lib/rubocop/cop/rspec/pending.rb +12 -2
  62. data/lib/rubocop/cop/rspec/pending_without_reason.rb +1 -1
  63. data/lib/rubocop/cop/rspec/predicate_matcher.rb +10 -10
  64. data/lib/rubocop/cop/rspec/receive_counts.rb +1 -1
  65. data/lib/rubocop/cop/rspec/receive_messages.rb +161 -0
  66. data/lib/rubocop/cop/rspec/redundant_predicate_matcher.rb +67 -0
  67. data/lib/rubocop/cop/rspec/remove_const.rb +39 -0
  68. data/lib/rubocop/cop/rspec/repeated_example.rb +6 -6
  69. data/lib/rubocop/cop/rspec/repeated_example_group_body.rb +1 -1
  70. data/lib/rubocop/cop/rspec/repeated_example_group_description.rb +2 -2
  71. data/lib/rubocop/cop/rspec/repeated_include_example.rb +1 -1
  72. data/lib/rubocop/cop/rspec/repeated_subject_call.rb +125 -0
  73. data/lib/rubocop/cop/rspec/return_from_stub.rb +1 -1
  74. data/lib/rubocop/cop/rspec/scattered_setup.rb +1 -1
  75. data/lib/rubocop/cop/rspec/shared_context.rb +1 -1
  76. data/lib/rubocop/cop/rspec/shared_examples.rb +66 -20
  77. data/lib/rubocop/cop/rspec/single_argument_message_chain.rb +2 -3
  78. data/lib/rubocop/cop/rspec/sort_metadata.rb +3 -2
  79. data/lib/rubocop/cop/rspec/spec_file_path_format.rb +133 -0
  80. data/lib/rubocop/cop/rspec/spec_file_path_suffix.rb +40 -0
  81. data/lib/rubocop/cop/rspec/stubbed_mock.rb +4 -2
  82. data/lib/rubocop/cop/rspec/subject_stub.rb +6 -6
  83. data/lib/rubocop/cop/rspec/undescriptive_literals_description.rb +69 -0
  84. data/lib/rubocop/cop/rspec/unspecified_exception.rb +2 -2
  85. data/lib/rubocop/cop/rspec/variable_definition.rb +4 -4
  86. data/lib/rubocop/cop/rspec/verified_double_reference.rb +6 -6
  87. data/lib/rubocop/cop/rspec/verified_doubles.rb +2 -2
  88. data/lib/rubocop/cop/rspec/void_expect.rb +4 -3
  89. data/lib/rubocop/cop/rspec_cops.rb +14 -28
  90. data/lib/rubocop/rspec/concept.rb +0 -1
  91. data/lib/rubocop/rspec/config_formatter.rb +1 -11
  92. data/lib/rubocop/rspec/cop/generator.rb +25 -0
  93. data/lib/rubocop/rspec/language.rb +8 -9
  94. data/lib/rubocop/rspec/node.rb +1 -1
  95. data/lib/rubocop/rspec/shared_contexts/default_rspec_language_config_context.rb +1 -1
  96. data/lib/rubocop/rspec/version.rb +1 -1
  97. data/lib/rubocop/rspec/wording.rb +8 -0
  98. data/lib/rubocop-rspec.rb +2 -16
  99. metadata +27 -49
  100. data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +0 -39
  101. data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +0 -104
  102. data/lib/rubocop/cop/rspec/capybara/match_style.rb +0 -38
  103. data/lib/rubocop/cop/rspec/capybara/negation_matcher.rb +0 -33
  104. data/lib/rubocop/cop/rspec/capybara/specific_actions.rb +0 -29
  105. data/lib/rubocop/cop/rspec/capybara/specific_finders.rb +0 -24
  106. data/lib/rubocop/cop/rspec/capybara/specific_matcher.rb +0 -35
  107. data/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb +0 -36
  108. data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +0 -128
  109. data/lib/rubocop/cop/rspec/factory_bot/consistent_parentheses_style.rb +0 -117
  110. data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +0 -260
  111. data/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb +0 -56
  112. data/lib/rubocop/cop/rspec/factory_bot/factory_name_style.rb +0 -74
  113. data/lib/rubocop/cop/rspec/factory_bot/syntax_methods.rb +0 -89
  114. data/lib/rubocop/cop/rspec/file_path.rb +0 -173
  115. data/lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb +0 -43
  116. data/lib/rubocop/cop/rspec/rails/have_http_status.rb +0 -55
  117. data/lib/rubocop/cop/rspec/rails/http_status.rb +0 -203
  118. data/lib/rubocop/cop/rspec/rails/inferred_spec_type.rb +0 -145
  119. data/lib/rubocop/cop/rspec/rails/minitest_assertions.rb +0 -60
  120. data/lib/rubocop/cop/rspec/rails/travel_around.rb +0 -92
  121. data/lib/rubocop/rspec/factory_bot/language.rb +0 -37
  122. data/lib/rubocop/rspec/factory_bot.rb +0 -64
  123. data/lib/rubocop/rspec/language/node_pattern.rb +0 -48
@@ -6,6 +6,8 @@ module RuboCop
6
6
  class Wording
7
7
  SHOULDNT_PREFIX = /\Ashould(?:n't| not)\b/i.freeze
8
8
  SHOULDNT_BE_PREFIX = /#{SHOULDNT_PREFIX} be\b/i.freeze
9
+ WILL_NOT_PREFIX = /\Awill not\b/i.freeze
10
+ WONT_PREFIX = /\Awon't\b/i.freeze
9
11
  ES_SUFFIX_PATTERN = /(?:o|s|x|ch|sh|z)\z/i.freeze
10
12
  IES_SUFFIX_PATTERN = /[^aeou]y\z/i.freeze
11
13
 
@@ -15,16 +17,22 @@ module RuboCop
15
17
  @replacements = replace
16
18
  end
17
19
 
20
+ # rubocop:disable Metrics/MethodLength
18
21
  def rewrite
19
22
  case text
20
23
  when SHOULDNT_BE_PREFIX
21
24
  replace_prefix(SHOULDNT_BE_PREFIX, 'is not')
22
25
  when SHOULDNT_PREFIX
23
26
  replace_prefix(SHOULDNT_PREFIX, 'does not')
27
+ when WILL_NOT_PREFIX
28
+ replace_prefix(WILL_NOT_PREFIX, 'does not')
29
+ when WONT_PREFIX
30
+ replace_prefix(WONT_PREFIX, 'does not')
24
31
  else
25
32
  remove_should_and_pluralize
26
33
  end
27
34
  end
35
+ # rubocop:enable Metrics/MethodLength
28
36
 
29
37
  private
30
38
 
data/lib/rubocop-rspec.rb CHANGED
@@ -4,20 +4,15 @@ require 'pathname'
4
4
  require 'yaml'
5
5
 
6
6
  require 'rubocop'
7
- require 'rubocop-capybara'
8
7
 
9
8
  require_relative 'rubocop/rspec'
10
9
  require_relative 'rubocop/rspec/inject'
11
- require_relative 'rubocop/rspec/language/node_pattern'
10
+ require_relative 'rubocop/rspec/language'
12
11
  require_relative 'rubocop/rspec/node'
13
12
  require_relative 'rubocop/rspec/version'
14
13
  require_relative 'rubocop/rspec/wording'
15
14
 
16
- # Dependent on `RuboCop::RSpec::Language::NodePattern`.
17
- require_relative 'rubocop/rspec/language'
18
-
19
- require_relative 'rubocop/rspec/factory_bot/language'
20
-
15
+ require_relative 'rubocop/cop/rspec/mixin/file_help'
21
16
  require_relative 'rubocop/cop/rspec/mixin/final_end_location'
22
17
  require_relative 'rubocop/cop/rspec/mixin/inside_example_group'
23
18
  require_relative 'rubocop/cop/rspec/mixin/location_help'
@@ -37,7 +32,6 @@ require_relative 'rubocop/rspec/concept'
37
32
  require_relative 'rubocop/rspec/corrector/move_node'
38
33
  require_relative 'rubocop/rspec/example'
39
34
  require_relative 'rubocop/rspec/example_group'
40
- require_relative 'rubocop/rspec/factory_bot'
41
35
  require_relative 'rubocop/rspec/hook'
42
36
 
43
37
  RuboCop::RSpec::Inject.defaults!
@@ -56,12 +50,4 @@ RuboCop::Cop::Layout::ExtraSpacing.singleton_class.prepend(
56
50
  end
57
51
  )
58
52
 
59
- RuboCop::Cop::Style::TrailingCommaInArguments.singleton_class.prepend(
60
- Module.new do
61
- def autocorrect_incompatible_with
62
- super.push(RuboCop::Cop::RSpec::Capybara::CurrentPathExpectation)
63
- end
64
- end
65
- )
66
-
67
53
  RuboCop::AST::Node.include(RuboCop::RSpec::Node)
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.21.0
4
+ version: 3.0.1
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: 2023-05-05 00:00:00.000000000 Z
13
+ date: 2024-06-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rubocop
@@ -18,31 +18,17 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '1.33'
21
+ version: '1.61'
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.33'
29
- - !ruby/object:Gem::Dependency
30
- name: rubocop-capybara
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - "~>"
34
- - !ruby/object:Gem::Version
35
- version: '2.17'
36
- type: :runtime
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: '2.17'
43
- description: |2
44
- Code style checking for RSpec files.
45
- A plugin for the RuboCop code style enforcing & linting tool.
28
+ version: '1.61'
29
+ description: |
30
+ Code style checking for RSpec files.
31
+ A plugin for the RuboCop code style enforcing & linting tool.
46
32
  email:
47
33
  - johncbackus@gmail.com
48
34
  - ian@nevir.net
@@ -71,14 +57,6 @@ files:
71
57
  - lib/rubocop/cop/rspec/be_eql.rb
72
58
  - lib/rubocop/cop/rspec/be_nil.rb
73
59
  - lib/rubocop/cop/rspec/before_after_all.rb
74
- - lib/rubocop/cop/rspec/capybara/current_path_expectation.rb
75
- - lib/rubocop/cop/rspec/capybara/feature_methods.rb
76
- - lib/rubocop/cop/rspec/capybara/match_style.rb
77
- - lib/rubocop/cop/rspec/capybara/negation_matcher.rb
78
- - lib/rubocop/cop/rspec/capybara/specific_actions.rb
79
- - lib/rubocop/cop/rspec/capybara/specific_finders.rb
80
- - lib/rubocop/cop/rspec/capybara/specific_matcher.rb
81
- - lib/rubocop/cop/rspec/capybara/visibility_matcher.rb
82
60
  - lib/rubocop/cop/rspec/change_by_zero.rb
83
61
  - lib/rubocop/cop/rspec/class_check.rb
84
62
  - lib/rubocop/cop/rspec/contain_exactly.rb
@@ -98,6 +76,9 @@ files:
98
76
  - lib/rubocop/cop/rspec/empty_line_after_final_let.rb
99
77
  - lib/rubocop/cop/rspec/empty_line_after_hook.rb
100
78
  - lib/rubocop/cop/rspec/empty_line_after_subject.rb
79
+ - lib/rubocop/cop/rspec/empty_metadata.rb
80
+ - lib/rubocop/cop/rspec/empty_output.rb
81
+ - lib/rubocop/cop/rspec/eq.rb
101
82
  - lib/rubocop/cop/rspec/example_length.rb
102
83
  - lib/rubocop/cop/rspec/example_without_description.rb
103
84
  - lib/rubocop/cop/rspec/example_wording.rb
@@ -105,14 +86,8 @@ files:
105
86
  - lib/rubocop/cop/rspec/expect_actual.rb
106
87
  - lib/rubocop/cop/rspec/expect_change.rb
107
88
  - lib/rubocop/cop/rspec/expect_in_hook.rb
89
+ - lib/rubocop/cop/rspec/expect_in_let.rb
108
90
  - lib/rubocop/cop/rspec/expect_output.rb
109
- - lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb
110
- - lib/rubocop/cop/rspec/factory_bot/consistent_parentheses_style.rb
111
- - lib/rubocop/cop/rspec/factory_bot/create_list.rb
112
- - lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb
113
- - lib/rubocop/cop/rspec/factory_bot/factory_name_style.rb
114
- - lib/rubocop/cop/rspec/factory_bot/syntax_methods.rb
115
- - lib/rubocop/cop/rspec/file_path.rb
116
91
  - lib/rubocop/cop/rspec/focus.rb
117
92
  - lib/rubocop/cop/rspec/hook_argument.rb
118
93
  - lib/rubocop/cop/rspec/hooks_before_examples.rb
@@ -123,6 +98,7 @@ files:
123
98
  - lib/rubocop/cop/rspec/indexed_let.rb
124
99
  - lib/rubocop/cop/rspec/instance_spy.rb
125
100
  - lib/rubocop/cop/rspec/instance_variable.rb
101
+ - lib/rubocop/cop/rspec/is_expected_specify.rb
126
102
  - lib/rubocop/cop/rspec/it_behaves_like.rb
127
103
  - lib/rubocop/cop/rspec/iterated_expectation.rb
128
104
  - lib/rubocop/cop/rspec/leading_subject.rb
@@ -133,9 +109,12 @@ files:
133
109
  - lib/rubocop/cop/rspec/message_chain.rb
134
110
  - lib/rubocop/cop/rspec/message_expectation.rb
135
111
  - lib/rubocop/cop/rspec/message_spies.rb
112
+ - lib/rubocop/cop/rspec/metadata_style.rb
136
113
  - lib/rubocop/cop/rspec/missing_example_group_argument.rb
114
+ - lib/rubocop/cop/rspec/missing_expectation_target_method.rb
137
115
  - lib/rubocop/cop/rspec/mixin/comments_help.rb
138
116
  - lib/rubocop/cop/rspec/mixin/empty_line_separation.rb
117
+ - lib/rubocop/cop/rspec/mixin/file_help.rb
139
118
  - lib/rubocop/cop/rspec/mixin/final_end_location.rb
140
119
  - lib/rubocop/cop/rspec/mixin/inside_example_group.rb
141
120
  - lib/rubocop/cop/rspec/mixin/location_help.rb
@@ -156,20 +135,18 @@ files:
156
135
  - lib/rubocop/cop/rspec/pending.rb
157
136
  - lib/rubocop/cop/rspec/pending_without_reason.rb
158
137
  - lib/rubocop/cop/rspec/predicate_matcher.rb
159
- - lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb
160
- - lib/rubocop/cop/rspec/rails/have_http_status.rb
161
- - lib/rubocop/cop/rspec/rails/http_status.rb
162
- - lib/rubocop/cop/rspec/rails/inferred_spec_type.rb
163
- - lib/rubocop/cop/rspec/rails/minitest_assertions.rb
164
- - lib/rubocop/cop/rspec/rails/travel_around.rb
165
138
  - lib/rubocop/cop/rspec/receive_counts.rb
139
+ - lib/rubocop/cop/rspec/receive_messages.rb
166
140
  - lib/rubocop/cop/rspec/receive_never.rb
167
141
  - lib/rubocop/cop/rspec/redundant_around.rb
142
+ - lib/rubocop/cop/rspec/redundant_predicate_matcher.rb
143
+ - lib/rubocop/cop/rspec/remove_const.rb
168
144
  - lib/rubocop/cop/rspec/repeated_description.rb
169
145
  - lib/rubocop/cop/rspec/repeated_example.rb
170
146
  - lib/rubocop/cop/rspec/repeated_example_group_body.rb
171
147
  - lib/rubocop/cop/rspec/repeated_example_group_description.rb
172
148
  - lib/rubocop/cop/rspec/repeated_include_example.rb
149
+ - lib/rubocop/cop/rspec/repeated_subject_call.rb
173
150
  - lib/rubocop/cop/rspec/return_from_stub.rb
174
151
  - lib/rubocop/cop/rspec/scattered_let.rb
175
152
  - lib/rubocop/cop/rspec/scattered_setup.rb
@@ -178,9 +155,12 @@ files:
178
155
  - lib/rubocop/cop/rspec/single_argument_message_chain.rb
179
156
  - lib/rubocop/cop/rspec/skip_block_inside_example.rb
180
157
  - lib/rubocop/cop/rspec/sort_metadata.rb
158
+ - lib/rubocop/cop/rspec/spec_file_path_format.rb
159
+ - lib/rubocop/cop/rspec/spec_file_path_suffix.rb
181
160
  - lib/rubocop/cop/rspec/stubbed_mock.rb
182
161
  - lib/rubocop/cop/rspec/subject_declaration.rb
183
162
  - lib/rubocop/cop/rspec/subject_stub.rb
163
+ - lib/rubocop/cop/rspec/undescriptive_literals_description.rb
184
164
  - lib/rubocop/cop/rspec/unspecified_exception.rb
185
165
  - lib/rubocop/cop/rspec/variable_definition.rb
186
166
  - lib/rubocop/cop/rspec/variable_name.rb
@@ -193,16 +173,14 @@ files:
193
173
  - lib/rubocop/rspec/align_let_brace.rb
194
174
  - lib/rubocop/rspec/concept.rb
195
175
  - lib/rubocop/rspec/config_formatter.rb
176
+ - lib/rubocop/rspec/cop/generator.rb
196
177
  - lib/rubocop/rspec/corrector/move_node.rb
197
178
  - lib/rubocop/rspec/description_extractor.rb
198
179
  - lib/rubocop/rspec/example.rb
199
180
  - lib/rubocop/rspec/example_group.rb
200
- - lib/rubocop/rspec/factory_bot.rb
201
- - lib/rubocop/rspec/factory_bot/language.rb
202
181
  - lib/rubocop/rspec/hook.rb
203
182
  - lib/rubocop/rspec/inject.rb
204
183
  - lib/rubocop/rspec/language.rb
205
- - lib/rubocop/rspec/language/node_pattern.rb
206
184
  - lib/rubocop/rspec/node.rb
207
185
  - lib/rubocop/rspec/shared_contexts/default_rspec_language_config_context.rb
208
186
  - lib/rubocop/rspec/version.rb
@@ -214,7 +192,7 @@ metadata:
214
192
  changelog_uri: https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md
215
193
  documentation_uri: https://docs.rubocop.org/rubocop-rspec/
216
194
  rubygems_mfa_required: 'true'
217
- post_install_message:
195
+ post_install_message:
218
196
  rdoc_options: []
219
197
  require_paths:
220
198
  - lib
@@ -229,8 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
207
  - !ruby/object:Gem::Version
230
208
  version: '0'
231
209
  requirements: []
232
- rubygems_version: 3.4.12
233
- signing_key:
210
+ rubygems_version: 3.5.9
211
+ signing_key:
234
212
  specification_version: 4
235
213
  summary: Code style checking for RSpec files
236
214
  test_files: []
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- module Capybara
7
- # @!parse
8
- # # Checks that no expectations are set on Capybara's `current_path`.
9
- # #
10
- # # The
11
- # # https://www.rubydoc.info/github/teamcapybara/capybara/master/Capybara/RSpecMatchers#have_current_path-instance_method[`have_current_path` matcher]
12
- # # should be used on `page` to set expectations on Capybara's
13
- # # current path, since it uses
14
- # # https://github.com/teamcapybara/capybara/blob/master/README.md#asynchronous-javascript-ajax-and-friends[Capybara's waiting functionality]
15
- # # which ensures that preceding actions (like `click_link`) have
16
- # # completed.
17
- # #
18
- # # This cop does not support autocorrection in some cases.
19
- # #
20
- # # @example
21
- # # # bad
22
- # # expect(current_path).to eq('/callback')
23
- # #
24
- # # # good
25
- # # expect(page).to have_current_path('/callback')
26
- # #
27
- # # # bad (does not support autocorrection)
28
- # # expect(page.current_path).to match(variable)
29
- # #
30
- # # # good
31
- # # expect(page).to have_current_path('/callback')
32
- # #
33
- # class CurrentPathExpectation < ::RuboCop::Cop::Base; end
34
- CurrentPathExpectation =
35
- ::RuboCop::Cop::Capybara::CurrentPathExpectation
36
- end
37
- end
38
- end
39
- end
@@ -1,104 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- module Capybara
7
- # Checks for consistent method usage in feature specs.
8
- #
9
- # By default, the cop disables all Capybara-specific methods that have
10
- # the same native RSpec method (e.g. are just aliases). Some teams
11
- # however may prefer using some of the Capybara methods (like `feature`)
12
- # to make it obvious that the test uses Capybara, while still disable
13
- # the rest of the methods, like `given` (alias for `let`), `background`
14
- # (alias for `before`), etc. You can configure which of the methods to
15
- # be enabled by using the EnabledMethods configuration option.
16
- #
17
- # @example
18
- # # bad
19
- # feature 'User logs in' do
20
- # given(:user) { User.new }
21
- #
22
- # background do
23
- # visit new_session_path
24
- # end
25
- #
26
- # scenario 'with OAuth' do
27
- # # ...
28
- # end
29
- # end
30
- #
31
- # # good
32
- # describe 'User logs in' do
33
- # let(:user) { User.new }
34
- #
35
- # before do
36
- # visit new_session_path
37
- # end
38
- #
39
- # it 'with OAuth' do
40
- # # ...
41
- # end
42
- # end
43
- #
44
- class FeatureMethods < Base
45
- extend AutoCorrector
46
- include InsideExampleGroup
47
-
48
- MSG = 'Use `%<replacement>s` instead of `%<method>s`.'
49
-
50
- # https://github.com/teamcapybara/capybara/blob/e283c1aeaa72441f5403963577e16333bf111a81/lib/capybara/rspec/features.rb#L31-L36
51
- MAP = {
52
- background: :before,
53
- scenario: :it,
54
- xscenario: :xit,
55
- given: :let,
56
- given!: :let!,
57
- feature: :describe
58
- }.freeze
59
-
60
- # @!method capybara_speak(node)
61
- def_node_matcher :capybara_speak, <<-PATTERN
62
- {#{MAP.keys.map(&:inspect).join(' ')}}
63
- PATTERN
64
-
65
- # @!method feature_method(node)
66
- def_node_matcher :feature_method, <<-PATTERN
67
- (block
68
- $(send #rspec? $#capybara_speak ...)
69
- ...)
70
- PATTERN
71
-
72
- def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
73
- return unless inside_example_group?(node)
74
-
75
- feature_method(node) do |send_node, match|
76
- next if enabled?(match)
77
-
78
- add_offense(send_node.loc.selector) do |corrector|
79
- corrector.replace(send_node.loc.selector, MAP[match].to_s)
80
- end
81
- end
82
- end
83
-
84
- def message(range)
85
- name = range.source.to_sym
86
- format(MSG, method: name, replacement: MAP[name])
87
- end
88
-
89
- private
90
-
91
- def enabled?(method_name)
92
- enabled_methods.include?(method_name)
93
- end
94
-
95
- def enabled_methods
96
- cop_config
97
- .fetch('EnabledMethods', [])
98
- .map(&:to_sym)
99
- end
100
- end
101
- end
102
- end
103
- end
104
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- module Capybara
7
- # @!parse
8
- # # Checks for usage of deprecated style methods.
9
- # #
10
- # # @example when using `assert_style`
11
- # # # bad
12
- # # page.find(:css, '#first').assert_style(display: 'block')
13
- # #
14
- # # # good
15
- # # page.find(:css, '#first').assert_matches_style(display: 'block')
16
- # #
17
- # # @example when using `has_style?`
18
- # # # bad
19
- # # expect(page.find(:css, 'first')
20
- # # .has_style?(display: 'block')).to be true
21
- # #
22
- # # # good
23
- # # expect(page.find(:css, 'first')
24
- # # .matches_style?(display: 'block')).to be true
25
- # #
26
- # # @example when using `have_style`
27
- # # # bad
28
- # # expect(page).to have_style(display: 'block')
29
- # #
30
- # # # good
31
- # # expect(page).to match_style(display: 'block')
32
- # #
33
- # class MatchStyle < ::RuboCop::Cop::Base; end
34
- MatchStyle = ::RuboCop::Cop::Capybara::MatchStyle
35
- end
36
- end
37
- end
38
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- module Capybara
7
- # @!parse
8
- # # Enforces use of `have_no_*` or `not_to` for negated expectations.
9
- # #
10
- # # @example EnforcedStyle: not_to (default)
11
- # # # bad
12
- # # expect(page).to have_no_selector
13
- # # expect(page).to have_no_css('a')
14
- # #
15
- # # # good
16
- # # expect(page).not_to have_selector
17
- # # expect(page).not_to have_css('a')
18
- # #
19
- # # @example EnforcedStyle: have_no
20
- # # # bad
21
- # # expect(page).not_to have_selector
22
- # # expect(page).not_to have_css('a')
23
- # #
24
- # # # good
25
- # # expect(page).to have_no_selector
26
- # # expect(page).to have_no_css('a')
27
- # #
28
- # class NegationMatcher < ::RuboCop::Cop::Base; end
29
- NegationMatcher = ::RuboCop::Cop::Capybara::NegationMatcher
30
- end
31
- end
32
- end
33
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- module Capybara
7
- # @!parse
8
- # # Checks for there is a more specific actions offered by Capybara.
9
- # #
10
- # # @example
11
- # #
12
- # # # bad
13
- # # find('a').click
14
- # # find('button.cls').click
15
- # # find('a', exact_text: 'foo').click
16
- # # find('div button').click
17
- # #
18
- # # # good
19
- # # click_link
20
- # # click_button(class: 'cls')
21
- # # click_link(exact_text: 'foo')
22
- # # find('div').click_button
23
- # #
24
- # class SpecificActions < ::RuboCop::Cop::Base; end
25
- SpecificActions = ::RuboCop::Cop::Capybara::SpecificActions
26
- end
27
- end
28
- end
29
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- module Capybara
7
- # @!parse
8
- # # Checks if there is a more specific finder offered by Capybara.
9
- # #
10
- # # @example
11
- # # # bad
12
- # # find('#some-id')
13
- # # find('[visible][id=some-id]')
14
- # #
15
- # # # good
16
- # # find_by_id('some-id')
17
- # # find_by_id('some-id', visible: true)
18
- # #
19
- # class SpecificFinders < ::RuboCop::Cop::Base; end
20
- SpecificFinders = ::RuboCop::Cop::Capybara::SpecificFinders
21
- end
22
- end
23
- end
24
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- module Capybara
7
- # @!parse
8
- # # Checks for there is a more specific matcher offered by Capybara.
9
- # #
10
- # # @example
11
- # #
12
- # # # bad
13
- # # expect(page).to have_selector('button')
14
- # # expect(page).to have_no_selector('button.cls')
15
- # # expect(page).to have_css('button')
16
- # # expect(page).to have_no_css('a.cls', href: 'http://example.com')
17
- # # expect(page).to have_css('table.cls')
18
- # # expect(page).to have_css('select')
19
- # # expect(page).to have_css('input', exact_text: 'foo')
20
- # #
21
- # # # good
22
- # # expect(page).to have_button
23
- # # expect(page).to have_no_button(class: 'cls')
24
- # # expect(page).to have_button
25
- # # expect(page).to have_no_link('foo', class: 'cls', href: 'http://example.com')
26
- # # expect(page).to have_table(class: 'cls')
27
- # # expect(page).to have_select
28
- # # expect(page).to have_field('foo')
29
- # #
30
- # class SpecificMatcher < ::RuboCop::Cop::Base; end
31
- SpecificMatcher = ::RuboCop::Cop::Capybara::SpecificMatcher
32
- end
33
- end
34
- end
35
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- module Capybara
7
- # @!parse
8
- # # Checks for boolean visibility in Capybara finders.
9
- # #
10
- # # Capybara lets you find elements that match a certain visibility
11
- # # using the `:visible` option. `:visible` accepts both boolean and
12
- # # symbols as values, however using booleans can have unwanted
13
- # # effects. `visible: false` does not find just invisible elements,
14
- # # but both visible and invisible elements. For expressiveness and
15
- # # clarity, use one of the # symbol values, `:all`, `:hidden` or
16
- # # `:visible`.
17
- # # Read more in
18
- # # https://www.rubydoc.info/gems/capybara/Capybara%2FNode%2FFinders:all[the documentation].
19
- # #
20
- # # @example
21
- # # # bad
22
- # # expect(page).to have_selector('.foo', visible: false)
23
- # # expect(page).to have_css('.foo', visible: true)
24
- # # expect(page).to have_link('my link', visible: false)
25
- # #
26
- # # # good
27
- # # expect(page).to have_selector('.foo', visible: :visible)
28
- # # expect(page).to have_css('.foo', visible: :all)
29
- # # expect(page).to have_link('my link', visible: :hidden)
30
- # #
31
- # class VisibilityMatcher < ::RuboCop::Cop::Base; end
32
- VisibilityMatcher = ::RuboCop::Cop::Capybara::VisibilityMatcher
33
- end
34
- end
35
- end
36
- end