Module: JsonExpressions::Test::Unit::Helpers
- Included in:
- Test::Unit::TestCase
- Defined in:
- lib/json_expressions/test/unit/helpers.rb
Instance Method Summary collapse
Instance Method Details
#assert_json_match(exp, act, msg = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/json_expressions/test/unit/helpers.rb', line 8 def assert_json_match(exp, act, msg = nil) unless JsonExpressions::Matcher === exp exp = JsonExpressions::Matcher.new(exp) end if String === act begin act = JSON.parse(act) rescue assert false, "Expected #{pp(act)} to be valid JSON" end end unless exp =~ act assert false, "Expected #{pp(exp)} to match #{pp(act)}\n #{exp.last_error}" end # Return the matcher return exp end |