You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you think it would be useful to enable somekind of mechanism allowing to prettify JSON output in case if matching process fails? If yes, what would be the best way to implement this?
Thanks for your suggestion!
My ugly solution is to include this snippet in test_helper.rb:
moduleJsonExpressionsclassMatcherdefjson@jsonendendendmoduleMiniTestmoduleAssertionsdefmu_pp2(obj,msg=nil)apmsg,color: {string: :purpleish}ifmsg.present?apobjapmsg.reverse,color: {string: :purpleish}ifmsg.present?enddefassert_json_match(exp,act,msg=nil)unlessJsonExpressions::Matcher === expexp=JsonExpressions::Matcher.new(exp)endifString === actassertact=JSON.parse(act),"Expected #{mu_pp(act)} to be valid JSON"endassertexp =~ act,->{"Expected #{mu_pp2(exp.json,'Expected---------->')} to match #{mu_pp2(act,'Actual---------->')}\n" + exp.last_error}# Return the matcherreturnexpenddefrefute_json_match(exp,act,msg=nil)unlessJsonExpressions::Matcher === expexp=JsonExpressions::Matcher.new(exp)endifString === actassertact=JSON.parse(act),"Expected #{mu_pp(act)} to be valid JSON"endrefuteexp =~ act,->{"Expected #{mu_pp2(exp.json,'Expected')} to match #{mu_pp2(act,'Actual')}\n" + exp.last_error}# Return the matcherreturnexpendendend
The text was updated successfully, but these errors were encountered:
movstox
changed the title
Using awesome_print for prettier JSON output on failure
[feature]: Using awesome_print for prettier JSON output on failure
Feb 7, 2015
Hi all and thanks for this beautiful gem,
Do you think it would be useful to enable somekind of mechanism allowing to prettify JSON output in case if matching process fails? If yes, what would be the best way to implement this?
Thanks for your suggestion!
My ugly solution is to include this snippet in
test_helper.rb
:The text was updated successfully, but these errors were encountered: