Exercises
We covered a lot of new material throughout this chapter, so to better understand, we recommend doing the exercises and creating your own project with acceptance tests:
- Create a Ruby-based web service
book-library
to store books:
The acceptance criteria is delivered in the form of the following Cucumber feature:
Scenario: Store book in the library Given: Book "The Lord of the Rings" by "J.R.R. Tolkien" with ISBN number "0395974682" When: I store the book in library Then: I am able to retrieve the book by the ISBN number
- Write step definitions for the Cucumber test
- Write the web service (the simplest is to use the Sinatra framework: http://www.sinatrarb.com/, but you can also use Ruby on Rails).
- The book should have the following attributes: name, author, and ISBN.
- The web service should have the following endpoints:
- POST "
/books/
" to add a book - GET "
books/<isbn>
" to retrieve the book
- POST "
- The data can be stored in the memory.
- In the end, check if the acceptance test is green.
- Add "book...