Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add spec for :dispose

  • Loading branch information...
commit e5faff08a587f7addbd3eabb2a82a3608be1f521 1 parent 68c76b7
@timon authored
Showing with 24 additions and 0 deletions.
  1. +24 −0 spec/parsing/partial_streaming_spec.rb
View
24 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
+
Please sign in to comment.
Something went wrong with that request. Please try again.