Exercise Wednesday

Goal: Practice creating class methods and class variables. Use them in your Sinatra apps, and update the server with POST requests through forms. You should also incorporate dynamic routing so users can look at a detail page for an item on the list. Add integration testing for each path through your application that a user can take.

Warm Up

  • What are the advantages to nested routing? What are some of the disadvantages?
  • Why is integration testing important?
  • What is save_and_open_page? How can we use it to help debug our applications?


Record Store Continued

Follow along with the homework lessons and add CRUD functionality for Songs. Consider adding Song properties such as lyrics, songwriter and so on. Once you've completed all CRUD, add integration testing to your application. Feel free to style and continue building out the application to add any functionality that interests you.

Woodland Mists Festival

Create a website for a local festival in the woods. A user should be able to create, read, update and delete a Stage and should also be able to create, read, update and delete an Artist. Artists belong to Stages. For the purposes of this project, an Artist can only perform on a single Stage — otherwise, we'd need to use a many-to-many relationship, which is much more complicated.

Start with unit tests and get all tests passing before starting on integration testing and Sinatra. Make sure integration tests cover all the ways a user may navigate through your pages.


Create a Sinatra application with CRUD functionality where users can traverse a maze. Each "room" of the maze should have a description and one or more ways to move to another room. For instance, if the room is a dead end, then a user should be able to return to the previous room. There could be a winning condition if the user successfully traverses the maze.

  • Start by building a maze with a few hard-coded rooms. Use a whiteboard to visualize your maze before building it. Then add CRUD functionality so users can add more rooms to the maze.
  • Add objects with their own descriptions to the rooms. This will involve nested routing — for instance, an object belongs to a room. For a user to look at it, they might have to navigate to /rooms/7/objects/3.
  • Add an additional layer of complexity to your application. Allow a user to pick up items from various rooms of the maze. Some of these items (such as a key or a flashlight) might be necessary to successfully escape.
  • Add levers to some of the rooms. A user will only be able to pass through the door to the exit if the levers are in a certain position.
  • Continue to build out your maze in any way you like!

Peer Code Review

  • Are objects created from a custom class with custom methods?
  • Does Sinatra process GET and POST requests and responses correctly?
  • Do specs have complete coverage for behaviors that need to be tested?
  • Is the logic easy to understand?
  • Is integration testing in place for each route a user may traverse on the site?
  • Is the code clean and well-refactored?

Lesson 30 of 37
Last updated August 7, 2022