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

"NotImplementedError: expect { }.not_to change { }.by() is not supported" - would be nice to improve #1433

Open
loqimean opened this issue Oct 17, 2023 · 2 comments

Comments

@loqimean
Copy link

Hi, there is an error when you add .by(..) to your expect {}.not_to change(some, :attr), like expect {}.not_to change(some, :attr).by(1) that says "NotImplementedError: expect { }.not_to change { }.by() is not supported" and.., it's really not good, because you see the first things that say "You can use change matcher with the block" but you miss that there is a problem 'cause you forget to delete or just added .by(..) to your matcher.
My solution:
To change the error message like to this: Hey, you cannot use '.by(1)' in your <code> matcher, it is not supported, delete it or change matcher, please.
*Would be fun if the message can be like this, please ^-^

@JonRowe JonRowe transferred this issue from rspec/rspec-rails Oct 17, 2023
@pirj
Copy link
Member

pirj commented Oct 17, 2023

Would you harvest the codebase for similar messages, and send a PR to make them more consistent?

@JonRowe
Copy link
Member

JonRowe commented Oct 18, 2023

The error comes from here https://github.com/rspec/rspec-expectations/blob/main/lib/rspec/matchers/built_in/change.rb#L150

        def does_not_match?(_event_proc)
          raise NotImplementedError, "`expect { }.not_to change " \
            "{ }.#{@relativity}()` is not supported"
        end

This could be changed to "{ }.#{@relativity}() is not supported, remove #{@relativity} or refactor your expression.` or similar...

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

3 participants