Skip to content

CAST 2011 Presentation: Intro to Sinatra

The Sinatra logo (a fedora)

When I attended CAST 2011 this year, I was given a really neat opportunity: to present! I selected Sinatra as my topic, for a few reasons:

  • Its low barrier to entry (easy to learn and free)
  • I had a few interesting experiences with Sinatra to share
  • I wanted to demonstrate that testers could write useful code that wasn’t automation

The presentation (in 3 parts) went something like this:

#1: What’s Sinatra?

Since the audience was potentially a mix of coders, non-coders, etc., I wanted to lay some groundwork, including:

  • What’s a DSL?
  • What’s a web application, exactly?
  • Why Ruby: its readability, the robust native string manipulation library, how regular expressions are tightly integrated, the vast repository of helpful gems
The Final Countown by Europe album cover

An early idea was to play “Final Countdown” while coding

#2: Live demo

Next, I gave a live coding demonstration (I’ve since been told that I was…brave for trying this). There were four distinct steps:

  1. A static response (essentially, the example on the Sinatra home page)
  2. A dynamic response
  3. A dynamic view (ERB)
  4. Dynamic data (JSON)

#3: Examples

I shared 3 examples where Sinatra saved the day:

  1. An e-commerce payment gateway that we had to work with was in many respects a “black box”, and it was drastically limiting our ability to test. We understood how the requests and responses worked well enough to build a replica in Sinatra, however, giving us the testability features we needed, including:

    • Logging
    • Recall of past transactions
    • “Magic” functionality (ex. getting any gift certificate amount you wanted)
    • Error simulations (ex. internal server errors, connection timeouts, etc.)
  2. The diverse set of tools used by my team at Interactive Partners led to an unfortunate case of information siloing, but thankfully they all had APIs, so a Sinatra application named iP Relay was created to help “glue” them all together, for example:

    When David, one of our developers, does a deployment using Capistrano:
    > cap deploy
    Our faithful chat servant Botsworth announces it to the team:
    Botsworth: David Stamm deployed 3.16.1 (023c968) to SHO production

    Or, when he makes a commit with a message in this format (with the square brackets at the end):
    Bug #1941 (a bug that will live in infamy) — Fixed incorrect link URL. [bug: 1941, status: resolved]
    A screenshot of the "Testing Test"

    Screenshot of the "Testing Test"

    The following actions are carried out in our bug tracker, Bugzilla:
    Add comment to bug #1941, change status to “RESOLVED”.
  3. When hiring, without access to old bug reports or test plans, it was difficult to evaluate how well candidates could find and report on bugs, so a Sinatra application named Testing Test was created to help test the testers. The person we ended up hiring found all of the bugs we intended to be in there, and even some we didn’t!

Slides

Finally, the slides shown to the audience, for your viewing pleasure:

Categories: Testing.

Tags: , , ,

No responses (yet)