diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2013-12-13 16:12:21 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2013-12-13 16:12:21 -0800 |
commit | d152d4826c802a9558c1c336d70bcfd6b5827634 (patch) | |
tree | 22c05d5c15777f73995480cf89c667d0048e49d0 /spec | |
parent | 0ce27f29202be406a41fce56d38d6da6c7715afd (diff) | |
download | ffi-yajl-d152d4826c802a9558c1c336d70bcfd6b5827634.tar.gz |
add tests for missing/trailing brackets/braces
also fixed test for adding #to_json without loading json_compat
which is currently broken.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/ffi_yajl/parser_spec.rb | 30 | ||||
-rw-r--r-- | spec/spec_helper.rb | 2 |
2 files changed, 32 insertions, 0 deletions
diff --git a/spec/ffi_yajl/parser_spec.rb b/spec/ffi_yajl/parser_spec.rb new file mode 100644 index 0000000..28a0f36 --- /dev/null +++ b/spec/ffi_yajl/parser_spec.rb @@ -0,0 +1,30 @@ + + +require 'spec_helper' + +describe "FFI_Yajl::Parser" do + + let(:parser) { FFI_Yajl::Parser.new } + + it "throws an exception when trailing braces are missing" do + json = '{{"foo": 1234}' + expect { parser.parse(json) }.to raise_error(FFI_Yajl::ParseError) + end + + it "throws an exception when trailing brackets are missing" do + json = '[["foo", "bar"]' + expect { parser.parse(json) }.to raise_error(FFI_Yajl::ParseError) + end + + it "throws an exception when it has an extra brace" do + json = '{{"foo": 1234}}}' + expect { parser.parse(json) }.to raise_error(FFI_Yajl::ParseError) + end + + it "throws an exception when it has an extra bracket" do + json = '[["foo", "bar"]]]' + expect { parser.parse(json) }.to raise_error(FFI_Yajl::ParseError) + end + +end + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 83b4705..05effa2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,7 @@ $: << File.expand_path(File.join(File.dirname( __FILE__ ), "../lib")) +require 'ffi_yajl' + RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true |