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

should_not validate_presence_of can give a false positive #1302

Open
mcmire opened this issue May 15, 2020 · 1 comment
Open

should_not validate_presence_of can give a false positive #1302

mcmire opened this issue May 15, 2020 · 1 comment

Comments

@mcmire
Copy link
Collaborator

mcmire commented May 15, 2020

If you have a situation where you have a presence validation with a custom message and you say it { should_not validate_presence_of(:attribute) } when in fact the validation is being run, the test will pass. This is technically true, because it { should_not validate_presence_of(:attribute) } is the same thing as saying it { should_not validate_presence_of(:attribute).with_message(:blank) }. That may make sense for should, but for should_not this doesn't make any sense.

@HeitorMC
Copy link
Contributor

HeitorMC commented Mar 7, 2023

Hey @mcmire. I'm working on this one. But honestly, I'm getting lost searching for the responsible method of the false positive, in lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb.

Can you help me out? 😄

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

No branches or pull requests

2 participants