Skip to content

Instantly share code, notes, and snippets.

@amiel
Created December 24, 2011 03:32
Show Gist options
  • Save amiel/1516144 to your computer and use it in GitHub Desktop.
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
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