|
355 | 355 |
|
356 | 356 | let(:items) { service.fetch_all { |token| responses[token] } } |
357 | 357 |
|
| 358 | + let(:responses2) do |
| 359 | + data = {} |
| 360 | + data[nil] = OpenStruct.new( |
| 361 | + next_page_token: 'p1', alt_page_token: 'p2', items: ['a', 'b', 'c'], alt_items: [1, 2, 3], singular: 'foo', hash_: { 'foo' => 1, 'bar' => 2 }) |
| 362 | + data['p1'] = OpenStruct.new( |
| 363 | + next_page_token: 'p2', items: ['d', 'e', 'f'], alt_items: [4, 5, 6], singular: 'bar', hash_: nil) |
| 364 | + data['p2'] = OpenStruct.new( |
| 365 | + next_page_token: '', alt_page_token: nil, items: ['g', 'h', 'i'], alt_items: [7, 8, 9], singular: 'baz', hash_: { 'baz' => 3 }) |
| 366 | + data |
| 367 | + end |
| 368 | + |
| 369 | + let(:items2) { service.fetch_all { |token| responses2[token] } } |
| 370 | + |
358 | 371 | it 'should fetch pages until next page token is nil' do |
359 | 372 | expect(items).to contain_exactly('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i') |
360 | 373 | end |
361 | 374 |
|
| 375 | + it 'should fetch pages until next page token is empty' do |
| 376 | + expect(items2).to contain_exactly('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i') |
| 377 | + end |
| 378 | + |
362 | 379 | it 'should stop on repeated page token' do |
363 | 380 | responses['p2'].next_page_token = 'p2' |
364 | 381 | expect(items).to contain_exactly('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i') |
|
0 commit comments