From 6b5afcb529444ab54cea14fbd5ea76dbce9e4d93 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Sat, 22 Nov 2014 13:57:21 -0800 Subject: add busted specs for outstanding parser bugs --- spec/ffi_yajl/parser_spec.rb | 50 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/ffi_yajl/parser_spec.rb b/spec/ffi_yajl/parser_spec.rb index c6ca3e4..0afae3f 100644 --- a/spec/ffi_yajl/parser_spec.rb +++ b/spec/ffi_yajl/parser_spec.rb @@ -14,6 +14,55 @@ describe "FFI_Yajl::Parser" do end end + context "when parsing nil" do + let(:json) { nil } + it "should not coredump ruby" do + expect{ parser }.to raise_error(FFI_Yajl::ParseError) + end + end + + context "when parsing bare int" do + let(:json) { "1" } + it "should parse to the int value" do + expect( parser ).to eq(1) + end + end + + context "when parsing bare string" do + let(:json) { '"a"' } + it "should parse to the string value" do + expect( parser ).to eq("a") + end + end + + context "when parsing bare true" do + let(:json) { "true" } + it "should parse to the true value" do + expect( parser ).to eq(true) + end + end + + context "when parsing bare false" do + let(:json) { "false" } + it "should parse to the false value" do + expect( parser ).to eq(false) + end + end + + context "when parsing bare null" do + let(:json) { "null" } + it "should parse to the nil value" do + expect( parser ).to eq(nil) + end + end + + context "when parsing bare float" do + let(:json) { "1.1" } + it "should parse to the a float" do + expect( parser ).to eq(1.1) + end + end + context "when json has comments" do let(:json) { '{"key": /* this is a comment */ "value"}' } @@ -482,4 +531,3 @@ describe "FFI_Yajl::Parser" do end end end - -- cgit v1.2.1