Skip to content

Commit 3375bbb

Browse files
committed
Add RuboCop/Capybara-NegationMatcherAfterVisit.md
1 parent 0f698b4 commit 3375bbb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Pattern: Negation matcher after `visit`
2+
3+
Issue: -
4+
5+
## Description
6+
7+
Do not allow negative matchers to be used immediately after `visit`.
8+
9+
## Examples
10+
11+
```ruby
12+
# bad
13+
visit foo_path
14+
expect(page).to have_no_link('bar')
15+
expect(page).to have_css('a')
16+
17+
# good
18+
visit foo_path
19+
expect(page).to have_css('a')
20+
expect(page).to have_no_link('bar')
21+
22+
# bad
23+
visit foo_path
24+
expect(page).not_to have_link('bar')
25+
expect(page).to have_css('a')
26+
27+
# good
28+
visit foo_path
29+
expect(page).to have_css('a')
30+
expect(page).not_to have_link('bar')
31+
```
32+
33+
## Further Reading
34+
35+
* [RuboCop - Capybara/NegationMatcherAfterVisit](https://docs.rubocop.org/rubocop-capybara/cops_capybara.html#capybaranegationmatcheraftervisit)
36+

0 commit comments

Comments
 (0)