Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You could probably get away with using <a href="http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines" rel="noreferrer">scenario outlines</a> to keep the repetition down in your feature file, but be aware that it will expand to a very large number of actually-run scenarios, so it'll be slower than you'd expect. Something like this should probably work, assuming 5 books per page. I'll leave the step definitions as an exercise, but they should be pretty straightforward.</p> <p>I should also mention that I haven't actually run this, so take any syntax errors with a grain of salt.</p> <pre><code>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 &lt;count&gt; books When I view all books from page &lt;page&gt; Then I should see a link to page &lt;target page&gt; 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 &lt;count&gt; books When I view all books from page &lt;page&gt; Then I should see a disabled pagination link to page &lt;page&gt; Examples: | count | page | | 8 | 1 | | 8 | 2 | | 13 | 1 | | 13 | 2 | | 13 | 3 | Scenario: Next Page links Given I have &lt;count&gt; books When I view all books from page &lt;page&gt; Then I should see a link "Next Page" When I click "Next Page" Then I should be on page &lt;next page&gt; # assert against query params maybe? # alternately, to keep page requests down, one could use something like: # Then I should see a link "Next Page" going to "?p=&lt;next page&gt;" Examples: | count | page | next page | | 8 | 1 | 2 | | 13 | 1 | 2 | | 13 | 2 | 3 | Scenario: Next Page links on last page Given I have &lt;count&gt; books When I view all books from page &lt;page&gt; Then I should see a disabled pagination link "Next Page" Examples: | count | page | | 8 | 2 | | 13 | 3 | </code></pre> <p>Similar scenarios could be used for checking the link state of Previous/First/Last as for Next, and you could add some followup clicking to the Page Links scenario similar to what the Next Page scenario is doing if you wanted. You might also want to add extra examples to check that your pagination is at exactly 5, since the examples I've picked would also pass if pagination was 6 per page. Depends on what exactly your goals are for checking the pagination functionality.</p> <p>If you eventually decide on something other than will_paginate, then the only things you'd need to look at changing might be a few of the steps (like the disabled pagination ones).</p> <p>And as you mention asking for links, this might make a good blog post too ;)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload