How to Integrate rspec into a Sinatra App
videos

How to Integrate rspec into a Sinatra App

Tutorial Details
  • Technologies: Ruby, Sinatra, rspec
  • Difficulty: Moderate
  • Format: 11 Minute Screencast

In today’s video tutorial, I’m going to teach you how to use rspec within a Sinatra application. Along the way, we’ll also arrange for autotesting with Growl notifications so that our tests run automatically when we save our projects. If you’re quite new to the idea of testing, this is the perfect introduction.

Choose 720p for optimal viewing.
Subscribe to our YouTube and Blip.tv channels to watch more screencasts.

We’ll Cover…

  • Installing rspec
  • Integrating rspec into a Sinatra application
  • The basic syntax for rspec tests
  • Enabling Growl notifications
  • Autotesting

Add Comment

Discussion 8 Comments

  1. Jeffrey Way says:
    Author

    Hey guys. I can’t remember if I covered this in the video, but if not: after you move your _spec file to the spec/ folder, make sure you update the “require” at the top of the page. You can do require_relative ‘../reverse.rb’

  2. Tom says:

    Great screencast! I didn’t realise testing was this easy in sinatra, so I haven’t bothered to do it properly before. Looks like that’ll change :P

  3. G says:

    Great screencast as always. btw you can reverse the string just by calling it directly string.reverse

    • Jeffrey Way says:
      Author

      Thanks! Yeah, I know about the reverse method; I had planned on doing something fun with those join/split methods to help out with the testing aspect, but it ended up being cut out of the screencast. :/

  4. salomoko says:

    real nice tut!

  5. Bram Jetten says:

    Great screencast Jeffrey. I like how you’re really to the point. :-)

  6. Still can’t get into a habit testing my ruby code :( Thanks anyway

  7. geeknam says:

    For those who do not have the newest ruby. You gotta add the following instead:

    require File.join(File.dirname(__FILE__), ‘../reverse.rb’)
    require ‘rubygems’

    Just fyi :)

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.