summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-04-20 13:37:52 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-04-20 13:37:52 -0700
commita1d4ff3ab371aecc92182f3fc9ff5a966a2df8bc (patch)
treeeaf61da3581bcbb0102a39d62b2d312f7040cb41 /spec
parent5f9b3bd8e896cdba674d16dff83d4c9463d752d7 (diff)
parent329352cda438729a240ff450338f514938d74ba6 (diff)
downloadffi-yajl-a1d4ff3ab371aecc92182f3fc9ff5a966a2df8bc.tar.gz
Merge pull request #55 from chef/lcg/unique_key_checking
add :unique_key_checking flag to parser
Diffstat (limited to 'spec')
-rw-r--r--spec/ffi_yajl/parser_spec.rb15
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