Skip to content

Instantly share code, notes, and snippets.

@kares
Created December 28, 2009 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kares/264891 to your computer and use it in GitHub Desktop.
Save kares/264891 to your computer and use it in GitHub Desktop.
assert an error is caused by JSON parsing for rails 2.x.x
def assert_json_parse_exception(error)
if ActiveSupport::JSON.respond_to?(:parse_error) # 2.3.5
parse_error_class = ActiveSupport::JSON.parse_error
assert_instance_of parse_error_class, error
else
assert_instance_of ActiveSupport::JSON::ParseError, error
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment