File: last_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 (31 lines) | stat: -rw-r--r-- 866 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
shared_examples 'an endpoint with a last page' do
  it 'should not give a link with rel "last"' do
    expect(link).not_to include('rel="last"')
  end

  it 'should not give a link with rel "next"' do
    expect(link).not_to include('rel="next"')
  end

  it 'should give a link with rel "first"' do
    expect(links).to include('<http://example.org/numbers?count=100&page=1>; rel="first"')
  end

  it 'should give a link with rel "prev"' do
    expect(links).to include('<http://example.org/numbers?count=100&page=9>; rel="prev"')
  end

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

  it 'should list the last page of numbers in the response body' do
    body = '[91,92,93,94,95,96,97,98,99,100]'

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