Skip to content

Commit

Permalink
Docs: add testing section (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
benkoshy authored Oct 31, 2023
1 parent 836fb75 commit 0a220b1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -834,3 +834,18 @@ end
!!!warning Rescue from `Pagy::OverflowError` first
All Pagy exceptions are subclasses of `ArgumentError`, so if you need to `rescue_from ArgumentError, ...` along with `rescue_from Pagy::OverflowError, ...` then the `Pagy::OverflowError` line should go BEFORE the `ArgumentError` line or it will never get rescued.
!!!


## Test with Pagy

* Pagy has 100% test coverage.
* You only need to test pagy if you have overridden methods, or if using your own templates.

If you need to test pagination, remember:

- `Pagy::DEFAULT` should be set by your initializer and be frozen. You can test that your code cannot change it.
- You can override defaults - i.e. any pagy variable can be passed to a pagy constructor - e.g.

```rb
@pagy, @books = pagy(Book.all, items: 10) # the items default has been overridden
```

0 comments on commit 0a220b1

Please sign in to comment.