Skip to content

Commit

Permalink
Add AllowedPatterns configuration option to `RSpec/NoExpectationExa…
Browse files Browse the repository at this point in the history
…mple`

Fix: rubocop/rubocop-rspec#1385

This cop can be customized allowed expectation methods pattern
with `AllowedPatterns`. \Aexpect_ and \Aassert_ are allowed by default.

### @ example `AllowedPatterns: [\Aexpect_]`
```ruby
# bad
it do
  not_expect_something
end

# good
it do
  expect_something
end
```
  • Loading branch information
ydah committed Oct 16, 2022
1 parent 7594e3d commit 42022b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Fix a false positive for `RSpec/Capybara/SpecificMatcher` when `have_css("a")` without attribute. ([@ydah][])
* Update `RSpec/ExampleWording` cop to raise error for insufficient descriptions. ([@akrox58][])
* Add new `RSpec/Capybara/NegationMatcher` cop. ([@ydah][])
* Add `AllowedPatterns` configuration option to `RSpec/NoExpectationExample`. ([@ydah][])

## 2.13.2 (2022-09-23)

Expand Down
4 changes: 4 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,11 @@ RSpec/NoExpectationExample:
Enabled: pending
Safe: false
VersionAdded: '2.13'
VersionChanged: '2.14'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NoExpectationExample
AllowedPatterns:
- "^expect_"
- "^assert_"

RSpec/NotToNot:
Description: Checks for consistent method usage for negating expectations.
Expand Down

0 comments on commit 42022b9

Please sign in to comment.