Skip to content

Commit

Permalink
Exclude have_text and have_content that raise ArgumentError wit…
Browse files Browse the repository at this point in the history
…h `RSpec/Capybara/VisibilityMatcher` where `:visible` is an invalid option

If `:visible` is specified for `have_text` and its alias method,
`have_content`, it will result in an `ArgumentError` as follows.

Therefore, This PR is excluded `have_text` and `have_content`
for `RSpec/Capybara/VisibilityMatcher`.

```
      Failure/Error: expect(page).to have_text('a', visible: true)

      ArgumentError:
        Invalid option(s) :visible, should be one of :count, :minimum, :maximum, :between, :wait, :exact, :normalize_ws
      # ./spec/capybara/sandbox_spec.rb:20:in `block (2 levels) in <top (required)>'

      Failure/Error: expect(page).to have_content('a', visible: true)

      ArgumentError:
        Invalid option(s) :visible, should be one of :count, :minimum, :maximum, :between, :wait, :exact, :normalize_ws
      # ./spec/capybara/sandbox_spec.rb:68:in `block (2 levels) in <top (required)>'
```
  • Loading branch information
ydah committed Sep 21, 2022
1 parent 3e05139 commit 7f5e2c1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Fix an error for `RSpec/Capybara/SpecificFinders` with no parentheses. ([@ydah][])
* Fix a false positive for `RSpec/NoExpectationExample` with pending using `skip` or `pending` inside an example. ([@ydah][])
* Exclude `have_text` and `have_content` that raise `ArgumentError` with `RSpec/Capybara/VisibilityMatcher` where `:visible` is an invalid option. ([@ydah][])

## 2.13.1 (2022-09-12)

Expand Down
2 changes: 0 additions & 2 deletions lib/rubocop/cop/rspec/capybara/visibility_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class VisibilityMatcher < Base
have_table
have_checked_field
have_unchecked_field
have_text
have_content
].freeze

RESTRICT_ON_SEND = CAPYBARA_MATCHER_METHODS
Expand Down
4 changes: 0 additions & 4 deletions spec/rubocop/cop/rspec/capybara/visibility_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
^^^^^^^^^^^^^^ Use `:all` or `:hidden` instead of `false`.
expect(page).to have_unchecked_field('cat', visible: false)
^^^^^^^^^^^^^^ Use `:all` or `:hidden` instead of `false`.
expect(page).to have_text('My homepage', visible: false)
^^^^^^^^^^^^^^ Use `:all` or `:hidden` instead of `false`.
expect(page).to have_content('Success', visible: false)
^^^^^^^^^^^^^^ Use `:all` or `:hidden` instead of `false`.
RUBY
end

Expand Down

0 comments on commit 7f5e2c1

Please sign in to comment.