Skip to content

Commit

Permalink
Merge pull request #1401 from ydah/fix/specific_matcher
Browse files Browse the repository at this point in the history
Fix a false positive for `RSpec/Capybara/SpecificMatcher` when `have_css("a")` without attribute
  • Loading branch information
Darhazer authored Oct 3, 2022
2 parents 61e154c + d807313 commit 4a05fd3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Master (Unreleased)

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

## 2.13.2 (2022-09-23)

Expand Down
1 change: 0 additions & 1 deletion lib/rubocop/cop/rspec/capybara/specific_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def specific_matcher(arg)

def specific_matcher_option?(node, arg, matcher)
attrs = CssSelector.attributes(arg).keys
return true if attrs.empty?
return false unless replaceable_matcher?(node, matcher, attrs)

attrs.all? do |attr|
Expand Down
1 change: 1 addition & 0 deletions spec/rubocop/cop/rspec/capybara/specific_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class style visible obscured exact exact_text normalize_ws match wait
"first argument is element with replaceable attributes #{attr} " \
'for `have_link` without `href`' do
expect_no_offenses(<<-RUBY, attr: attr)
expect(page).to have_css("a")
expect(page).to have_css("a[#{attr}=foo]")
expect(page).to have_css("a[#{attr}]")
RUBY
Expand Down

0 comments on commit 4a05fd3

Please sign in to comment.