Skip to content

Commit

Permalink
Refactor test file to match naming and module structure; Add array yi…
Browse files Browse the repository at this point in the history
…eld test case
  • Loading branch information
thisismydesign committed May 4, 2017
1 parent 027fa94 commit 1f3b673
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions spec/streamer_spec.rb → spec/json/streamer/json_streamer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@example_hash = {@example_key => @example_value}
end

describe '#get_nesting_level' do
describe '#get' do

context 'Get 0th level of empty JSON object' do
it 'should yield empty JSON object' do
Expand Down Expand Up @@ -133,10 +133,6 @@
end
end

end

describe '#get_nesting_level' do

context 'Get data from flat JSON by key' do
it 'should yield value within JSON object' do

Expand Down Expand Up @@ -213,6 +209,25 @@
end
end

context 'JSON array' do
it 'should yield array elements' do

hash = [@example_hash, @example_hash, @example_hash]
json_file_mock = StringIO.new(JSON.generate(hash))
streamer = Json::Streamer::JsonStreamer.new(json_file_mock, 10)

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

expect(objects.length).to eq(3)
objects[0..2].each do |element|
expect(element).to eq(@example_hash)
end
end
end

end

end

0 comments on commit 1f3b673

Please sign in to comment.