You will probably be able to use scripting scripts to keep the repetition in your function file, but keep in mind that it will expand to a lot of actual scripts, so it will be slower than you expected. Perhaps something like this should work, assuming 5 books per page. I left the definitions of steps as an exercise, but they should be fairly simple.
, , .
Feature: Book Browsing Pagination
Scenario: No results
Given I have 0 books
When I view all books
Then I should see "No results" on the page
Scenario: Some results
Given I have 3 books
When I view all books
Then I should see "Book 1"
And I should see "Book 2"
And I should see "Book 3"
Scenario: Page links
Given I have <count> books
When I view all books from page <page>
Then I should see a link to page <target page>
Examples:
| count | page | target page |
| 8 | 1 | 2 |
| 8 | 2 | 1 |
| 13 | 1 | 2 |
| 13 | 1 | 3 |
| 13 | 2 | 1 |
| 13 | 2 | 3 |
| 13 | 3 | 1 |
| 13 | 3 | 2 |
Scenario: Page links for current page
Given I have <count> books
When I view all books from page <page>
Then I should see a disabled pagination link to page <page>
Examples:
| count | page |
| 8 | 1 |
| 8 | 2 |
| 13 | 1 |
| 13 | 2 |
| 13 | 3 |
Scenario: Next Page links
Given I have <count> books
When I view all books from page <page>
Then I should see a link "Next Page"
When I click "Next Page"
Then I should be on page <next page>
Examples:
| count | page | next page |
| 8 | 1 | 2 |
| 13 | 1 | 2 |
| 13 | 2 | 3 |
Scenario: Next Page links on last page
Given I have <count> books
When I view all books from page <page>
Then I should see a disabled pagination link "Next Page"
Examples:
| count | page |
| 8 | 2 |
| 13 | 3 |
//, Next, , , . , , 5, , , , 6 . , .
- , will_paginate, , , (, ).
, ;)