module Minitest::Assertions
Assert style
Public Instance Methods
assert_match_json(expected, actual)
click to toggle source
Fails unless +param and +actual have the same items.
# File lib/minitest/match_json.rb, line 41 def assert_match_json(expected, actual) match_json(expected, actual) end
Private Instance Methods
match_json(expected, actual)
click to toggle source
Helper to highlight diffs between two json strings
# File lib/minitest/match_json.rb, line 48 def match_json(expected, actual) diff_str = Minitest::MatchJson.compare_json( pretty_json(actual), pretty_json(expected) ) diff_str.strip.empty? ? match_json_passes : match_json_fails(diff_str) end
match_json_fails(diff_str)
click to toggle source
# File lib/minitest/match_json.rb, line 55 def match_json_fails(diff_str) puts "\n#{diff_str}\n" flunk 'JSON did not match' end
match_json_passes()
click to toggle source
# File lib/minitest/match_json.rb, line 60 def match_json_passes pass 'JSON matched' end
pretty_json(param)
click to toggle source
# File lib/minitest/match_json.rb, line 64 def pretty_json(param) Minitest::MatchJson.pretty_json(param) rescue StandardError flunk 'Parameter cannot be converted to JSON' end