Skip to content

Commit

Permalink
Refactor descriptions; Change JSON array test to multi level
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismydesign committed May 4, 2017
1 parent 1f3b673 commit d37c16c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions spec/json/streamer/json_streamer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

describe '#get' do

context 'Get 0th level of empty JSON object' do
context '0th level of empty JSON object' do
it 'should yield empty JSON object' do

hash = {}
Expand All @@ -27,7 +27,7 @@
end
end

context 'Get first level from JSON' do
context '1st level from JSON' do
it 'should yield objects within JSON object' do

hash = {'object1':@example_hash, 'object2':@example_hash, 'object3':@example_hash}
Expand All @@ -46,7 +46,7 @@
end
end

context 'Get first level from JSON array' do
context '1st level from JSON array' do
it 'should yield objects in array elements' do

array = Array.new(10) {@example_hash}
Expand Down Expand Up @@ -100,7 +100,7 @@
end
end

context 'Get values' do
context 'Yield values enabled' do
it 'should yield values from given level' do

hash = {obj:@example_hash}
Expand All @@ -117,7 +117,7 @@
end
end

context 'Do not get values' do
context 'Yield values disabled' do
it 'should not yield values from given level' do

hash = {obj:@example_hash}
Expand All @@ -133,7 +133,7 @@
end
end

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

json_file_mock = StringIO.new(JSON.generate(@example_hash))
Expand All @@ -151,7 +151,7 @@
end
end

context 'Get data from multi level JSON by key' do
context 'By key from multi level JSON' do
it 'should yield values within JSON object second level' do

hash = {obj1:@example_hash, obj2:@example_hash, obj3:@example_hash}
Expand All @@ -170,7 +170,7 @@
end
end

context 'Get data from multi level JSON by key' do
context 'By key from multi level JSON' do
it 'should yield values within JSON object from all levels the key occurs' do

hash = {'obj1' => @example_hash, @example_key => @example_value}
Expand All @@ -189,7 +189,7 @@
end
end

context 'Get data from multi level JSON by key' do
context 'By key from multi level JSON' do
it 'should yield values and objects as well within JSON object from all levels the key occurs' do

hash = {'obj1' => @example_hash, @example_key => @example_value, 'obj2' => {@example_key => @example_hash}}
Expand All @@ -209,15 +209,15 @@
end
end

context 'JSON array' do
context '2nd level of multi-level JSON array' do
it 'should yield array elements' do

hash = [@example_hash, @example_hash, @example_hash]
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|
streamer.get(nesting_level:2) do |object|
objects.push(object)
end

Expand Down

0 comments on commit d37c16c

Please sign in to comment.