Permalink
Browse files

add spec for :dispose

  • Loading branch information...
1 parent 68c76b7 commit e5faff08a587f7addbd3eabb2a82a3608be1f521 @timon committed Jun 26, 2012
Showing with 24 additions and 0 deletions.
  1. +24 −0 spec/parsing/partial_streaming_spec.rb
@@ -31,4 +31,28 @@
toys.should eql(%w(buzz rex bo hamm))
end
+
+ it "should remove hash from array if on_hash_end callback returns :dispose" do
+ toys = []
+
+ @parser.on_hash_end = lambda do |hash, level|
+ toys.push hash["id"]
+ :dispose
+ end
+
+
+ @parser.on_parse_complete = lambda do |obj|
+ obj.should eql([])
+ end
+
+ @parser << '['
+ @parser << ' {"id": "buzz"},'
+ @parser << ' {"id": "rex"},'
+ @parser << ' {"id": "bo"},'
+ @parser << ' {"id": "hamm"}'
+ @parser << ']'
+
+ toys.should eql(%w(buzz rex bo hamm))
+ end
end
+

0 comments on commit e5faff0

Please sign in to comment.