RSpec/RedundantPredicateMatcher autocorrect on be_match is not safe
Tietew opened this issue · 1 comments
Tietew commented
Example
class Token
def initialize(token) = @token = token
def match?(other) = other == @token
end
Passed expectation
expect(Token.new('FOO')).to be_match('FOO')
# calls Token.new('FOO').match?('FOO') => true
Autocorrected expectation
expect(Token.new('FOO')).to match('FOO')
# calls 'FOO'.match(Token.new('FOO')) => false
fails with message:
expected #<Token:0x**** @token="FOO"> to match "FOO"
pirj commented
Is it deliberate that you don’t want to override ==
in this class?