Skip to content

Commit 4a05fd3

Browse files
authored
Merge pull request #1401 from ydah/fix/specific_matcher
Fix a false positive for `RSpec/Capybara/SpecificMatcher` when `have_css("a")` without attribute
2 parents 61e154c + d807313 commit 4a05fd3

File tree

3 files changed

+2
-1
lines changed

3 files changed

+2
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Master (Unreleased)
44

55
* Add `require_implicit` style to `RSpec/ImplicitSubject`. ([@r7kamura][])
6+
* Fix a false positive for `RSpec/Capybara/SpecificMatcher` when `have_css("a")` without attribute. ([@ydah][])
67

78
## 2.13.2 (2022-09-23)
89

lib/rubocop/cop/rspec/capybara/specific_matcher.rb

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ def specific_matcher(arg)
9696

9797
def specific_matcher_option?(node, arg, matcher)
9898
attrs = CssSelector.attributes(arg).keys
99-
return true if attrs.empty?
10099
return false unless replaceable_matcher?(node, matcher, attrs)
101100

102101
attrs.all? do |attr|

spec/rubocop/cop/rspec/capybara/specific_matcher_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class style visible obscured exact exact_text normalize_ws match wait
101101
"first argument is element with replaceable attributes #{attr} " \
102102
'for `have_link` without `href`' do
103103
expect_no_offenses(<<-RUBY, attr: attr)
104+
expect(page).to have_css("a")
104105
expect(page).to have_css("a[#{attr}=foo]")
105106
expect(page).to have_css("a[#{attr}]")
106107
RUBY

0 commit comments

Comments
 (0)