Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Created March 14, 2012 15:52
Show Gist options
  • Save peterhellberg/2037425 to your computer and use it in GitHub Desktop.
Save peterhellberg/2037425 to your computer and use it in GitHub Desktop.
Some (maybe) unexpected return values from yajl-ruby (0.8.3)
require 'yajl'
require 'minitest/spec'
require 'minitest/autorun'
describe Yajl do
def parse(*args)
Yajl::Parser.parse(*args)
end
it "returns an empty hash sometimes" do
parse('{') == {}
parse('{"') == {}
parse('{"foo bar baz') == {}
end
it "returns nil in some cases" do
parse('"') == nil
parse(' ') == nil
end
it "returns an empty string sometimes" do
parse('{""') == ""
end
it "raises parse errors in some cases" do
-> { parse("'") }.must_raise Yajl::ParseError
-> { parse(nil) }.must_raise Yajl::ParseError
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment