summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-11-22 13:57:21 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2014-11-22 13:57:21 -0800
commit6b5afcb529444ab54cea14fbd5ea76dbce9e4d93 (patch)
treefd27df21857dc257ed45e41b44c36f66694f1f20 /spec
parentf234c9b05b4857defed81eac023933e4c4a9d437 (diff)
downloadffi-yajl-6b5afcb529444ab54cea14fbd5ea76dbce9e4d93.tar.gz
add busted specs for outstanding parser bugs
Diffstat (limited to 'spec')
-rw-r--r--spec/ffi_yajl/parser_spec.rb50
1 files changed, 49 insertions, 1 deletions
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
-