Skip to content

Instantly share code, notes, and snippets.

@lostphilosopher
Created February 9, 2017 16:04
Show Gist options
  • Save lostphilosopher/2e247373dd152e1aaec93e25bbea1f1b to your computer and use it in GitHub Desktop.
Save lostphilosopher/2e247373dd152e1aaec93e25bbea1f1b to your computer and use it in GitHub Desktop.
Test for Avro support of `doc`
require 'avro'
require 'pry'
schema =
{
"type": "record",
"name": "User",
"fields":
[
{
"name": "name",
"type": "string",
"doc": "lorem ipsum"
},
{
"name": "points",
"type": "int",
"doc": "lorem ipsum"
},
{
"name": "winner",
"type": "boolean",
"default": "false",
"doc": "lorem ipsum"
}
]
}.to_json
schema = Avro::Schema.parse(schema)
puts schema
puts '---'
# Test case to verify if :doc is being supported in Avro
field = schema.fields.first
if field.methods.include? :doc
puts "Success! doc: #{field.doc}"
else
puts "Failure..."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment