Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSpec/RedundantPredicateMatcher autocorrect on be_match is not safe #1781

Open
Tietew opened this issue Jan 16, 2024 · 1 comment
Open

RSpec/RedundantPredicateMatcher autocorrect on be_match is not safe #1781

Tietew opened this issue Jan 16, 2024 · 1 comment

Comments

@Tietew
Copy link
Contributor

Tietew commented Jan 16, 2024

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
Copy link
Member

pirj commented Jan 22, 2024

Is it deliberate that you don’t want to override == in this class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants