File: middle_page.rb

package info (click to toggle)
ruby-api-pagination 4.8.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 272 kB
  • sloc: ruby: 1,125; makefile: 3
file content (22 lines) | stat: -rw-r--r-- 789 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
shared_examples 'an endpoint with a middle page' do
  it 'should give all pagination links' do
    expect(links).to include('<http://example.org/numbers?count=100&page=1>; rel="first"')
    expect(links).to include('<http://example.org/numbers?count=100&page=10>; rel="last"')
    expect(links).to include('<http://example.org/numbers?count=100&page=3>; rel="next"')
    expect(links).to include('<http://example.org/numbers?count=100&page=1>; rel="prev"')
  end

  it 'should give a Total header' do
    expect(total).to eq(100)
  end

  it 'should list a middle page of numbers in the response body' do
    body = '[11,12,13,14,15,16,17,18,19,20]'

    if defined?(response)
      expect(response.body).to eq(body)
    else
      expect(last_response.body).to eq(body)
    end
  end
end