diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-04-17 18:05:45 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-04-17 18:05:45 -0700 |
commit | 846a93684d2d81ef102717004cd076c1b93544f7 (patch) | |
tree | 18615d57b3ae7d10f1a7ace71504226fde5d42ad /spec | |
parent | 5f9b3bd8e896cdba674d16dff83d4c9463d752d7 (diff) | |
download | ffi-yajl-846a93684d2d81ef102717004cd076c1b93544f7.tar.gz |
add :unique_key_checking flag to parserlcg/unique_key_checking
can be used to error out if keys are duplicated in input rather than
silently replacing.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/ffi_yajl/parser_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/ffi_yajl/parser_spec.rb b/spec/ffi_yajl/parser_spec.rb index 7592f67..ed6ef2a 100644 --- a/spec/ffi_yajl/parser_spec.rb +++ b/spec/ffi_yajl/parser_spec.rb @@ -492,6 +492,21 @@ describe "FFI_Yajl::Parser" do expect{ parser }.not_to raise_error end end + + context "should ignore repeated keys by default" do + let(:json) { '{"foo":"bar","foo":"baz"}' } + it "should replace the first hash key with the second" do + expect(parser).to eql( "foo" => "baz" ) + end + end + + context "should raise an exception for repeated keys" do + let(:json) { '{"foo":"bar","foo":"baz"}' } + let(:options) { { :unique_key_checking => true } } + it "should raise" do + expect{ parser }.to raise_error(FFI_Yajl::ParseError) + end + end end context "when options are set to empty hash" do |