Skip to content

Commit

Permalink
Add test case for EventMachine style chunked input
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismydesign committed May 29, 2017
1 parent 6915fc8 commit a71c8a7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/json/streamer/json_streamer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@
end
end

context '1st level from EventMachine style chunked input' do
it 'should yield objects within JSON object' do

hash = {'object1':@example_hash, 'object2':@example_hash, 'object3':@example_hash}
streamer = Json::Streamer::JsonStreamer.new

objects = []
streamer.get(nesting_level:1) do |object|
objects.push(object)
end

chunk_size = 10
json_file_mock = StringIO.new(JSON.generate(hash))
json_file_mock.each(chunk_size) do |chunk|
streamer.parser << chunk
end

expect(objects.length).to eq(hash.length)
objects.each do |element|
expect(element).to eq(@example_hash)
end
end
end

context 'JSONs with various nesting level and number of objects per level' do
it 'should yield all objects on desired level (checking number of yielded objects)' do

Expand Down

0 comments on commit a71c8a7

Please sign in to comment.