Created
March 14, 2012 15:52
-
-
Save peterhellberg/2037425 to your computer and use it in GitHub Desktop.
Some (maybe) unexpected return values from yajl-ruby (0.8.3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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