Feature: Borrowing books
Members of the library borrow books and take them home.
Each member may hold a few books at a time, for a few weeks each.
- Given a member named "Ana" with card number 1024
- And the library is open
A book on the shelf can be borrowed at once.
From the background: Background: A member at the desk
- Given a member named "Ana" with card number 1024
- And the library is open
- Given the book "The Hobbit" is on the shelf
- When "Ana" borrows "The Hobbit"
- Then "The Hobbit" is due back in 21 days
- And "Ana" holds 1 book
From the background: Background: A member at the desk
- Given a member named "Ana" with card number 1024
- And the library is open
- Given these books are on the shelf:
title author Middlemarch George Eliot Dom Casmurro Machado de Assis Either | Or Søren Kierkegaard - When "Ana" borrows every book on the shelf
- Then "Ana" holds 3 books
From the background: Background: A member at the desk
- Given a member named "Ana" with card number 1024
- And the library is open
- Given the book "<title>" is on the shelf
- When "Ana" borrows "<title>"
- Then "<title>" is due back in <days> days
| title | days |
|---|---|
| The Hobbit | 21 |
| Middlemarch | 21 |
| title | days |
|---|---|
| Metropolis | 7 |
- Given the book "The Hobbit" is on the shelf
- When "Ana" borrows "The Hobbit"
- Then "The Hobbit" is due back in 21 days
- Given the book "Middlemarch" is on the shelf
- When "Ana" borrows "Middlemarch"
- Then "Middlemarch" is due back in 21 days
- Given the book "Metropolis" is on the shelf
- When "Ana" borrows "Metropolis"
- Then "Metropolis" is due back in 7 days
The limit keeps books on the shelves for everyone.
- Given "Ana" holds 5 books
From the background: Background: A member at the desk
- Given a member named "Ana" with card number 1024
- And the library is open
From the rule's background: Background: A member near the limit
- Given "Ana" holds 5 books
- Given the book "Emma" is on the shelf
- When "Ana" borrows "Emma"
- Then the loan is refused with "You already hold 5 books."
- And "Ana" holds 5 books
From the background: Background: A member at the desk
- Given a member named "Ana" with card number 1024
- And the library is open
From the rule's background: Background: A member near the limit
- Given "Ana" holds 5 books
- Given "Ana" returns "The Hobbit"
- And the book "Emma" is on the shelf
- When "Ana" borrows "Emma"
- Then "Ana" holds 5 books
From the background: Background: A member at the desk
- Given a member named "Ana" with card number 1024
- And the library is open
- Given "Bea" asked to hold "Emma"
- And the book "Emma" is on the shelf
- When "Ana" borrows "Emma"
- Then the loan is refused with "Emma is on hold for another member."