Created
December 24, 2011 03:32
-
-
Save amiel/1516144 to your computer and use it in GitHub Desktop.
I was fed up with "expected valid? to return true". Now you get errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module CustomValidationMatcher | |
class IsValid | |
def matches?(target) | |
@target = target | |
@target.valid? | |
end | |
def failure_message | |
"expected #{ @target.class.name } to be in valid, errors were: #{ @target.errors.full_messages.inspect }" | |
end | |
def negative_failure_message | |
"expected #{ @target.class.name } not to be valid" | |
end | |
end | |
def be_valid | |
IsValid.new | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment