Last active
December 10, 2015 00:49
-
-
Save nacengineer/4353897 to your computer and use it in GitHub Desktop.
A simple method to add to test helpers for displaying error messages
This file contains hidden or 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
| # 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