Skip to content

Instantly share code, notes, and snippets.

@nacengineer
Last active December 10, 2015 00:49
Show Gist options
  • Save nacengineer/4353897 to your computer and use it in GitHub Desktop.
Save nacengineer/4353897 to your computer and use it in GitHub Desktop.
A simple method to add to test helpers for displaying error messages
# assumptions: rails, object responds to errors
# in your test use this line where object is the object being validated
# :msg => flay_the_errors(__method__).call( object.errors)
def flay_the_errors( method )
Proc.new do |x|
y = "\n### oh noes #{method} failed! ###\n"
y << "Full Inspect:\n"
y << x.inspect << "\n"
x.each {|k,v| y << "- #{k} #{v}\n"}
y
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment