shoulda-matchers
shoulda-matchers copied to clipboard
should_not validate_presence_of can give a false positive
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.
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? :smile: