Pattern: Missing use of predicate matcher
Issue: -
Prefer using predicate matcher over using predicate method directly.
RSpec defines magic matchers for predicate methods. This rule recommends to use the predicate matcher instead of using predicate method directly.
# bad
expect(foo.something?).to be_truthy
# good
expect(foo).to be_something
# also good - It checks "true" strictly.
expect(foo).to be(true)
# bad
expect(foo.something?).to be_truthy
expect(foo).to be(true)
# good
expect(foo).to be_something
# bad
expect(foo).to be_something
# good - the above code is rewritten to it by this cop
expect(foo.something?).to be(true)
# bad
expect(foo).to be_something
# good - the above code is rewritten to it by this cop
expect(foo.something?).to be_truthy
Name | Default value | Configurable values |
---|---|---|
Strict | true |
Boolean |
EnforcedStyle | inflected |
inflected , explicit |