Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
96 lines (63 sloc) 2.17 KB

Forked from

This is the source code for the sinatra-template project on github. It's the basic structure I use for my Sinatra projects and it make things a bit more organized.

What's inside?

  • Modular Sinatra app
  • rspec for unit-level tests
  • rack-test for routes tests
  • cucumber and rspec
  • yard for documentation
  • Rakefile, Gemfile, .rvmrc, .gitignore, .autotest, .rspec

Folders Structure

app.rb          # require sinatra, models/init, routes/init, helpers/init

  boot.rb       # bundler setup

  init.rb       # Require each helper file
  api_helper.rb # Related helper methods

  init.rb       # Require each model, in controlled order
  user.rb       # model

  init.rb       # Require each route, in controlled order
  api.rb        # One or more routes related to some feature

  layout.erb    # Common layout
  index.erb     # Specific view

  models        # rspec
  routes        # rspec and rack-test

features/       # cucumber and rspec


Install Ruby 1.9.2 (if necessary). 'rvm' or 'rbenv' are optional, but highly recommended


rvm install ruby-1.9.2-p318
git clone
cd sinatra-template


rbenv install 1.9.2-p318
rbenv rehash
git clone
cd sinatra-template

Install bundler

gem install bundler

Install the gems

bundle install

View all available rake commands

bundle exec rake -T

bundle exec rake                  # Run all tests
bundle exec rake cucumber         # Run acceptance tests
bundle exec rake rspec:models     # Run models tests
bundle exec rake rspec:routes     # Run routes tests
bundle exec rake yard             # Generate YARD Documentation

Run the server

bundle exec rackup

Go to

IRB console testing

RACK_ENV=development irb
:001 > require './app'

TDD with RSpec and Autotest

bundle exec autotest
Something went wrong with that request. Please try again.