JSON and Testing Sinatra

Readme Homework

Episode 11 -- JSON

Return JSON (tested) in Sinatra and Rabl

Panda Level

  1. Add an attribute named :execution_time to the LogRequest
  2. Make sure to test that it is included in the JSON result

Tiger Level

  1. Implement a post "/" that will log the request
  2. Receive JSON on the post and insert the record into the in-memory store
  3. Write a test that confirms that you can post a log entry and read it back on a subsequent call

Eagle Level

  1. Implement a user scheme, where a User object has a unique code
  2. If I pass in the "code" as a parameter to get "/", then it only returns my logs
  3. Make the code be required on the post. Return a 401 error code if it is not present

Show Links


Copyright: 2012 Jesse Wolgamott, MIT License (See LICENSE)

JSON and Testing Sinatra

  • Area:

  • Runtime:

  • Tech:

    Sinatra, API  
  • Tags:

    sinatra api json  

We'll return JSON from a sinatra app --- otherwise known as a web API! yay! In addition, it sets up a small monitoring app where you can accept logs from a bunch of different servers.

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.


Ruby Off Rails is dedicated to accelerating the mastering of Ruby and increasing developer happiness everywhere.

In my software training, I see two distinct sets of programmers: those who know Ruby, and those who haven’t learned it yet. People who learn Ruby have an easier time understanding Rails, gems, and what magic voodoo is going on. And most importantly, they can cast wicked voodoo themselves.