diff --git a/spec/json/streamer/json_streamer_spec.rb b/spec/json/streamer/json_streamer_spec.rb index b35f65d..390c1dc 100644 --- a/spec/json/streamer/json_streamer_spec.rb +++ b/spec/json/streamer/json_streamer_spec.rb @@ -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