File tree Expand file tree Collapse file tree 4 files changed +25
-23
lines changed Expand file tree Collapse file tree 4 files changed +25
-23
lines changed Original file line number Diff line number Diff line change 6
6
- Fix a false negative for ` RSpec/HaveSelector ` when first argument is dstr node. ([ @ydah ] )
7
7
- Add new ` Capybara/RedundantWithinFind ` cop. ([ @ydah ] )
8
8
- Fix an invalid attributes parse when name with multiple ` [] ` for ` Capybara/SpecificFinders ` and ` Capybara/SpecificActions ` and ` Capybara/SpecificMatcher ` . ([ @ydah ] )
9
+ - Change to default ` EnforcedStyle: have_no ` for ` Capybara/NegationMatcher ` cop. ([ @ydah ] )
9
10
10
11
## 2.19.0 (2023-09-20)
11
12
Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ Capybara/NegationMatcher:
37
37
Description : Enforces use of `have_no_*` or `not_to` for negated expectations.
38
38
Enabled : pending
39
39
VersionAdded : ' 2.14'
40
- EnforcedStyle : not_to
40
+ VersionChanged : " <<next>>"
41
+ EnforcedStyle : have_no
41
42
SupportedStyles :
42
43
- have_no
43
44
- not_to
Original file line number Diff line number Diff line change @@ -170,37 +170,37 @@ expect(page).to match_style(display: 'block')
170
170
| Yes
171
171
| Yes
172
172
| 2.14
173
- | -
173
+ | <<next>>
174
174
|===
175
175
176
176
Enforces use of `have_no_*` or `not_to` for negated expectations.
177
177
178
178
=== Examples
179
179
180
- ==== EnforcedStyle: not_to (default)
180
+ ==== EnforcedStyle: have_no (default)
181
181
182
182
[source,ruby]
183
183
----
184
184
# bad
185
- expect(page).to have_no_selector
186
- expect(page).to have_no_css('a')
187
-
188
- # good
189
185
expect(page).not_to have_selector
190
186
expect(page).not_to have_css('a')
187
+
188
+ # good
189
+ expect(page).to have_no_selector
190
+ expect(page).to have_no_css('a')
191
191
----
192
192
193
- ==== EnforcedStyle: have_no
193
+ ==== EnforcedStyle: not_to
194
194
195
195
[source,ruby]
196
196
----
197
197
# bad
198
- expect(page).not_to have_selector
199
- expect(page).not_to have_css('a')
200
-
201
- # good
202
198
expect(page).to have_no_selector
203
199
expect(page).to have_no_css('a')
200
+
201
+ # good
202
+ expect(page).not_to have_selector
203
+ expect(page).not_to have_css('a')
204
204
----
205
205
206
206
=== Configurable attributes
@@ -209,7 +209,7 @@ expect(page).to have_no_css('a')
209
209
| Name | Default value | Configurable values
210
210
211
211
| EnforcedStyle
212
- | `not_to `
212
+ | `have_no `
213
213
| `have_no`, `not_to`
214
214
|===
215
215
Original file line number Diff line number Diff line change @@ -5,16 +5,7 @@ module Cop
5
5
module Capybara
6
6
# Enforces use of `have_no_*` or `not_to` for negated expectations.
7
7
#
8
- # @example EnforcedStyle: not_to (default)
9
- # # bad
10
- # expect(page).to have_no_selector
11
- # expect(page).to have_no_css('a')
12
- #
13
- # # good
14
- # expect(page).not_to have_selector
15
- # expect(page).not_to have_css('a')
16
- #
17
- # @example EnforcedStyle: have_no
8
+ # @example EnforcedStyle: have_no (default)
18
9
# # bad
19
10
# expect(page).not_to have_selector
20
11
# expect(page).not_to have_css('a')
@@ -23,6 +14,15 @@ module Capybara
23
14
# expect(page).to have_no_selector
24
15
# expect(page).to have_no_css('a')
25
16
#
17
+ # @example EnforcedStyle: not_to
18
+ # # bad
19
+ # expect(page).to have_no_selector
20
+ # expect(page).to have_no_css('a')
21
+ #
22
+ # # good
23
+ # expect(page).not_to have_selector
24
+ # expect(page).not_to have_css('a')
25
+ #
26
26
class NegationMatcher < ::RuboCop ::Cop ::Base
27
27
extend AutoCorrector
28
28
include ConfigurableEnforcedStyle
You can’t perform that action at this time.
0 commit comments