Cache pages in fetch_all to allow multiple iterations

This commit is contained in:
Steve Bazyl committed 2016-03-11 14:24:27 -08:00
1 parent 0ebb4165ef
commit 6e3342b671
2 files changed
+46 -6

No files matched your search

+27
View File
@@ -281,6 +281,33 @@ EOF
end.count
end.to yield_successive_args(nil, 'p1', 'p2')
end
it 'should cache results' do
count = 0
items = service.fetch_all do |token|
count = count + 1
responses[token]
end
items.each{ |i| puts i }
items.each{ |i| puts i }
expect(count).to eq 3
end
it 'should allow disabling caching' do
count = 0
items = service.fetch_all(cache: false) do |token|
count = count + 1
responses[token]
end
items.each{ |i| puts i }
items.each{ |i| puts i }
expect(count).to eq 6
end
end
end
end